webpack 5.107.0 → 5.107.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/BannerPlugin.js +3 -4
- package/lib/Chunk.js +21 -25
- package/lib/ChunkGroup.js +57 -15
- package/lib/Compilation.js +33 -11
- package/lib/Compiler.js +27 -3
- package/lib/ContextModuleFactory.js +45 -38
- package/lib/EvalSourceMapDevToolPlugin.js +0 -1
- package/lib/ExportsInfo.js +30 -34
- package/lib/ExternalModule.js +15 -11
- package/lib/ExternalModuleFactoryPlugin.js +2 -1
- package/lib/Module.js +1 -1
- package/lib/ModuleNotFoundError.js +10 -0
- package/lib/ModuleSourceTypeConstants.js +24 -22
- package/lib/MultiCompiler.js +14 -0
- package/lib/NormalModule.js +531 -53
- package/lib/NormalModuleFactory.js +38 -26
- package/lib/ProgressPlugin.js +1 -1
- package/lib/RuntimePlugin.js +1 -1
- package/lib/SourceMapDevToolPlugin.js +335 -57
- package/lib/Template.js +1 -1
- package/lib/TemplatedPathPlugin.js +22 -4
- package/lib/asset/AssetBytesGenerator.js +6 -6
- package/lib/asset/AssetGenerator.js +14 -14
- package/lib/asset/AssetModulesPlugin.js +3 -7
- package/lib/asset/AssetSourceGenerator.js +6 -6
- package/lib/buildChunkGraph.js +24 -2
- package/lib/cache/getLazyHashedEtag.js +9 -2
- package/lib/css/CssModulesPlugin.js +2 -2
- package/lib/dependencies/CommonJsImportsParserPlugin.js +108 -1
- package/lib/dependencies/CssUrlDependency.js +3 -2
- package/lib/dependencies/HarmonyDetectionParserPlugin.js +21 -1
- package/lib/dependencies/HarmonyExportInitFragment.js +8 -9
- package/lib/dependencies/HtmlInlineScriptDependency.js +3 -14
- package/lib/dependencies/HtmlInlineStyleDependency.js +17 -0
- package/lib/dependencies/HtmlScriptSrcDependency.js +265 -65
- package/lib/dependencies/HtmlSourceDependency.js +21 -2
- package/lib/dependencies/WorkerPlugin.js +18 -4
- package/lib/hmr/LazyCompilationPlugin.js +104 -0
- package/lib/html/HtmlGenerator.js +81 -33
- package/lib/html/HtmlModulesPlugin.js +87 -28
- package/lib/html/walkHtmlTokens.js +641 -125
- package/lib/index.js +2 -0
- package/lib/javascript/JavascriptModulesPlugin.js +2 -2
- package/lib/javascript/JavascriptParser.js +1 -1
- package/lib/library/ModuleLibraryPlugin.js +30 -24
- package/lib/node/NodeWatchFileSystem.js +37 -22
- package/lib/optimize/ConcatenatedModule.js +3 -2
- package/lib/optimize/SideEffectsFlagPlugin.js +1 -2
- package/lib/optimize/SplitChunksPlugin.js +4 -4
- package/lib/runtime/AutoPublicPathRuntimeModule.js +3 -3
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +5 -5
- package/lib/sharing/ConsumeSharedPlugin.js +2 -8
- package/lib/sharing/ProvideSharedPlugin.js +4 -4
- package/lib/util/fs.js +6 -1
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +1 -2
- package/package.json +5 -5
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +11 -9
- package/schemas/plugins/container/ContainerReferencePlugin.check.js +1 -1
- package/schemas/plugins/container/ContainerReferencePlugin.json +1 -0
- package/schemas/plugins/container/ExternalsType.check.js +1 -1
- package/schemas/plugins/container/ModuleFederationPlugin.check.js +1 -1
- package/schemas/plugins/container/ModuleFederationPlugin.json +1 -0
- package/types.d.ts +472 -149
package/lib/index.js
CHANGED
|
@@ -41,6 +41,8 @@ const memoize = require("./util/memoize");
|
|
|
41
41
|
/** @typedef {import("./Compilation").AssetInfo} AssetInfo */
|
|
42
42
|
/** @typedef {import("./Compilation").EntryOptions} EntryOptions */
|
|
43
43
|
/** @typedef {import("./Compilation").PathData} PathData */
|
|
44
|
+
/** @typedef {import("./Compilation").PathDataChunk} PathDataChunk */
|
|
45
|
+
/** @typedef {import("./Compilation").PathDataModule} PathDataModule */
|
|
44
46
|
/** @typedef {import("./CodeGenerationResults")} CodeGenerationResults */
|
|
45
47
|
/** @typedef {import("./Entrypoint")} Entrypoint */
|
|
46
48
|
/** @typedef {import("./ExternalModuleFactoryPlugin").ExternalItemFunctionCallback} ExternalItemFunctionCallback */
|
|
@@ -83,7 +83,7 @@ const JavascriptParser = require("./JavascriptParser");
|
|
|
83
83
|
/** @typedef {import("../Module").CodeGenerationResultData} CodeGenerationResultData */
|
|
84
84
|
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
|
85
85
|
/** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
|
|
86
|
-
/** @typedef {import("../
|
|
86
|
+
/** @typedef {import("../Chunk").ChunkFilenameTemplate} ChunkFilenameTemplate */
|
|
87
87
|
/** @typedef {import("../errors/WebpackError")} WebpackError */
|
|
88
88
|
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
|
89
89
|
/** @typedef {import("../util/Hash")} Hash */
|
|
@@ -732,7 +732,7 @@ class JavascriptModulesPlugin {
|
|
|
732
732
|
* Gets chunk filename template.
|
|
733
733
|
* @param {Chunk} chunk chunk
|
|
734
734
|
* @param {OutputOptions} outputOptions output options
|
|
735
|
-
* @returns {
|
|
735
|
+
* @returns {ChunkFilenameTemplate} used filename template
|
|
736
736
|
*/
|
|
737
737
|
static getChunkFilenameTemplate(chunk, outputOptions) {
|
|
738
738
|
if (chunk.filenameTemplate) {
|
|
@@ -127,7 +127,7 @@ const BasicEvaluatedExpression = require("./BasicEvaluatedExpression");
|
|
|
127
127
|
|
|
128
128
|
/** @typedef {Set<DestructuringAssignmentProperty>} DestructuringAssignmentProperties */
|
|
129
129
|
|
|
130
|
-
// TODO remove cast when @types/estree has been updated to import
|
|
130
|
+
// TODO remove cast when @types/estree has been updated to import phases
|
|
131
131
|
/** @typedef {import("estree").ImportExpression & { phase?: "defer" | "source" }} ImportExpression */
|
|
132
132
|
|
|
133
133
|
/** @type {string[]} */
|
|
@@ -111,24 +111,15 @@ class ModuleLibraryPlugin extends AbstractLibraryPlugin {
|
|
|
111
111
|
|
|
112
112
|
// `ModuleLibraryPlugin` stashes the on-demand exports source via
|
|
113
113
|
// `onDemandExportsGeneration` and only re-emits it when the
|
|
114
|
-
// module is wrapped in an IIFE/factory. When
|
|
115
|
-
//
|
|
114
|
+
// module is wrapped in an IIFE/factory. When the entry is
|
|
115
|
+
// inlined directly, the stashed source — and the
|
|
116
116
|
// `definePropertyGetters` / `requireScope` runtime helpers it
|
|
117
117
|
// pulled in — never make it into the output. Drop those helpers
|
|
118
|
-
// from the chunk's set
|
|
119
|
-
// clean.
|
|
118
|
+
// from the chunk's set so the bundle stays clean.
|
|
120
119
|
compilation.hooks.additionalChunkRuntimeRequirements.tap(
|
|
121
120
|
PLUGIN_NAME,
|
|
122
121
|
(chunk, set, { chunkGraph, codeGenerationResults }) => {
|
|
123
122
|
if (!set.has(RuntimeGlobals.definePropertyGetters)) return;
|
|
124
|
-
|
|
125
|
-
// Only handle the simple "single concatenated entry"
|
|
126
|
-
// shape. Anything else (additional modules, multiple
|
|
127
|
-
// entries, sibling runtime chunks, or chunk-level
|
|
128
|
-
// requirements that disable inline startup) forces the
|
|
129
|
-
// module through factory/IIFE rendering, which re-emits
|
|
130
|
-
// the source.
|
|
131
|
-
if (chunkGraph.getNumberOfChunkModules(chunk) !== 1) return;
|
|
132
123
|
if (chunkGraph.getNumberOfEntryModules(chunk) !== 1) return;
|
|
133
124
|
if (chunkGraph.hasChunkEntryDependentChunks(chunk)) return;
|
|
134
125
|
if (
|
|
@@ -140,8 +131,6 @@ class ModuleLibraryPlugin extends AbstractLibraryPlugin {
|
|
|
140
131
|
) {
|
|
141
132
|
return;
|
|
142
133
|
}
|
|
143
|
-
// Anyone tapping `inlineInRuntimeBailout` may force factory
|
|
144
|
-
// rendering at render time, so conservatively bail out.
|
|
145
134
|
if (javascriptHooks.inlineInRuntimeBailout.isUsed()) return;
|
|
146
135
|
|
|
147
136
|
const [module] = chunkGraph.getChunkEntryModulesIterable(chunk);
|
|
@@ -153,14 +142,6 @@ class ModuleLibraryPlugin extends AbstractLibraryPlugin {
|
|
|
153
142
|
) {
|
|
154
143
|
return;
|
|
155
144
|
}
|
|
156
|
-
// If the generated source references any
|
|
157
|
-
// `__webpack_require__.<helper>` (the on-demand `.d(...)`
|
|
158
|
-
// is stashed, but `.r(__webpack_exports__)` from the ESM
|
|
159
|
-
// compat flag, namespace objects, deferred externals, ...
|
|
160
|
-
// stay in the result) the helpers and the require scope
|
|
161
|
-
// they live in are still needed. The dot in the substring
|
|
162
|
-
// avoids matching the bare `"__webpack_require__"` string
|
|
163
|
-
// literals that some test fixtures include.
|
|
164
145
|
const codeGenResult = codeGenerationResults.get(
|
|
165
146
|
module,
|
|
166
147
|
chunk.runtime
|
|
@@ -174,9 +155,34 @@ class ModuleLibraryPlugin extends AbstractLibraryPlugin {
|
|
|
174
155
|
return;
|
|
175
156
|
}
|
|
176
157
|
|
|
158
|
+
// Check whether any other module in the chunk still needs
|
|
159
|
+
// the helpers we want to remove.
|
|
160
|
+
let otherNeedsDefine = false;
|
|
161
|
+
let otherNeedsExports = false;
|
|
162
|
+
let otherNeedsRequireScope = false;
|
|
163
|
+
for (const m of chunkGraph.getChunkModulesIterable(chunk)) {
|
|
164
|
+
if (m === module) continue;
|
|
165
|
+
const requirements = chunkGraph.getModuleRuntimeRequirements(
|
|
166
|
+
m,
|
|
167
|
+
chunk.runtime
|
|
168
|
+
);
|
|
169
|
+
if (!requirements) continue;
|
|
170
|
+
if (requirements.has(RuntimeGlobals.definePropertyGetters)) {
|
|
171
|
+
otherNeedsDefine = true;
|
|
172
|
+
}
|
|
173
|
+
if (requirements.has(RuntimeGlobals.exports)) {
|
|
174
|
+
otherNeedsExports = true;
|
|
175
|
+
}
|
|
176
|
+
if (requirements.has(RuntimeGlobals.requireScope)) {
|
|
177
|
+
otherNeedsRequireScope = true;
|
|
178
|
+
}
|
|
179
|
+
if (otherNeedsDefine) break;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
if (otherNeedsDefine) return;
|
|
177
183
|
set.delete(RuntimeGlobals.definePropertyGetters);
|
|
178
|
-
set.delete(RuntimeGlobals.exports);
|
|
179
|
-
set.delete(RuntimeGlobals.requireScope);
|
|
184
|
+
if (!otherNeedsExports) set.delete(RuntimeGlobals.exports);
|
|
185
|
+
if (!otherNeedsRequireScope) set.delete(RuntimeGlobals.requireScope);
|
|
180
186
|
}
|
|
181
187
|
);
|
|
182
188
|
});
|
|
@@ -82,6 +82,41 @@ class NodeWatchFileSystem {
|
|
|
82
82
|
}
|
|
83
83
|
return { fileTimeInfoEntries, contextTimeInfoEntries };
|
|
84
84
|
};
|
|
85
|
+
const directoriesSet =
|
|
86
|
+
directories instanceof Set ? directories : new Set(directories);
|
|
87
|
+
|
|
88
|
+
// Watchpack reports a watched directory (a context dependency) in
|
|
89
|
+
// `changes` whenever its contents change, alongside the individual
|
|
90
|
+
// file events. The default `fs.purge(dir)` matches cache keys by
|
|
91
|
+
// prefix, so it would wipe the stat cache of every file inside the
|
|
92
|
+
// directory even though only file-level events actually invalidate
|
|
93
|
+
// file stats. For directories we explicitly watch, purge only the
|
|
94
|
+
// directory's own entry (`{ exact: true }`, enhanced-resolve >=
|
|
95
|
+
// 5.22.0); file-level events in the same aggregated batch still
|
|
96
|
+
// handle file stats and the parent readdir invalidation.
|
|
97
|
+
/**
|
|
98
|
+
* @param {Changes | null | undefined} changes changes set
|
|
99
|
+
* @param {Removals | null | undefined} removals removals set
|
|
100
|
+
*/
|
|
101
|
+
const purgeChanges = (changes, removals) => {
|
|
102
|
+
const fs = this.inputFileSystem;
|
|
103
|
+
if (!fs || !fs.purge) return;
|
|
104
|
+
if (changes) {
|
|
105
|
+
for (const item of changes) {
|
|
106
|
+
if (directoriesSet.has(item)) {
|
|
107
|
+
fs.purge(item, { exact: true });
|
|
108
|
+
} else {
|
|
109
|
+
fs.purge(item);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
if (removals) {
|
|
114
|
+
for (const item of removals) {
|
|
115
|
+
fs.purge(item);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
|
|
85
120
|
this.watcher.once(
|
|
86
121
|
"aggregated",
|
|
87
122
|
/**
|
|
@@ -94,15 +129,7 @@ class NodeWatchFileSystem {
|
|
|
94
129
|
/** @type {Watchpack} */
|
|
95
130
|
(this.watcher).pause();
|
|
96
131
|
|
|
97
|
-
|
|
98
|
-
if (fs && fs.purge) {
|
|
99
|
-
for (const item of changes) {
|
|
100
|
-
fs.purge(item);
|
|
101
|
-
}
|
|
102
|
-
for (const item of removals) {
|
|
103
|
-
fs.purge(item);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
132
|
+
purgeChanges(changes, removals);
|
|
106
133
|
const { fileTimeInfoEntries, contextTimeInfoEntries } = fetchTimeInfo();
|
|
107
134
|
callback(
|
|
108
135
|
null,
|
|
@@ -172,19 +199,7 @@ class NodeWatchFileSystem {
|
|
|
172
199
|
getInfo: () => {
|
|
173
200
|
const removals = this.watcher && this.watcher.aggregatedRemovals;
|
|
174
201
|
const changes = this.watcher && this.watcher.aggregatedChanges;
|
|
175
|
-
|
|
176
|
-
if (fs && fs.purge) {
|
|
177
|
-
if (removals) {
|
|
178
|
-
for (const item of removals) {
|
|
179
|
-
fs.purge(item);
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
if (changes) {
|
|
183
|
-
for (const item of changes) {
|
|
184
|
-
fs.purge(item);
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
}
|
|
202
|
+
purgeChanges(changes, removals);
|
|
188
203
|
const { fileTimeInfoEntries, contextTimeInfoEntries } = fetchTimeInfo();
|
|
189
204
|
return {
|
|
190
205
|
changes,
|
|
@@ -2317,8 +2317,9 @@ ${defineGetters}`
|
|
|
2317
2317
|
info.module.updateHash(hash, context);
|
|
2318
2318
|
break;
|
|
2319
2319
|
case "external":
|
|
2320
|
-
hash.update(
|
|
2321
|
-
|
|
2320
|
+
hash.update(
|
|
2321
|
+
`${chunkGraph.getModuleId(info.module)}|${runtimeConditionToString(info.runtimeCondition)}|${info.nonDeferAccess ? "1" : "0"}|${chunkGraph.moduleGraph.isDeferred(info.module) ? "1" : "0"}`
|
|
2322
|
+
);
|
|
2322
2323
|
break;
|
|
2323
2324
|
}
|
|
2324
2325
|
}
|
|
@@ -27,7 +27,6 @@ const { CompilerHintNotationRegExp } = require("../util/magicComment");
|
|
|
27
27
|
/** @typedef {import("../Module")} Module */
|
|
28
28
|
/** @typedef {import("../Module").BuildMeta} BuildMeta */
|
|
29
29
|
/** @typedef {import("../ModuleGraphConnection")} ModuleGraphConnection */
|
|
30
|
-
/** @typedef {import("../NormalModuleFactory").ModuleSettings} ModuleSettings */
|
|
31
30
|
/** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */
|
|
32
31
|
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
|
33
32
|
|
|
@@ -134,7 +133,7 @@ class SideEffectsFlagPlugin {
|
|
|
134
133
|
return module;
|
|
135
134
|
});
|
|
136
135
|
normalModuleFactory.hooks.module.tap(PLUGIN_NAME, (module, data) => {
|
|
137
|
-
const settings =
|
|
136
|
+
const settings = data.settings;
|
|
138
137
|
if (typeof settings.sideEffects === "boolean") {
|
|
139
138
|
if (module.factoryMeta === undefined) {
|
|
140
139
|
module.factoryMeta = {};
|
|
@@ -32,7 +32,7 @@ const MinMaxSizeWarning = require("./MinMaxSizeWarning");
|
|
|
32
32
|
/** @typedef {import("../Module")} Module */
|
|
33
33
|
/** @typedef {import("../Module").SourceType} SourceType */
|
|
34
34
|
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
|
35
|
-
/** @typedef {import("../
|
|
35
|
+
/** @typedef {import("../Chunk").ChunkFilenameTemplate} ChunkFilenameTemplate */
|
|
36
36
|
/** @typedef {import("../util/deterministicGrouping").GroupedItems<Module>} DeterministicGroupingGroupedItemsForModule */
|
|
37
37
|
/** @typedef {import("../util/deterministicGrouping").Options<Module>} DeterministicGroupingOptionsForModule */
|
|
38
38
|
/** @typedef {import("../util/deterministicGrouping").Sizes} Sizes */
|
|
@@ -78,7 +78,7 @@ const MinMaxSizeWarning = require("./MinMaxSizeWarning");
|
|
|
78
78
|
* @property {CountOfChunk=} minChunks
|
|
79
79
|
* @property {CountOfRequest=} maxAsyncRequests
|
|
80
80
|
* @property {CountOfRequest=} maxInitialRequests
|
|
81
|
-
* @property {
|
|
81
|
+
* @property {ChunkFilenameTemplate=} filename
|
|
82
82
|
* @property {string=} idHint
|
|
83
83
|
* @property {string=} automaticNameDelimiter
|
|
84
84
|
* @property {boolean=} reuseExistingChunk
|
|
@@ -101,7 +101,7 @@ const MinMaxSizeWarning = require("./MinMaxSizeWarning");
|
|
|
101
101
|
* @property {CountOfChunk} minChunks
|
|
102
102
|
* @property {CountOfRequest} maxAsyncRequests
|
|
103
103
|
* @property {CountOfRequest} maxInitialRequests
|
|
104
|
-
* @property {
|
|
104
|
+
* @property {ChunkFilenameTemplate=} filename
|
|
105
105
|
* @property {string} idHint
|
|
106
106
|
* @property {string} automaticNameDelimiter
|
|
107
107
|
* @property {boolean} reuseExistingChunk
|
|
@@ -163,7 +163,7 @@ const MinMaxSizeWarning = require("./MinMaxSizeWarning");
|
|
|
163
163
|
* @property {CountOfRequest} maxAsyncRequests
|
|
164
164
|
* @property {CountOfRequest} maxInitialRequests
|
|
165
165
|
* @property {boolean} hidePathInfo
|
|
166
|
-
* @property {
|
|
166
|
+
* @property {ChunkFilenameTemplate=} filename
|
|
167
167
|
* @property {string} automaticNameDelimiter
|
|
168
168
|
* @property {GetCacheGroups} getCacheGroups
|
|
169
169
|
* @property {GetNameFn} getName
|
|
@@ -26,14 +26,14 @@ class AutoPublicPathRuntimeModule extends RuntimeModule {
|
|
|
26
26
|
const compilation = /** @type {Compilation} */ (this.compilation);
|
|
27
27
|
const { scriptType, importMetaName, path, environment } =
|
|
28
28
|
compilation.outputOptions;
|
|
29
|
+
const chunk = /** @type {Chunk} */ (this.chunk);
|
|
29
30
|
const chunkName = compilation.getPath(
|
|
30
31
|
JavascriptModulesPlugin.getChunkFilenameTemplate(
|
|
31
|
-
|
|
32
|
-
(this.chunk),
|
|
32
|
+
chunk,
|
|
33
33
|
compilation.outputOptions
|
|
34
34
|
),
|
|
35
35
|
{
|
|
36
|
-
chunk
|
|
36
|
+
chunk,
|
|
37
37
|
contentHashType: "javascript"
|
|
38
38
|
}
|
|
39
39
|
);
|
|
@@ -14,14 +14,14 @@ const { first } = require("../util/SetHelpers");
|
|
|
14
14
|
/** @typedef {import("../ChunkGraph")} ChunkGraph */
|
|
15
15
|
/** @typedef {import("../Compilation")} Compilation */
|
|
16
16
|
/** @typedef {import("../Compilation").HashWithLengthFunction} HashWithLengthFunction */
|
|
17
|
-
/** @typedef {import("../
|
|
17
|
+
/** @typedef {import("../Chunk").ChunkFilenameTemplate} ChunkFilenameTemplate */
|
|
18
18
|
|
|
19
19
|
class GetChunkFilenameRuntimeModule extends RuntimeModule {
|
|
20
20
|
/**
|
|
21
21
|
* @param {string} contentType the contentType to use the content hash for
|
|
22
22
|
* @param {string} name kind of filename
|
|
23
23
|
* @param {string} global function name to be assigned
|
|
24
|
-
* @param {(chunk: Chunk) =>
|
|
24
|
+
* @param {(chunk: Chunk) => ChunkFilenameTemplate | false} getFilenameForChunk functor to get the filename or function
|
|
25
25
|
* @param {boolean} allChunks when false, only async chunks are included
|
|
26
26
|
*/
|
|
27
27
|
constructor(contentType, name, global, getFilenameForChunk, allChunks) {
|
|
@@ -30,7 +30,7 @@ class GetChunkFilenameRuntimeModule extends RuntimeModule {
|
|
|
30
30
|
this.contentType = contentType;
|
|
31
31
|
/** @type {string} */
|
|
32
32
|
this.global = global;
|
|
33
|
-
/** @type {(chunk: Chunk) =>
|
|
33
|
+
/** @type {(chunk: Chunk) => ChunkFilenameTemplate | false} */
|
|
34
34
|
this.getFilenameForChunk = getFilenameForChunk;
|
|
35
35
|
/** @type {boolean} */
|
|
36
36
|
this.allChunks = allChunks;
|
|
@@ -49,7 +49,7 @@ class GetChunkFilenameRuntimeModule extends RuntimeModule {
|
|
|
49
49
|
const chunk = /** @type {Chunk} */ (this.chunk);
|
|
50
50
|
const { runtimeTemplate } = compilation;
|
|
51
51
|
|
|
52
|
-
/** @type {Map<
|
|
52
|
+
/** @type {Map<ChunkFilenameTemplate, Set<Chunk>>} */
|
|
53
53
|
const chunkFilenames = new Map();
|
|
54
54
|
let maxChunks = 0;
|
|
55
55
|
/** @type {string | undefined} */
|
|
@@ -126,7 +126,7 @@ class GetChunkFilenameRuntimeModule extends RuntimeModule {
|
|
|
126
126
|
|
|
127
127
|
/**
|
|
128
128
|
* @param {Chunk} c the chunk
|
|
129
|
-
* @param {
|
|
129
|
+
* @param {ChunkFilenameTemplate} chunkFilename the filename template for the chunk
|
|
130
130
|
* @returns {void}
|
|
131
131
|
*/
|
|
132
132
|
const addStaticUrl = (c, chunkFilename) => {
|
|
@@ -356,15 +356,9 @@ class ConsumeSharedPlugin {
|
|
|
356
356
|
) {
|
|
357
357
|
return Promise.resolve();
|
|
358
358
|
}
|
|
359
|
-
const options = resolvedConsumes.get(
|
|
360
|
-
/** @type {string} */ (resource)
|
|
361
|
-
);
|
|
359
|
+
const options = resolvedConsumes.get(resource);
|
|
362
360
|
if (options !== undefined) {
|
|
363
|
-
return createConsumeSharedModule(
|
|
364
|
-
context,
|
|
365
|
-
/** @type {string} */ (resource),
|
|
366
|
-
options
|
|
367
|
-
);
|
|
361
|
+
return createConsumeSharedModule(context, resource, options);
|
|
368
362
|
}
|
|
369
363
|
return Promise.resolve();
|
|
370
364
|
}
|
|
@@ -169,7 +169,7 @@ class ProvideSharedPlugin {
|
|
|
169
169
|
normalModuleFactory.hooks.module.tap(
|
|
170
170
|
PLUGIN_NAME,
|
|
171
171
|
(module, { resource, resourceResolveData }, resolveData) => {
|
|
172
|
-
if (resolvedProvideMap.has(
|
|
172
|
+
if (resolvedProvideMap.has(resource)) {
|
|
173
173
|
return module;
|
|
174
174
|
}
|
|
175
175
|
const { request } = resolveData;
|
|
@@ -179,7 +179,7 @@ class ProvideSharedPlugin {
|
|
|
179
179
|
provideSharedModule(
|
|
180
180
|
request,
|
|
181
181
|
config,
|
|
182
|
-
|
|
182
|
+
resource,
|
|
183
183
|
resourceResolveData
|
|
184
184
|
);
|
|
185
185
|
resolveData.cacheable = false;
|
|
@@ -189,12 +189,12 @@ class ProvideSharedPlugin {
|
|
|
189
189
|
if (request.startsWith(prefix)) {
|
|
190
190
|
const remainder = request.slice(prefix.length);
|
|
191
191
|
provideSharedModule(
|
|
192
|
-
|
|
192
|
+
resource,
|
|
193
193
|
{
|
|
194
194
|
...config,
|
|
195
195
|
shareKey: config.shareKey + remainder
|
|
196
196
|
},
|
|
197
|
-
|
|
197
|
+
resource,
|
|
198
198
|
resourceResolveData
|
|
199
199
|
);
|
|
200
200
|
resolveData.cacheable = false;
|
package/lib/util/fs.js
CHANGED
|
@@ -308,7 +308,12 @@ const path = require("path");
|
|
|
308
308
|
|
|
309
309
|
/**
|
|
310
310
|
* Defines the purge type used by this module.
|
|
311
|
-
*
|
|
311
|
+
*
|
|
312
|
+
* `options.exact` (supported by enhanced-resolve's `CachedInputFileSystem`
|
|
313
|
+
* from v5.22.0): when true, only entries whose key exactly matches `value`
|
|
314
|
+
* are invalidated; cached entries for descendants are preserved. Default
|
|
315
|
+
* is false (legacy prefix-match behavior).
|
|
316
|
+
* @typedef {(value?: string | string[] | Set<string>, options?: { exact?: boolean }) => void} Purge
|
|
312
317
|
*/
|
|
313
318
|
|
|
314
319
|
/**
|
|
@@ -216,8 +216,7 @@ class AsyncWebAssemblyModulesPlugin {
|
|
|
216
216
|
PLUGIN_NAME,
|
|
217
217
|
(createData, resolveData) =>
|
|
218
218
|
new AsyncWasmModule({
|
|
219
|
-
|
|
220
|
-
(createData),
|
|
219
|
+
...createData,
|
|
221
220
|
phase: resolveData.phase
|
|
222
221
|
})
|
|
223
222
|
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "webpack",
|
|
3
|
-
"version": "5.107.
|
|
3
|
+
"version": "5.107.2",
|
|
4
4
|
"description": "Packs ECMAScript/CommonJs/AMD modules for the browser. Allows you to split your codebase into multiple bundles, which can be loaded on demand. Supports loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.",
|
|
5
5
|
"homepage": "https://github.com/webpack/webpack",
|
|
6
6
|
"bugs": "https://github.com/webpack/webpack/issues",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"prelint": "yarn setup",
|
|
35
35
|
"lint": "yarn lint:code && yarn lint:special && yarn lint:types && yarn lint:types-test && yarn lint:types-benchmark && yarn lint:types-module-test && yarn lint:types-hot && yarn fmt:check && yarn lint:spellcheck",
|
|
36
36
|
"lint:code": "node node_modules/eslint/bin/eslint.js --cache .",
|
|
37
|
-
"lint:special": "node node_modules/tooling/lockfile-lint && node node_modules/tooling/schemas-lint && node node_modules/tooling/inherit-types && node node_modules/tooling/format-schemas && node tooling/generate-runtime-code.js && node tooling/generate-wasm-code.js && node node_modules/tooling/compile-to-definitions && node node_modules/tooling/precompile-schemas && node node_modules/tooling/generate-types --no-template-literals",
|
|
37
|
+
"lint:special": "node node_modules/tooling/lockfile-lint && node node_modules/tooling/schemas-lint && node node_modules/tooling/inherit-types && node node_modules/tooling/format-schemas && node tooling/generate-runtime-code.js && node tooling/generate-wasm-code.js && node tooling/generate-html-entities.js && node node_modules/tooling/compile-to-definitions && node node_modules/tooling/precompile-schemas && node node_modules/tooling/generate-types --no-template-literals",
|
|
38
38
|
"lint:types": "tsc",
|
|
39
39
|
"lint:types-test": "tsc -p tsconfig.types.test.json",
|
|
40
40
|
"lint:types-benchmark": "tsc -p tsconfig.types.benchmark.json",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"fmt:base": "node node_modules/prettier/bin/prettier.cjs --cache --ignore-unknown .",
|
|
49
49
|
"fix": "yarn fix:code && yarn fix:special && yarn fmt",
|
|
50
50
|
"fix:code": "yarn lint:code --fix",
|
|
51
|
-
"fix:special": "node node_modules/tooling/inherit-types --write && node node_modules/tooling/format-schemas --write && node tooling/generate-runtime-code.js --write && node tooling/generate-wasm-code.js --write && node node_modules/tooling/compile-to-definitions --write && node node_modules/tooling/precompile-schemas --write && node node_modules/tooling/generate-types --no-template-literals --write",
|
|
51
|
+
"fix:special": "node node_modules/tooling/inherit-types --write && node node_modules/tooling/format-schemas --write && node tooling/generate-runtime-code.js --write && node tooling/generate-wasm-code.js --write && node tooling/generate-html-entities.js --write && node node_modules/tooling/compile-to-definitions --write && node node_modules/tooling/precompile-schemas --write && node node_modules/tooling/generate-types --no-template-literals --write",
|
|
52
52
|
"build:examples": "cd examples && node buildAll.js",
|
|
53
53
|
"benchmark": "node --max-old-space-size=6144 --experimental-vm-modules --trace-deprecation --hash-seed=1 --random-seed=1 --no-opt --predictable --predictable-gc-schedule --interpreted-frames-native-stack --allow-natives-syntax --expose-gc --no-concurrent-sweeping ./test/BenchmarkTestCases.benchmark.mjs",
|
|
54
54
|
"pretest": "yarn lint",
|
|
@@ -97,7 +97,7 @@
|
|
|
97
97
|
"acorn-import-phases": "^1.0.3",
|
|
98
98
|
"browserslist": "^4.28.1",
|
|
99
99
|
"chrome-trace-event": "^1.0.2",
|
|
100
|
-
"enhanced-resolve": "^5.
|
|
100
|
+
"enhanced-resolve": "^5.22.0",
|
|
101
101
|
"es-module-lexer": "^2.1.0",
|
|
102
102
|
"eslint-scope": "5.1.1",
|
|
103
103
|
"events": "^3.2.0",
|
|
@@ -110,7 +110,7 @@
|
|
|
110
110
|
"tapable": "^2.3.0",
|
|
111
111
|
"terser-webpack-plugin": "^5.5.0",
|
|
112
112
|
"watchpack": "^2.5.1",
|
|
113
|
-
"webpack-sources": "^3.
|
|
113
|
+
"webpack-sources": "^3.5.0"
|
|
114
114
|
},
|
|
115
115
|
"devDependencies": {
|
|
116
116
|
"@babel/core": "^7.27.1",
|