mirror of https://github.com/webpack/webpack.git
fix: avoid extra runtime for get javascript/css chunk filename
This commit is contained in:
parent
fcd41d21be
commit
9ad073028e
|
@ -34,6 +34,12 @@ const RuntimeIdRuntimeModule = require("./runtime/RuntimeIdRuntimeModule");
|
|||
const SystemContextRuntimeModule = require("./runtime/SystemContextRuntimeModule");
|
||||
const ShareRuntimeModule = require("./sharing/ShareRuntimeModule");
|
||||
const StringXor = require("./util/StringXor");
|
||||
const memoize = require("./util/memoize");
|
||||
|
||||
const getJavascriptModulesPlugin = memoize(() =>
|
||||
require("./javascript/JavascriptModulesPlugin")
|
||||
);
|
||||
const getCssModulesPlugin = memoize(() => require("./css/CssModulesPlugin"));
|
||||
|
||||
/** @typedef {import("../declarations/WebpackOptions").LibraryOptions} LibraryOptions */
|
||||
/** @typedef {import("../declarations/WebpackOptions").OutputNormalized} OutputNormalized */
|
||||
|
@ -261,7 +267,7 @@ class RuntimePlugin {
|
|||
});
|
||||
compilation.hooks.runtimeRequirementInTree
|
||||
.for(RuntimeGlobals.getChunkScriptFilename)
|
||||
.tap("RuntimePlugin", (chunk, set) => {
|
||||
.tap("RuntimePlugin", (chunk, set, { chunkGraph }) => {
|
||||
if (
|
||||
typeof compilation.outputOptions.chunkFilename === "string" &&
|
||||
/\[(full)?hash(:\d+)?\]/.test(
|
||||
|
@ -279,10 +285,11 @@ class RuntimePlugin {
|
|||
chunk =>
|
||||
/** @type {TemplatePath} */
|
||||
(
|
||||
chunk.filenameTemplate ||
|
||||
getJavascriptModulesPlugin().chunkHasJs(chunk, chunkGraph) &&
|
||||
(chunk.filenameTemplate ||
|
||||
(chunk.canBeInitial()
|
||||
? compilation.outputOptions.filename
|
||||
: compilation.outputOptions.chunkFilename)
|
||||
: compilation.outputOptions.chunkFilename))
|
||||
),
|
||||
false
|
||||
)
|
||||
|
@ -291,7 +298,7 @@ class RuntimePlugin {
|
|||
});
|
||||
compilation.hooks.runtimeRequirementInTree
|
||||
.for(RuntimeGlobals.getChunkCssFilename)
|
||||
.tap("RuntimePlugin", (chunk, set) => {
|
||||
.tap("RuntimePlugin", (chunk, set, { chunkGraph }) => {
|
||||
if (
|
||||
typeof compilation.outputOptions.cssChunkFilename === "string" &&
|
||||
/\[(full)?hash(:\d+)?\]/.test(
|
||||
|
@ -307,6 +314,7 @@ class RuntimePlugin {
|
|||
"css",
|
||||
RuntimeGlobals.getChunkCssFilename,
|
||||
chunk =>
|
||||
getCssModulesPlugin().chunkHasCss(chunk, chunkGraph) &&
|
||||
getChunkFilenameTemplate(chunk, compilation.outputOptions),
|
||||
set.has(RuntimeGlobals.hmrDownloadUpdateHandlers)
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue