Skip to content

Commit

Permalink
Fix ignored external build module reference due to build configuratio…
Browse files Browse the repository at this point in the history
…n json resolve
  • Loading branch information
t-ski committed Nov 14, 2024
1 parent 4e297c3 commit acb5330
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 5 deletions.
18 changes: 13 additions & 5 deletions packages/rjs-build/src/Plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,26 @@ export class Plugin {

private resolveBuildModulePath(): string {
const buildConfig: TJSON = this.fetchBuildConfig();
const buildModuleReferences: string[] = [
..._config.buildModuleNames.map((buildModuleName: string) =>
const buildModuleReferences: string[] = _config.buildModuleNames.map(
(buildModuleName: string) =>
join(this.pluginDirectoryPath, buildModuleName)
),
buildConfig[_config.buildModuleReferenceKey] as string
];
);
buildConfig[_config.buildModuleReferenceKey] &&
buildModuleReferences.push(
resolve(
this.pluginDirectoryPath,
buildConfig[_config.buildModuleReferenceKey] as string
)
);

let buildModulePath: string;
while (!buildModulePath && buildModuleReferences.length) {
const buildModuleReference: string = buildModuleReferences.shift();
try {
buildModulePath = require.resolve(buildModuleReference);
buildModulePath = !/\.json$/.test(buildModulePath)
? buildModulePath
: null;
} catch {}
}

Expand Down
6 changes: 6 additions & 0 deletions packages/rjs-build/test/unit/build.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ new UnitTest("Basic build")
name: "out",
extension: "txt",
contents: "O\nP1\nP2"
},
{
relativePath: "generated/out.txt",
name: "out",
extension: "txt",
contents: "[generated]"
}
]
)
Expand Down
1 change: 1 addition & 0 deletions packages/rjs-server/src/TLSRedirectServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export function createTLSRedirectServer(
});
}

// TODO: Proxy?
export class TLSRedirectServer extends EventEmitter {
constructor(sourcePort: number = 80, targetPort: number = 443) {
super();
Expand Down
3 changes: 3 additions & 0 deletions test-app/ext-plugin/plugin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = (rJS) => {
return new rJS.File("generated/out.txt", "[generated]");
};
3 changes: 3 additions & 0 deletions test-app/src/generate/__rjs.plugin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"package": "../../ext-plugin/plugin.js"
}

0 comments on commit acb5330

Please sign in to comment.