Fix CI build failures due to extranous double quotes and await worker termination in config Cases

Can you believe it was only due to an extra "" in the code? smh...
This commit is contained in:
Thomas Tay 2023-02-09 14:51:42 -08:00
parent 06368638c5
commit 0d91c55f76
3 changed files with 11 additions and 9 deletions

View File

@ -101,6 +101,10 @@ WorkerDependency.Template = class WorkerDependencyTemplate extends (
chunkGraph.getBlockChunkGroup(block)
);
const chunk = entrypoint.getEntrypointChunk();
// We use the workerPublicPath option if provided, else we fallback to the RuntimeGlobal publicPath
const workerImportBaseUrl = dep.options.publicPath
? `"${dep.options.publicPath}"`
: RuntimeGlobals.publicPath;
runtimeRequirements.add(RuntimeGlobals.publicPath);
runtimeRequirements.add(RuntimeGlobals.baseURI);
@ -109,12 +113,9 @@ WorkerDependency.Template = class WorkerDependencyTemplate extends (
source.replace(
dep.range[0],
dep.range[1] - 1,
`/* worker import */ "${
// We use the workerPublicPath option if provided, else we fallback to the RuntimeGlobal publicPath
dep.options.publicPath || RuntimeGlobals.publicPath
}" + ${RuntimeGlobals.getChunkScriptFilename}(${JSON.stringify(
chunk.id
)}), ${RuntimeGlobals.baseURI}`
`/* worker import */ ${workerImportBaseUrl} + ${
RuntimeGlobals.getChunkScriptFilename
}(${JSON.stringify(chunk.id)}), ${RuntimeGlobals.baseURI}`
);
}
};

View File

@ -4688,9 +4688,9 @@ exports[`StatsTestCases should print correct stats for worker-public-path 1`] =
With worker public path (webpack x.x.x) compiled successfully in X ms
No worker public path:
asset main-b6dd2c275025065fa08b.js 3.51 KiB [emitted] [immutable] (name: main)
asset main-66e86aae6a45e26d90e0.js 3.51 KiB [emitted] [immutable] (name: main)
asset 442-579eebb6602aecc20b13.js 219 bytes [emitted] [immutable]
chunk (runtime: main) main-b6dd2c275025065fa08b.js (main) 115 bytes (javascript) 1.75 KiB (runtime) [entry] [rendered]
chunk (runtime: main) main-66e86aae6a45e26d90e0.js (main) 115 bytes (javascript) 1.75 KiB (runtime) [entry] [rendered]
runtime modules 1.75 KiB 5 modules
./index.js 115 bytes [built] [code generated]
chunk (runtime: a4291b531e90a0ccd153) 442-579eebb6602aecc20b13.js 135 bytes [entry] [rendered]

View File

@ -1,6 +1,6 @@
import { Worker } from "worker_threads";
it("should define public path", () => {
it("should define public path", async () => {
const worker = new Worker(new URL("./worker.js", import.meta.url), {
type: "module"
});
@ -10,4 +10,5 @@ it("should define public path", () => {
path = require("path");
var source = fs.readFileSync(path.join(__dirname, "main.js"), "utf-8");
expect(source).toMatch("workerPublicPath2");
await worker.terminate()
});