Skip to content

Commit

Permalink
Merge pull request #13143 from webpack/bugfix/falsy-entry-options
Browse files Browse the repository at this point in the history
handle falsy entry options correctly
  • Loading branch information
sokra authored Apr 14, 2021
2 parents 7a7d3be + 2df8267 commit 45fac7d
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lib/Compilation.js
Original file line number Diff line number Diff line change
Expand Up @@ -4035,7 +4035,7 @@ This prevents using hashes of each other and should be avoided.`);

const entrypoint = new Entrypoint({
runtime,
chunkLoading: "none",
chunkLoading: false,
...options.entryOptions
});
chunkGraph.connectChunkAndEntryModule(chunk, module, entrypoint);
Expand Down
4 changes: 3 additions & 1 deletion lib/RuntimePlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,9 @@ class RuntimePlugin {
const { publicPath: globalPublicPath, scriptType } = outputOptions;
const entryOptions = chunk.getEntryOptions();
const publicPath =
(entryOptions && entryOptions.publicPath) || globalPublicPath;
entryOptions && entryOptions.publicPath !== undefined
? entryOptions.publicPath
: globalPublicPath;

if (publicPath === "auto") {
const module = new AutoPublicPathRuntimeModule();
Expand Down
4 changes: 3 additions & 1 deletion lib/node/CommonJsChunkLoadingPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ class CommonJsChunkLoadingPlugin {
const isEnabledForChunk = chunk => {
const options = chunk.getEntryOptions();
const chunkLoading =
(options && options.chunkLoading) || globalChunkLoading;
options && options.chunkLoading !== undefined
? options.chunkLoading
: globalChunkLoading;
return chunkLoading === chunkLoadingValue;
};
const onceForChunkSet = new WeakSet();
Expand Down
4 changes: 3 additions & 1 deletion lib/node/ReadFileCompileAsyncWasmPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ class ReadFileCompileAsyncWasmPlugin {
const isEnabledForChunk = chunk => {
const options = chunk.getEntryOptions();
const wasmLoading =
(options && options.wasmLoading) || globalWasmLoading;
options && options.wasmLoading !== undefined
? options.wasmLoading
: globalWasmLoading;
return wasmLoading === "async-node";
};
const generateLoadBinaryCode = path =>
Expand Down
4 changes: 3 additions & 1 deletion lib/node/ReadFileCompileWasmPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ class ReadFileCompileWasmPlugin {
const isEnabledForChunk = chunk => {
const options = chunk.getEntryOptions();
const wasmLoading =
(options && options.wasmLoading) || globalWasmLoading;
options && options.wasmLoading !== undefined
? options.wasmLoading
: globalWasmLoading;
return wasmLoading === "async-node";
};
const generateLoadBinaryCode = path =>
Expand Down
4 changes: 3 additions & 1 deletion lib/runtime/StartupChunkDependenciesPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ class StartupChunkDependenciesPlugin {
const isEnabledForChunk = chunk => {
const options = chunk.getEntryOptions();
const chunkLoading =
(options && options.chunkLoading) || globalChunkLoading;
options && options.chunkLoading !== undefined
? options.chunkLoading
: globalChunkLoading;
return chunkLoading === this.chunkLoading;
};
compilation.hooks.additionalTreeRuntimeRequirements.tap(
Expand Down
4 changes: 3 additions & 1 deletion lib/web/FetchCompileAsyncWasmPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ class FetchCompileAsyncWasmPlugin {
const isEnabledForChunk = chunk => {
const options = chunk.getEntryOptions();
const wasmLoading =
(options && options.wasmLoading) || globalWasmLoading;
options && options.wasmLoading !== undefined
? options.wasmLoading
: globalWasmLoading;
return wasmLoading === "fetch";
};
const generateLoadBinaryCode = path =>
Expand Down
4 changes: 3 additions & 1 deletion lib/web/FetchCompileWasmPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ class FetchCompileWasmPlugin {
const isEnabledForChunk = chunk => {
const options = chunk.getEntryOptions();
const wasmLoading =
(options && options.wasmLoading) || globalWasmLoading;
options && options.wasmLoading !== undefined
? options.wasmLoading
: globalWasmLoading;
return wasmLoading === "fetch";
};
const generateLoadBinaryCode = path =>
Expand Down
4 changes: 3 additions & 1 deletion lib/web/JsonpChunkLoadingPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ class JsonpChunkLoadingPlugin {
const isEnabledForChunk = chunk => {
const options = chunk.getEntryOptions();
const chunkLoading =
(options && options.chunkLoading) || globalChunkLoading;
options && options.chunkLoading !== undefined
? options.chunkLoading
: globalChunkLoading;
return chunkLoading === "jsonp";
};
const onceForChunkSet = new WeakSet();
Expand Down
4 changes: 3 additions & 1 deletion lib/webworker/ImportScriptsChunkLoadingPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ class ImportScriptsChunkLoadingPlugin {
const isEnabledForChunk = chunk => {
const options = chunk.getEntryOptions();
const chunkLoading =
(options && options.chunkLoading) || globalChunkLoading;
options && options.chunkLoading !== undefined
? options.chunkLoading
: globalChunkLoading;
return chunkLoading === "import-scripts";
};
const onceForChunkSet = new WeakSet();
Expand Down

0 comments on commit 45fac7d

Please sign in to comment.