webpack/lib/RuntimePlugin.js

525 lines
18 KiB
JavaScript
Raw Normal View History

2018-11-17 01:18:44 +08:00
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
const RuntimeGlobals = require("./RuntimeGlobals");
2022-01-13 22:26:56 +08:00
const { getChunkFilenameTemplate } = require("./css/CssModulesPlugin");
const RuntimeRequirementsDependency = require("./dependencies/RuntimeRequirementsDependency");
2019-11-15 00:28:43 +08:00
const JavascriptModulesPlugin = require("./javascript/JavascriptModulesPlugin");
2021-01-29 18:12:11 +08:00
const AsyncModuleRuntimeModule = require("./runtime/AsyncModuleRuntimeModule");
const AutoPublicPathRuntimeModule = require("./runtime/AutoPublicPathRuntimeModule");
const BaseUriRuntimeModule = require("./runtime/BaseUriRuntimeModule");
const CompatGetDefaultExportRuntimeModule = require("./runtime/CompatGetDefaultExportRuntimeModule");
const CompatRuntimeModule = require("./runtime/CompatRuntimeModule");
const CreateFakeNamespaceObjectRuntimeModule = require("./runtime/CreateFakeNamespaceObjectRuntimeModule");
const CreateScriptRuntimeModule = require("./runtime/CreateScriptRuntimeModule");
const CreateScriptUrlRuntimeModule = require("./runtime/CreateScriptUrlRuntimeModule");
const DefinePropertyGettersRuntimeModule = require("./runtime/DefinePropertyGettersRuntimeModule");
const EnsureChunkRuntimeModule = require("./runtime/EnsureChunkRuntimeModule");
2018-11-21 18:32:10 +08:00
const GetChunkFilenameRuntimeModule = require("./runtime/GetChunkFilenameRuntimeModule");
const GetMainFilenameRuntimeModule = require("./runtime/GetMainFilenameRuntimeModule");
2021-09-08 19:09:01 +08:00
const GetTrustedTypesPolicyRuntimeModule = require("./runtime/GetTrustedTypesPolicyRuntimeModule");
2018-12-06 19:11:01 +08:00
const GlobalRuntimeModule = require("./runtime/GlobalRuntimeModule");
2019-12-03 21:27:39 +08:00
const HasOwnPropertyRuntimeModule = require("./runtime/HasOwnPropertyRuntimeModule");
const LoadScriptRuntimeModule = require("./runtime/LoadScriptRuntimeModule");
const MakeDeferredNamespaceObjectRuntime = require("./runtime/MakeDeferredNamespaceObjectRuntime");
2018-11-20 17:22:10 +08:00
const MakeNamespaceObjectRuntimeModule = require("./runtime/MakeNamespaceObjectRuntimeModule");
2022-05-10 02:45:42 +08:00
const NonceRuntimeModule = require("./runtime/NonceRuntimeModule");
const OnChunksLoadedRuntimeModule = require("./runtime/OnChunksLoadedRuntimeModule");
const PublicPathRuntimeModule = require("./runtime/PublicPathRuntimeModule");
const RelativeUrlRuntimeModule = require("./runtime/RelativeUrlRuntimeModule");
const RuntimeIdRuntimeModule = require("./runtime/RuntimeIdRuntimeModule");
const SystemContextRuntimeModule = require("./runtime/SystemContextRuntimeModule");
2020-05-23 22:08:51 +08:00
const ShareRuntimeModule = require("./sharing/ShareRuntimeModule");
const StringXor = require("./util/StringXor");
const memoize = require("./util/memoize");
2024-08-09 01:03:17 +08:00
/** @typedef {import("../declarations/WebpackOptions").LibraryOptions} LibraryOptions */
2024-08-08 02:59:26 +08:00
/** @typedef {import("../declarations/WebpackOptions").OutputNormalized} OutputNormalized */
2018-11-17 01:18:44 +08:00
/** @typedef {import("./Chunk")} Chunk */
/** @typedef {import("./Compiler")} Compiler */
/** @typedef {import("./Module")} Module */
2024-08-08 02:59:26 +08:00
/** @typedef {import("./TemplatedPathPlugin").TemplatePath} TemplatePath */
2018-11-17 01:18:44 +08:00
2024-10-04 22:37:20 +08:00
const getJavascriptModulesPlugin = memoize(() =>
require("./javascript/JavascriptModulesPlugin")
);
const getCssModulesPlugin = memoize(() => require("./css/CssModulesPlugin"));
const GLOBALS_ON_REQUIRE = [
RuntimeGlobals.chunkName,
RuntimeGlobals.runtimeId,
RuntimeGlobals.compatGetDefaultExport,
RuntimeGlobals.createFakeNamespaceObject,
RuntimeGlobals.createScript,
RuntimeGlobals.createScriptUrl,
RuntimeGlobals.getTrustedTypesPolicy,
RuntimeGlobals.definePropertyGetters,
RuntimeGlobals.ensureChunk,
RuntimeGlobals.entryModuleId,
RuntimeGlobals.getFullHash,
RuntimeGlobals.global,
RuntimeGlobals.makeNamespaceObject,
RuntimeGlobals.moduleCache,
RuntimeGlobals.moduleFactories,
RuntimeGlobals.moduleFactoriesAddOnly,
RuntimeGlobals.interceptModuleExecution,
RuntimeGlobals.publicPath,
RuntimeGlobals.baseURI,
RuntimeGlobals.relativeUrl,
2024-02-28 01:29:46 +08:00
// TODO webpack 6 - rename to nonce, because we use it for CSS too
RuntimeGlobals.scriptNonce,
RuntimeGlobals.uncaughtErrorHandler,
2021-01-29 18:12:11 +08:00
RuntimeGlobals.asyncModule,
RuntimeGlobals.wasmInstances,
2020-05-23 22:08:51 +08:00
RuntimeGlobals.instantiateWasm,
RuntimeGlobals.shareScopeMap,
RuntimeGlobals.initializeSharing,
RuntimeGlobals.loadScript,
RuntimeGlobals.systemContext,
RuntimeGlobals.onChunksLoaded,
RuntimeGlobals.makeDeferredNamespaceObject
];
const MODULE_DEPENDENCIES = {
[RuntimeGlobals.moduleLoaded]: [RuntimeGlobals.module],
[RuntimeGlobals.moduleId]: [RuntimeGlobals.module]
};
const TREE_DEPENDENCIES = {
2019-12-03 21:27:39 +08:00
[RuntimeGlobals.definePropertyGetters]: [RuntimeGlobals.hasOwnProperty],
[RuntimeGlobals.compatGetDefaultExport]: [
RuntimeGlobals.definePropertyGetters
],
[RuntimeGlobals.createFakeNamespaceObject]: [
RuntimeGlobals.definePropertyGetters,
RuntimeGlobals.makeNamespaceObject,
RuntimeGlobals.require
2020-05-23 22:08:51 +08:00
],
[RuntimeGlobals.makeDeferredNamespaceObject]: [
RuntimeGlobals.definePropertyGetters,
RuntimeGlobals.makeNamespaceObject,
RuntimeGlobals.createFakeNamespaceObject,
RuntimeGlobals.hasOwnProperty,
RuntimeGlobals.require
],
2020-05-23 22:08:51 +08:00
[RuntimeGlobals.initializeSharing]: [RuntimeGlobals.shareScopeMap],
[RuntimeGlobals.shareScopeMap]: [RuntimeGlobals.hasOwnProperty]
};
2018-11-17 01:18:44 +08:00
2025-04-23 20:03:37 +08:00
const PLUGIN_NAME = "RuntimePlugin";
2018-11-17 01:18:44 +08:00
class RuntimePlugin {
/**
* @param {Compiler} compiler the Compiler
* @returns {void}
*/
apply(compiler) {
2025-04-23 20:03:37 +08:00
compiler.hooks.compilation.tap(PLUGIN_NAME, compilation => {
2022-03-08 16:10:05 +08:00
const globalChunkLoading = compilation.outputOptions.chunkLoading;
2023-05-25 03:37:58 +08:00
/**
* @param {Chunk} chunk chunk
* @returns {boolean} true, when chunk loading is disabled for the chunk
*/
2022-03-08 16:10:05 +08:00
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()
);
for (const req of GLOBALS_ON_REQUIRE) {
2018-11-17 01:18:44 +08:00
compilation.hooks.runtimeRequirementInModule
.for(req)
2025-04-23 20:03:37 +08:00
.tap(PLUGIN_NAME, (module, set) => {
set.add(RuntimeGlobals.requireScope);
});
compilation.hooks.runtimeRequirementInTree
.for(req)
2025-04-23 20:03:37 +08:00
.tap(PLUGIN_NAME, (module, set) => {
set.add(RuntimeGlobals.requireScope);
});
}
for (const req of Object.keys(TREE_DEPENDENCIES)) {
2023-06-17 01:13:03 +08:00
const deps =
TREE_DEPENDENCIES[/** @type {keyof TREE_DEPENDENCIES} */ (req)];
compilation.hooks.runtimeRequirementInTree
.for(req)
2025-04-23 20:03:37 +08:00
.tap(PLUGIN_NAME, (chunk, set) => {
for (const dep of deps) set.add(dep);
});
}
for (const req of Object.keys(MODULE_DEPENDENCIES)) {
2023-06-17 01:13:03 +08:00
const deps =
MODULE_DEPENDENCIES[/** @type {keyof MODULE_DEPENDENCIES} */ (req)];
compilation.hooks.runtimeRequirementInModule
.for(req)
2025-04-23 20:03:37 +08:00
.tap(PLUGIN_NAME, (chunk, set) => {
for (const dep of deps) set.add(dep);
2018-11-17 01:18:44 +08:00
});
}
compilation.hooks.runtimeRequirementInTree
.for(RuntimeGlobals.definePropertyGetters)
2025-04-23 20:03:37 +08:00
.tap(PLUGIN_NAME, chunk => {
compilation.addRuntimeModule(
chunk,
new DefinePropertyGettersRuntimeModule()
);
return true;
});
2018-11-20 17:22:10 +08:00
compilation.hooks.runtimeRequirementInTree
.for(RuntimeGlobals.makeNamespaceObject)
2025-04-23 20:03:37 +08:00
.tap(PLUGIN_NAME, chunk => {
2018-11-20 17:22:10 +08:00
compilation.addRuntimeModule(
chunk,
new MakeNamespaceObjectRuntimeModule()
);
return true;
});
compilation.hooks.runtimeRequirementInTree
.for(RuntimeGlobals.createFakeNamespaceObject)
2025-04-23 20:03:37 +08:00
.tap(PLUGIN_NAME, chunk => {
compilation.addRuntimeModule(
chunk,
new CreateFakeNamespaceObjectRuntimeModule()
);
return true;
});
compilation.hooks.runtimeRequirementInTree
.for(RuntimeGlobals.makeDeferredNamespaceObject)
.tap("RuntimePlugin", (chunk, runtimeRequirement) => {
compilation.addRuntimeModule(
chunk,
new MakeDeferredNamespaceObjectRuntime(
runtimeRequirement.has(RuntimeGlobals.asyncModule)
)
);
return true;
});
2019-12-03 21:27:39 +08:00
compilation.hooks.runtimeRequirementInTree
.for(RuntimeGlobals.hasOwnProperty)
2025-04-23 20:03:37 +08:00
.tap(PLUGIN_NAME, chunk => {
2019-12-03 21:27:39 +08:00
compilation.addRuntimeModule(
chunk,
new HasOwnPropertyRuntimeModule()
);
return true;
});
compilation.hooks.runtimeRequirementInTree
.for(RuntimeGlobals.compatGetDefaultExport)
2025-04-23 20:03:37 +08:00
.tap(PLUGIN_NAME, chunk => {
compilation.addRuntimeModule(
chunk,
new CompatGetDefaultExportRuntimeModule()
);
return true;
});
compilation.hooks.runtimeRequirementInTree
.for(RuntimeGlobals.runtimeId)
2025-04-23 20:03:37 +08:00
.tap(PLUGIN_NAME, chunk => {
compilation.addRuntimeModule(chunk, new RuntimeIdRuntimeModule());
return true;
});
compilation.hooks.runtimeRequirementInTree
.for(RuntimeGlobals.publicPath)
2025-04-23 20:03:37 +08:00
.tap(PLUGIN_NAME, (chunk, set) => {
2020-09-17 04:07:06 +08:00
const { outputOptions } = compilation;
const { publicPath: globalPublicPath, scriptType } = outputOptions;
const entryOptions = chunk.getEntryOptions();
const publicPath =
2021-04-15 02:21:17 +08:00
entryOptions && entryOptions.publicPath !== undefined
? entryOptions.publicPath
: globalPublicPath;
if (publicPath === "auto") {
const module = new AutoPublicPathRuntimeModule();
if (scriptType !== "module") set.add(RuntimeGlobals.global);
compilation.addRuntimeModule(chunk, module);
} else {
const module = new PublicPathRuntimeModule(publicPath);
if (
typeof publicPath !== "string" ||
/\[(full)?hash\]/.test(publicPath)
) {
module.fullHash = true;
}
compilation.addRuntimeModule(chunk, module);
}
return true;
});
2018-12-06 19:11:01 +08:00
compilation.hooks.runtimeRequirementInTree
.for(RuntimeGlobals.global)
2025-04-23 20:03:37 +08:00
.tap(PLUGIN_NAME, chunk => {
2018-12-06 19:11:01 +08:00
compilation.addRuntimeModule(chunk, new GlobalRuntimeModule());
return true;
});
2021-01-29 18:12:11 +08:00
compilation.hooks.runtimeRequirementInTree
.for(RuntimeGlobals.asyncModule)
2025-04-23 20:03:37 +08:00
.tap(PLUGIN_NAME, chunk => {
const experiments = compilation.options.experiments;
compilation.addRuntimeModule(
chunk,
new AsyncModuleRuntimeModule(experiments.deferImport)
);
2021-01-29 18:12:11 +08:00
return true;
});
compilation.hooks.runtimeRequirementInTree
.for(RuntimeGlobals.systemContext)
2025-04-23 20:03:37 +08:00
.tap(PLUGIN_NAME, chunk => {
const entryOptions = chunk.getEntryOptions();
const libraryType =
entryOptions && entryOptions.library !== undefined
? entryOptions.library.type
2024-08-09 01:03:17 +08:00
: /** @type {LibraryOptions} */
(compilation.outputOptions.library).type;
if (libraryType === "system") {
compilation.addRuntimeModule(
chunk,
new SystemContextRuntimeModule()
);
}
return true;
});
2018-11-21 18:32:10 +08:00
compilation.hooks.runtimeRequirementInTree
.for(RuntimeGlobals.getChunkScriptFilename)
2025-04-23 20:03:37 +08:00
.tap(PLUGIN_NAME, (chunk, set, { chunkGraph }) => {
2018-12-26 03:14:58 +08:00
if (
2020-09-25 17:04:14 +08:00
typeof compilation.outputOptions.chunkFilename === "string" &&
2018-12-26 03:14:58 +08:00
/\[(full)?hash(:\d+)?\]/.test(
compilation.outputOptions.chunkFilename
)
2020-09-25 17:04:14 +08:00
) {
2018-11-21 18:32:10 +08:00
set.add(RuntimeGlobals.getFullHash);
2020-09-25 17:04:14 +08:00
}
2018-11-21 18:32:10 +08:00
compilation.addRuntimeModule(
chunk,
new GetChunkFilenameRuntimeModule(
"javascript",
"javascript",
2018-11-21 18:32:10 +08:00
RuntimeGlobals.getChunkScriptFilename,
chunk =>
2024-10-04 22:37:20 +08:00
getJavascriptModulesPlugin().chunkHasJs(chunk, chunkGraph) &&
/** @type {TemplatePath} */ (
chunk.filenameTemplate ||
(chunk.canBeInitial()
? compilation.outputOptions.filename
: compilation.outputOptions.chunkFilename)
2024-08-08 02:59:26 +08:00
),
set.has(RuntimeGlobals.hmrDownloadUpdateHandlers)
2018-11-21 18:32:10 +08:00
)
);
return true;
});
2021-11-30 19:55:51 +08:00
compilation.hooks.runtimeRequirementInTree
.for(RuntimeGlobals.getChunkCssFilename)
2025-04-23 20:03:37 +08:00
.tap(PLUGIN_NAME, (chunk, set, { chunkGraph }) => {
2021-11-30 19:55:51 +08:00
if (
2021-12-17 19:18:01 +08:00
typeof compilation.outputOptions.cssChunkFilename === "string" &&
/\[(full)?hash(:\d+)?\]/.test(
compilation.outputOptions.cssChunkFilename
)
2021-11-30 19:55:51 +08:00
) {
set.add(RuntimeGlobals.getFullHash);
}
compilation.addRuntimeModule(
chunk,
new GetChunkFilenameRuntimeModule(
"css",
"css",
RuntimeGlobals.getChunkCssFilename,
chunk =>
getCssModulesPlugin().chunkHasCss(chunk, chunkGraph) &&
2024-08-09 01:03:17 +08:00
getChunkFilenameTemplate(chunk, compilation.outputOptions),
2022-01-13 22:26:56 +08:00
set.has(RuntimeGlobals.hmrDownloadUpdateHandlers)
2021-11-30 19:55:51 +08:00
)
);
return true;
});
compilation.hooks.runtimeRequirementInTree
.for(RuntimeGlobals.getChunkUpdateScriptFilename)
2025-04-23 20:03:37 +08:00
.tap(PLUGIN_NAME, (chunk, set) => {
if (
2018-12-26 03:14:58 +08:00
/\[(full)?hash(:\d+)?\]/.test(
2024-08-08 02:59:26 +08:00
/** @type {NonNullable<OutputNormalized["hotUpdateChunkFilename"]>} */
(compilation.outputOptions.hotUpdateChunkFilename)
)
) {
set.add(RuntimeGlobals.getFullHash);
}
compilation.addRuntimeModule(
chunk,
new GetChunkFilenameRuntimeModule(
"javascript",
"javascript update",
RuntimeGlobals.getChunkUpdateScriptFilename,
2025-07-08 22:46:17 +08:00
_chunk =>
2024-08-08 02:59:26 +08:00
/** @type {NonNullable<OutputNormalized["hotUpdateChunkFilename"]>} */
(compilation.outputOptions.hotUpdateChunkFilename),
true
)
);
return true;
});
compilation.hooks.runtimeRequirementInTree
.for(RuntimeGlobals.getUpdateManifestFilename)
2025-04-23 20:03:37 +08:00
.tap(PLUGIN_NAME, (chunk, set) => {
if (
2018-12-26 03:14:58 +08:00
/\[(full)?hash(:\d+)?\]/.test(
2024-08-08 02:59:26 +08:00
/** @type {NonNullable<OutputNormalized["hotUpdateMainFilename"]>} */
(compilation.outputOptions.hotUpdateMainFilename)
)
2018-12-18 05:05:08 +08:00
) {
set.add(RuntimeGlobals.getFullHash);
2018-12-18 05:05:08 +08:00
}
compilation.addRuntimeModule(
chunk,
new GetMainFilenameRuntimeModule(
"update manifest",
RuntimeGlobals.getUpdateManifestFilename,
2024-08-08 02:59:26 +08:00
/** @type {NonNullable<OutputNormalized["hotUpdateMainFilename"]>} */
(compilation.outputOptions.hotUpdateMainFilename)
)
);
return true;
});
compilation.hooks.runtimeRequirementInTree
.for(RuntimeGlobals.ensureChunk)
2025-04-23 20:03:37 +08:00
.tap(PLUGIN_NAME, (chunk, set) => {
const hasAsyncChunks = chunk.hasAsyncChunks();
if (hasAsyncChunks) {
set.add(RuntimeGlobals.ensureChunkHandlers);
}
compilation.addRuntimeModule(
chunk,
new EnsureChunkRuntimeModule(set)
);
return true;
});
compilation.hooks.runtimeRequirementInTree
.for(RuntimeGlobals.ensureChunkIncludeEntries)
2025-04-23 20:03:37 +08:00
.tap(PLUGIN_NAME, (chunk, set) => {
set.add(RuntimeGlobals.ensureChunkHandlers);
});
2020-05-23 22:08:51 +08:00
compilation.hooks.runtimeRequirementInTree
.for(RuntimeGlobals.shareScopeMap)
2025-04-23 20:03:37 +08:00
.tap(PLUGIN_NAME, (chunk, set) => {
2020-05-23 22:08:51 +08:00
compilation.addRuntimeModule(chunk, new ShareRuntimeModule());
return true;
});
compilation.hooks.runtimeRequirementInTree
.for(RuntimeGlobals.loadScript)
2025-04-23 20:03:37 +08:00
.tap(PLUGIN_NAME, (chunk, set) => {
2024-07-31 11:11:11 +08:00
const withCreateScriptUrl = Boolean(
compilation.outputOptions.trustedTypes
);
2021-05-10 15:33:04 +08:00
if (withCreateScriptUrl) {
set.add(RuntimeGlobals.createScriptUrl);
}
const withFetchPriority = set.has(RuntimeGlobals.hasFetchPriority);
2021-05-10 15:33:04 +08:00
compilation.addRuntimeModule(
chunk,
new LoadScriptRuntimeModule(withCreateScriptUrl, withFetchPriority)
2021-05-10 15:33:04 +08:00
);
return true;
});
compilation.hooks.runtimeRequirementInTree
.for(RuntimeGlobals.createScript)
2025-04-23 20:03:37 +08:00
.tap(PLUGIN_NAME, (chunk, set) => {
if (compilation.outputOptions.trustedTypes) {
set.add(RuntimeGlobals.getTrustedTypesPolicy);
}
compilation.addRuntimeModule(chunk, new CreateScriptRuntimeModule());
return true;
});
compilation.hooks.runtimeRequirementInTree
.for(RuntimeGlobals.createScriptUrl)
2025-04-23 20:03:37 +08:00
.tap(PLUGIN_NAME, (chunk, set) => {
if (compilation.outputOptions.trustedTypes) {
set.add(RuntimeGlobals.getTrustedTypesPolicy);
}
compilation.addRuntimeModule(
chunk,
new CreateScriptUrlRuntimeModule()
);
return true;
});
compilation.hooks.runtimeRequirementInTree
.for(RuntimeGlobals.getTrustedTypesPolicy)
2025-04-23 20:03:37 +08:00
.tap(PLUGIN_NAME, (chunk, set) => {
compilation.addRuntimeModule(
chunk,
new GetTrustedTypesPolicyRuntimeModule(set)
);
return true;
});
compilation.hooks.runtimeRequirementInTree
.for(RuntimeGlobals.relativeUrl)
2025-07-08 22:46:17 +08:00
.tap(PLUGIN_NAME, (chunk, _set) => {
compilation.addRuntimeModule(chunk, new RelativeUrlRuntimeModule());
return true;
});
compilation.hooks.runtimeRequirementInTree
.for(RuntimeGlobals.onChunksLoaded)
2025-07-08 22:46:17 +08:00
.tap(PLUGIN_NAME, (chunk, _set) => {
compilation.addRuntimeModule(
chunk,
new OnChunksLoadedRuntimeModule()
);
return true;
});
compilation.hooks.runtimeRequirementInTree
.for(RuntimeGlobals.baseURI)
2025-04-23 20:03:37 +08:00
.tap(PLUGIN_NAME, chunk => {
2022-03-08 16:10:05 +08:00
if (isChunkLoadingDisabledForChunk(chunk)) {
compilation.addRuntimeModule(chunk, new BaseUriRuntimeModule());
return true;
}
});
2022-05-10 02:45:42 +08:00
compilation.hooks.runtimeRequirementInTree
.for(RuntimeGlobals.scriptNonce)
2025-04-23 20:03:37 +08:00
.tap(PLUGIN_NAME, chunk => {
2022-05-10 02:45:42 +08:00
compilation.addRuntimeModule(chunk, new NonceRuntimeModule());
return true;
});
// TODO webpack 6: remove CompatRuntimeModule
compilation.hooks.additionalTreeRuntimeRequirements.tap(
2025-04-23 20:03:37 +08:00
PLUGIN_NAME,
2025-07-08 22:46:17 +08:00
(chunk, _set) => {
const { mainTemplate } = compilation;
if (
mainTemplate.hooks.bootstrap.isUsed() ||
mainTemplate.hooks.localVars.isUsed() ||
mainTemplate.hooks.requireEnsure.isUsed() ||
mainTemplate.hooks.requireExtensions.isUsed()
) {
compilation.addRuntimeModule(chunk, new CompatRuntimeModule());
}
}
);
2019-11-15 00:28:43 +08:00
JavascriptModulesPlugin.getCompilationHooks(compilation).chunkHash.tap(
2025-04-23 20:03:37 +08:00
PLUGIN_NAME,
2019-11-15 00:28:43 +08:00
(chunk, hash, { chunkGraph }) => {
const xor = new StringXor();
for (const m of chunkGraph.getChunkRuntimeModulesIterable(chunk)) {
xor.add(chunkGraph.getModuleHash(m, chunk.runtime));
2019-11-15 00:28:43 +08:00
}
xor.updateHash(hash);
2019-11-15 00:28:43 +08:00
}
);
2018-11-17 01:18:44 +08:00
});
}
}
2018-11-17 01:18:44 +08:00
module.exports = RuntimePlugin;