use global chunkLoading option

This commit is contained in:
Ivan Kopeykin 2022-03-08 11:10:05 +03:00
parent 26f3a1d21c
commit bbbe300e3a
1 changed files with 10 additions and 2 deletions

View File

@ -97,6 +97,15 @@ class RuntimePlugin {
*/
apply(compiler) {
compiler.hooks.compilation.tap("RuntimePlugin", compilation => {
const globalChunkLoading = compilation.outputOptions.chunkLoading;
const isChunkLoadingDisabledForChunk = chunk => {
const options = chunk.getEntryOptions();
const chunkLoading =
options && options.chunkLoading !== undefined
? options.chunkLoading
: globalChunkLoading;
return chunkLoading === false;
};
compilation.dependencyTemplates.set(
RuntimeRequirementsDependency,
new RuntimeRequirementsDependency.Template()
@ -417,8 +426,7 @@ class RuntimePlugin {
compilation.hooks.runtimeRequirementInTree
.for(RuntimeGlobals.baseURI)
.tap("RuntimePlugin", chunk => {
const { chunkLoading } = chunk.getEntryOptions();
if (chunkLoading === false) {
if (isChunkLoadingDisabledForChunk(chunk)) {
compilation.addRuntimeModule(chunk, new BaseUriRuntimeModule());
return true;
}