webpack 5.65.0 → 5.69.0
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.
Potentially problematic release.
This version of webpack might be problematic. Click here for more details.
- package/README.md +1 -1
- package/lib/APIPlugin.js +33 -0
- package/lib/Cache.js +1 -1
- package/lib/CacheFacade.js +4 -11
- package/lib/Chunk.js +2 -0
- package/lib/ChunkGraph.js +1 -2
- package/lib/CleanPlugin.js +1 -1
- package/lib/Compilation.js +93 -47
- package/lib/Compiler.js +57 -3
- package/lib/ContextModule.js +100 -41
- package/lib/ContextModuleFactory.js +60 -21
- package/lib/DelegatedModule.js +1 -1
- package/lib/Dependency.js +10 -0
- package/lib/DependencyTemplate.js +9 -0
- package/lib/DependencyTemplates.js +1 -1
- package/lib/DllModule.js +1 -1
- package/lib/EvalDevToolModulePlugin.js +16 -1
- package/lib/EvalSourceMapDevToolPlugin.js +18 -1
- package/lib/ExportsInfo.js +4 -4
- package/lib/ExternalModule.js +93 -53
- package/lib/ExternalModuleFactoryPlugin.js +1 -1
- package/lib/FileSystemInfo.js +29 -25
- package/lib/Generator.js +2 -0
- package/lib/HookWebpackError.js +1 -1
- package/lib/Module.js +25 -4
- package/lib/ModuleFilenameHelpers.js +5 -1
- package/lib/MultiCompiler.js +1 -1
- package/lib/MultiWatching.js +1 -1
- package/lib/NormalModule.js +9 -5
- package/lib/NormalModuleFactory.js +25 -27
- package/lib/ProgressPlugin.js +1 -1
- package/lib/RawModule.js +1 -1
- package/lib/RuntimeGlobals.js +29 -1
- package/lib/RuntimeModule.js +1 -1
- package/lib/RuntimePlugin.js +50 -0
- package/lib/RuntimeTemplate.js +21 -0
- package/lib/Template.js +2 -1
- package/lib/TemplatedPathPlugin.js +48 -23
- package/lib/Watching.js +2 -2
- package/lib/WebpackOptionsApply.js +43 -2
- package/lib/asset/AssetGenerator.js +67 -26
- package/lib/asset/AssetModulesPlugin.js +3 -0
- package/lib/asset/RawDataUrlModule.js +148 -0
- package/lib/async-modules/AwaitDependenciesInitFragment.js +4 -4
- package/lib/buildChunkGraph.js +1 -1
- package/lib/cache/ResolverCachePlugin.js +81 -29
- package/lib/cli.js +44 -3
- package/lib/config/defaults.js +86 -7
- package/lib/config/normalization.js +5 -0
- package/lib/container/ContainerEntryModule.js +4 -2
- package/lib/container/FallbackModule.js +4 -4
- package/lib/container/RemoteModule.js +4 -2
- package/lib/css/CssExportsGenerator.js +139 -0
- package/lib/css/CssGenerator.js +109 -0
- package/lib/css/CssLoadingRuntimeModule.js +440 -0
- package/lib/css/CssModulesPlugin.js +462 -0
- package/lib/css/CssParser.js +618 -0
- package/lib/css/walkCssTokens.js +659 -0
- package/lib/debug/ProfilingPlugin.js +15 -14
- package/lib/dependencies/ContextElementDependency.js +8 -2
- package/lib/dependencies/CreateScriptUrlDependency.js +12 -0
- package/lib/dependencies/CssExportDependency.js +85 -0
- package/lib/dependencies/CssImportDependency.js +75 -0
- package/lib/dependencies/CssLocalIdentifierDependency.js +119 -0
- package/lib/dependencies/CssSelfLocalIdentifierDependency.js +101 -0
- package/lib/dependencies/CssUrlDependency.js +132 -0
- package/lib/dependencies/ExportsInfoDependency.js +6 -0
- package/lib/dependencies/HarmonyCompatibilityDependency.js +5 -5
- package/lib/dependencies/ImportMetaPlugin.js +22 -3
- package/lib/dependencies/LoaderPlugin.js +2 -2
- package/lib/dependencies/URLDependency.js +3 -8
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +1 -1
- package/lib/hmr/LazyCompilationPlugin.js +45 -21
- package/lib/hmr/lazyCompilationBackend.js +4 -2
- package/lib/ids/DeterministicModuleIdsPlugin.js +55 -35
- package/lib/ids/HashedModuleIdsPlugin.js +9 -12
- package/lib/ids/IdHelpers.js +24 -10
- package/lib/ids/NamedModuleIdsPlugin.js +6 -9
- package/lib/ids/NaturalModuleIdsPlugin.js +10 -13
- package/lib/ids/OccurrenceModuleIdsPlugin.js +13 -10
- package/lib/ids/SyncModuleIdsPlugin.js +140 -0
- package/lib/index.js +10 -0
- package/lib/javascript/JavascriptGenerator.js +1 -0
- package/lib/javascript/JavascriptModulesPlugin.js +27 -2
- package/lib/javascript/StartupHelpers.js +6 -5
- package/lib/library/AssignLibraryPlugin.js +34 -5
- package/lib/library/EnableLibraryPlugin.js +11 -0
- package/lib/node/NodeTargetPlugin.js +1 -0
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +1 -1
- package/lib/node/RequireChunkLoadingRuntimeModule.js +1 -1
- package/lib/optimize/ConcatenatedModule.js +21 -9
- package/lib/runtime/AsyncModuleRuntimeModule.js +25 -15
- package/lib/runtime/CreateScriptRuntimeModule.js +36 -0
- package/lib/runtime/CreateScriptUrlRuntimeModule.js +9 -34
- package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +76 -0
- package/lib/schemes/HttpUriPlugin.js +32 -11
- package/lib/serialization/FileMiddleware.js +44 -9
- package/lib/sharing/ConsumeSharedModule.js +4 -2
- package/lib/sharing/ProvideSharedModule.js +4 -2
- package/lib/sharing/utils.js +1 -1
- package/lib/stats/DefaultStatsFactoryPlugin.js +112 -67
- package/lib/stats/DefaultStatsPrinterPlugin.js +88 -23
- package/lib/util/ArrayHelpers.js +18 -4
- package/lib/util/AsyncQueue.js +1 -1
- package/lib/util/compileBooleanMatcher.js +1 -1
- package/lib/util/deterministicGrouping.js +1 -1
- package/lib/util/hash/xxhash64.js +2 -2
- package/lib/util/identifier.js +65 -44
- package/lib/util/internalSerializables.js +11 -0
- package/lib/util/nonNumericOnlyHash.js +22 -0
- package/lib/util/semver.js +17 -10
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +9 -3
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +2 -2
- package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +3 -11
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +1 -1
- package/package.json +16 -23
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +96 -1
- package/schemas/plugins/asset/AssetGeneratorOptions.check.js +1 -1
- package/schemas/plugins/asset/AssetResourceGeneratorOptions.check.js +1 -1
- package/schemas/plugins/container/ContainerPlugin.check.js +1 -1
- package/schemas/plugins/container/ContainerPlugin.json +2 -1
- 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 +3 -1
- package/schemas/plugins/css/CssGeneratorOptions.check.d.ts +7 -0
- package/schemas/plugins/css/CssGeneratorOptions.check.js +6 -0
- package/schemas/plugins/css/CssGeneratorOptions.json +3 -0
- package/schemas/plugins/css/CssParserOptions.check.d.ts +7 -0
- package/schemas/plugins/css/CssParserOptions.check.js +6 -0
- package/schemas/plugins/css/CssParserOptions.json +3 -0
- package/types.d.ts +295 -59
package/lib/ContextModule.js
CHANGED
@@ -61,7 +61,7 @@ const makeSerializable = require("./util/makeSerializable");
|
|
61
61
|
|
62
62
|
/**
|
63
63
|
* @typedef {Object} ContextModuleOptionsExtras
|
64
|
-
* @property {string} resource
|
64
|
+
* @property {string|string[]} resource
|
65
65
|
* @property {string=} resourceQuery
|
66
66
|
* @property {string=} resourceFragment
|
67
67
|
* @property {TODO} resolveOptions
|
@@ -71,7 +71,7 @@ const makeSerializable = require("./util/makeSerializable");
|
|
71
71
|
|
72
72
|
/**
|
73
73
|
* @callback ResolveDependenciesCallback
|
74
|
-
* @param {Error=} err
|
74
|
+
* @param {(Error | null)=} err
|
75
75
|
* @param {ContextElementDependency[]=} dependencies
|
76
76
|
*/
|
77
77
|
|
@@ -92,23 +92,36 @@ class ContextModule extends Module {
|
|
92
92
|
* @param {ContextModuleOptions} options options object
|
93
93
|
*/
|
94
94
|
constructor(resolveDependencies, options) {
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
95
|
+
if (!options || typeof options.resource === "string") {
|
96
|
+
const parsed = parseResource(
|
97
|
+
options ? /** @type {string} */ (options.resource) : ""
|
98
|
+
);
|
99
|
+
const resource = parsed.path;
|
100
|
+
const resourceQuery = (options && options.resourceQuery) || parsed.query;
|
101
|
+
const resourceFragment =
|
102
|
+
(options && options.resourceFragment) || parsed.fragment;
|
103
|
+
|
104
|
+
super("javascript/dynamic", resource);
|
105
|
+
/** @type {ContextModuleOptions} */
|
106
|
+
this.options = {
|
107
|
+
...options,
|
108
|
+
resource,
|
109
|
+
resourceQuery,
|
110
|
+
resourceFragment
|
111
|
+
};
|
112
|
+
} else {
|
113
|
+
super("javascript/dynamic");
|
114
|
+
/** @type {ContextModuleOptions} */
|
115
|
+
this.options = {
|
116
|
+
...options,
|
117
|
+
resource: options.resource,
|
118
|
+
resourceQuery: options.resourceQuery || "",
|
119
|
+
resourceFragment: options.resourceFragment || ""
|
120
|
+
};
|
121
|
+
}
|
102
122
|
|
103
123
|
// Info from Factory
|
104
124
|
this.resolveDependencies = resolveDependencies;
|
105
|
-
/** @type {ContextModuleOptions} */
|
106
|
-
this.options = {
|
107
|
-
...options,
|
108
|
-
resource,
|
109
|
-
resourceQuery,
|
110
|
-
resourceFragment
|
111
|
-
};
|
112
125
|
if (options && options.resolveOptions !== undefined) {
|
113
126
|
this.resolveOptions = options.resolveOptions;
|
114
127
|
}
|
@@ -149,16 +162,17 @@ class ContextModule extends Module {
|
|
149
162
|
this.resolveDependencies = undefined;
|
150
163
|
}
|
151
164
|
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
return regexString
|
156
|
-
.substring(1, regexString.length - 1)
|
157
|
-
.replace(/!/g, "%21");
|
165
|
+
_prettyRegExp(regexString, stripSlash = true) {
|
166
|
+
const str = (regexString + "").replace(/!/g, "%21").replace(/\|/g, "%7C");
|
167
|
+
return stripSlash ? str.substring(1, str.length - 1) : str;
|
158
168
|
}
|
159
169
|
|
160
170
|
_createIdentifier() {
|
161
|
-
let identifier =
|
171
|
+
let identifier =
|
172
|
+
this.context ||
|
173
|
+
(typeof this.options.resource === "string"
|
174
|
+
? this.options.resource
|
175
|
+
: this.options.resource.join("|"));
|
162
176
|
if (this.options.resourceQuery) {
|
163
177
|
identifier += `|${this.options.resourceQuery}`;
|
164
178
|
}
|
@@ -175,13 +189,19 @@ class ContextModule extends Module {
|
|
175
189
|
identifier += `|${this.options.addon}`;
|
176
190
|
}
|
177
191
|
if (this.options.regExp) {
|
178
|
-
identifier += `|${this.options.regExp}`;
|
192
|
+
identifier += `|${this._prettyRegExp(this.options.regExp, false)}`;
|
179
193
|
}
|
180
194
|
if (this.options.include) {
|
181
|
-
identifier += `|include: ${this.
|
195
|
+
identifier += `|include: ${this._prettyRegExp(
|
196
|
+
this.options.include,
|
197
|
+
false
|
198
|
+
)}`;
|
182
199
|
}
|
183
200
|
if (this.options.exclude) {
|
184
|
-
identifier += `|exclude: ${this.
|
201
|
+
identifier += `|exclude: ${this._prettyRegExp(
|
202
|
+
this.options.exclude,
|
203
|
+
false
|
204
|
+
)}`;
|
185
205
|
}
|
186
206
|
if (this.options.referencedExports) {
|
187
207
|
identifier += `|referencedExports: ${JSON.stringify(
|
@@ -217,7 +237,16 @@ class ContextModule extends Module {
|
|
217
237
|
* @returns {string} a user readable identifier of the module
|
218
238
|
*/
|
219
239
|
readableIdentifier(requestShortener) {
|
220
|
-
let identifier
|
240
|
+
let identifier;
|
241
|
+
if (this.context) {
|
242
|
+
identifier = requestShortener.shorten(this.context) + "/";
|
243
|
+
} else if (typeof this.options.resource === "string") {
|
244
|
+
identifier = requestShortener.shorten(this.options.resource) + "/";
|
245
|
+
} else {
|
246
|
+
identifier = this.options.resource
|
247
|
+
.map(r => requestShortener.shorten(r) + "/")
|
248
|
+
.join(" ");
|
249
|
+
}
|
221
250
|
if (this.options.resourceQuery) {
|
222
251
|
identifier += ` ${this.options.resourceQuery}`;
|
223
252
|
}
|
@@ -231,13 +260,13 @@ class ContextModule extends Module {
|
|
231
260
|
identifier += ` ${requestShortener.shorten(this.options.addon)}`;
|
232
261
|
}
|
233
262
|
if (this.options.regExp) {
|
234
|
-
identifier += ` ${this.
|
263
|
+
identifier += ` ${this._prettyRegExp(this.options.regExp)}`;
|
235
264
|
}
|
236
265
|
if (this.options.include) {
|
237
|
-
identifier += ` include: ${this.
|
266
|
+
identifier += ` include: ${this._prettyRegExp(this.options.include)}`;
|
238
267
|
}
|
239
268
|
if (this.options.exclude) {
|
240
|
-
identifier += ` exclude: ${this.
|
269
|
+
identifier += ` exclude: ${this._prettyRegExp(this.options.exclude)}`;
|
241
270
|
}
|
242
271
|
if (this.options.referencedExports) {
|
243
272
|
identifier += ` referencedExports: ${this.options.referencedExports
|
@@ -267,11 +296,31 @@ class ContextModule extends Module {
|
|
267
296
|
* @returns {string | null} an identifier for library inclusion
|
268
297
|
*/
|
269
298
|
libIdent(options) {
|
270
|
-
let identifier
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
299
|
+
let identifier;
|
300
|
+
|
301
|
+
if (this.context) {
|
302
|
+
identifier = contextify(
|
303
|
+
options.context,
|
304
|
+
this.context,
|
305
|
+
options.associatedObjectForCache
|
306
|
+
);
|
307
|
+
} else if (typeof this.options.resource === "string") {
|
308
|
+
identifier = contextify(
|
309
|
+
options.context,
|
310
|
+
this.options.resource,
|
311
|
+
options.associatedObjectForCache
|
312
|
+
);
|
313
|
+
} else {
|
314
|
+
const arr = [];
|
315
|
+
for (const res of this.options.resource) {
|
316
|
+
arr.push(
|
317
|
+
contextify(options.context, res, options.associatedObjectForCache)
|
318
|
+
);
|
319
|
+
}
|
320
|
+
identifier = arr.join(" ");
|
321
|
+
}
|
322
|
+
|
323
|
+
if (this.layer) identifier = `(${this.layer})/${identifier}`;
|
275
324
|
if (this.options.mode) {
|
276
325
|
identifier += ` ${this.options.mode}`;
|
277
326
|
}
|
@@ -286,13 +335,13 @@ class ContextModule extends Module {
|
|
286
335
|
)}`;
|
287
336
|
}
|
288
337
|
if (this.options.regExp) {
|
289
|
-
identifier += ` ${this.
|
338
|
+
identifier += ` ${this._prettyRegExp(this.options.regExp)}`;
|
290
339
|
}
|
291
340
|
if (this.options.include) {
|
292
|
-
identifier += ` include: ${this.
|
341
|
+
identifier += ` include: ${this._prettyRegExp(this.options.include)}`;
|
293
342
|
}
|
294
343
|
if (this.options.exclude) {
|
295
|
-
identifier += ` exclude: ${this.
|
344
|
+
identifier += ` exclude: ${this._prettyRegExp(this.options.exclude)}`;
|
296
345
|
}
|
297
346
|
if (this.options.referencedExports) {
|
298
347
|
identifier += ` referencedExports: ${this.options.referencedExports
|
@@ -312,7 +361,7 @@ class ContextModule extends Module {
|
|
312
361
|
|
313
362
|
/**
|
314
363
|
* @param {NeedBuildContext} context context info
|
315
|
-
* @param {function(WebpackError=, boolean=): void} callback callback function, returns true, if the module needs a rebuild
|
364
|
+
* @param {function((WebpackError | null)=, boolean=): void} callback callback function, returns true, if the module needs a rebuild
|
316
365
|
* @returns {void}
|
317
366
|
*/
|
318
367
|
needBuild({ fileSystemInfo }, callback) {
|
@@ -438,7 +487,11 @@ class ContextModule extends Module {
|
|
438
487
|
compilation.fileSystemInfo.createSnapshot(
|
439
488
|
startTime,
|
440
489
|
null,
|
441
|
-
|
490
|
+
this.context
|
491
|
+
? [this.context]
|
492
|
+
: typeof this.options.resource === "string"
|
493
|
+
? [this.options.resource]
|
494
|
+
: this.options.resource,
|
442
495
|
null,
|
443
496
|
SNAPSHOT_OPTIONS,
|
444
497
|
(err, snapshot) => {
|
@@ -462,7 +515,13 @@ class ContextModule extends Module {
|
|
462
515
|
missingDependencies,
|
463
516
|
buildDependencies
|
464
517
|
) {
|
465
|
-
|
518
|
+
if (this.context) {
|
519
|
+
contextDependencies.add(this.context);
|
520
|
+
} else if (typeof this.options.resource === "string") {
|
521
|
+
contextDependencies.add(this.options.resource);
|
522
|
+
} else {
|
523
|
+
for (const res of this.options.resource) contextDependencies.add(res);
|
524
|
+
}
|
466
525
|
}
|
467
526
|
|
468
527
|
/**
|
@@ -167,6 +167,9 @@ module.exports = class ContextModuleFactory extends ModuleFactory {
|
|
167
167
|
asyncLib.parallel(
|
168
168
|
[
|
169
169
|
callback => {
|
170
|
+
const results = [];
|
171
|
+
const yield_ = obj => results.push(obj);
|
172
|
+
|
170
173
|
contextResolver.resolve(
|
171
174
|
{},
|
172
175
|
context,
|
@@ -174,11 +177,12 @@ module.exports = class ContextModuleFactory extends ModuleFactory {
|
|
174
177
|
{
|
175
178
|
fileDependencies,
|
176
179
|
missingDependencies,
|
177
|
-
contextDependencies
|
180
|
+
contextDependencies,
|
181
|
+
yield: yield_
|
178
182
|
},
|
179
|
-
|
183
|
+
err => {
|
180
184
|
if (err) return callback(err);
|
181
|
-
callback(null,
|
185
|
+
callback(null, results);
|
182
186
|
}
|
183
187
|
);
|
184
188
|
},
|
@@ -213,15 +217,20 @@ module.exports = class ContextModuleFactory extends ModuleFactory {
|
|
213
217
|
contextDependencies
|
214
218
|
});
|
215
219
|
}
|
216
|
-
|
220
|
+
const [contextResult, loaderResult] = result;
|
217
221
|
this.hooks.afterResolve.callAsync(
|
218
222
|
{
|
219
223
|
addon:
|
220
224
|
loadersPrefix +
|
221
|
-
|
222
|
-
(
|
223
|
-
resource:
|
225
|
+
loaderResult.join("!") +
|
226
|
+
(loaderResult.length > 0 ? "!" : ""),
|
227
|
+
resource:
|
228
|
+
contextResult.length > 1
|
229
|
+
? contextResult.map(r => r.path)
|
230
|
+
: contextResult[0].path,
|
224
231
|
resolveDependencies: this.resolveDependencies.bind(this),
|
232
|
+
resourceQuery: contextResult[0].query,
|
233
|
+
resourceFragment: contextResult[0].fragment,
|
225
234
|
...beforeResolveResult
|
226
235
|
},
|
227
236
|
(err, result) => {
|
@@ -278,26 +287,28 @@ module.exports = class ContextModuleFactory extends ModuleFactory {
|
|
278
287
|
} = options;
|
279
288
|
if (!regExp || !resource) return callback(null, []);
|
280
289
|
|
281
|
-
|
290
|
+
let severalContexts = false;
|
291
|
+
const addDirectoryChecked = (ctx, directory, visited, callback) => {
|
282
292
|
fs.realpath(directory, (err, realPath) => {
|
283
293
|
if (err) return callback(err);
|
284
294
|
if (visited.has(realPath)) return callback(null, []);
|
285
295
|
let recursionStack;
|
286
296
|
addDirectory(
|
297
|
+
ctx,
|
287
298
|
directory,
|
288
|
-
(dir, callback) => {
|
299
|
+
(_, dir, callback) => {
|
289
300
|
if (recursionStack === undefined) {
|
290
301
|
recursionStack = new Set(visited);
|
291
302
|
recursionStack.add(realPath);
|
292
303
|
}
|
293
|
-
addDirectoryChecked(dir, recursionStack, callback);
|
304
|
+
addDirectoryChecked(ctx, dir, recursionStack, callback);
|
294
305
|
},
|
295
306
|
callback
|
296
307
|
);
|
297
308
|
});
|
298
309
|
};
|
299
310
|
|
300
|
-
const addDirectory = (directory, addSubDirectory, callback) => {
|
311
|
+
const addDirectory = (ctx, directory, addSubDirectory, callback) => {
|
301
312
|
fs.readdir(directory, (err, files) => {
|
302
313
|
if (err) return callback(err);
|
303
314
|
const processedFiles = cmf.hooks.contextModuleFiles.call(
|
@@ -324,16 +335,15 @@ module.exports = class ContextModuleFactory extends ModuleFactory {
|
|
324
335
|
|
325
336
|
if (stat.isDirectory()) {
|
326
337
|
if (!recursive) return callback();
|
327
|
-
addSubDirectory(subResource, callback);
|
338
|
+
addSubDirectory(ctx, subResource, callback);
|
328
339
|
} else if (
|
329
340
|
stat.isFile() &&
|
330
341
|
(!include || subResource.match(include))
|
331
342
|
) {
|
332
343
|
const obj = {
|
333
|
-
context:
|
344
|
+
context: ctx,
|
334
345
|
request:
|
335
|
-
"." +
|
336
|
-
subResource.substr(resource.length).replace(/\\/g, "/")
|
346
|
+
"." + subResource.substr(ctx.length).replace(/\\/g, "/")
|
337
347
|
};
|
338
348
|
|
339
349
|
this.hooks.alternativeRequests.callAsync(
|
@@ -344,8 +354,11 @@ module.exports = class ContextModuleFactory extends ModuleFactory {
|
|
344
354
|
alternatives = alternatives
|
345
355
|
.filter(obj => regExp.test(obj.request))
|
346
356
|
.map(obj => {
|
357
|
+
const request = severalContexts
|
358
|
+
? join(fs, obj.context, obj.request)
|
359
|
+
: obj.request;
|
347
360
|
const dep = new ContextElementDependency(
|
348
|
-
|
361
|
+
request + resourceQuery + resourceFragment,
|
349
362
|
obj.request,
|
350
363
|
typePrefix,
|
351
364
|
category,
|
@@ -382,12 +395,38 @@ module.exports = class ContextModuleFactory extends ModuleFactory {
|
|
382
395
|
});
|
383
396
|
};
|
384
397
|
|
385
|
-
|
386
|
-
|
398
|
+
const addSubDirectory = (ctx, dir, callback) =>
|
399
|
+
addDirectory(ctx, dir, addSubDirectory, callback);
|
400
|
+
|
401
|
+
const visitResource = (resource, callback) => {
|
402
|
+
if (typeof fs.realpath === "function") {
|
403
|
+
addDirectoryChecked(resource, resource, new Set(), callback);
|
404
|
+
} else {
|
405
|
+
addDirectory(resource, resource, addSubDirectory, callback);
|
406
|
+
}
|
407
|
+
};
|
408
|
+
|
409
|
+
if (typeof resource === "string") {
|
410
|
+
visitResource(resource, callback);
|
387
411
|
} else {
|
388
|
-
|
389
|
-
|
390
|
-
|
412
|
+
severalContexts = true;
|
413
|
+
asyncLib.map(resource, visitResource, (err, result) => {
|
414
|
+
if (err) return callback(err);
|
415
|
+
|
416
|
+
// result dependencies should have unique userRequest
|
417
|
+
// ordered by resolve result
|
418
|
+
const temp = new Set();
|
419
|
+
const res = [];
|
420
|
+
for (let i = 0; i < result.length; i++) {
|
421
|
+
const inner = result[i];
|
422
|
+
for (const el of inner) {
|
423
|
+
if (temp.has(el.userRequest)) continue;
|
424
|
+
res.push(el);
|
425
|
+
temp.add(el.userRequest);
|
426
|
+
}
|
427
|
+
}
|
428
|
+
callback(null, res);
|
429
|
+
});
|
391
430
|
}
|
392
431
|
}
|
393
432
|
};
|
package/lib/DelegatedModule.js
CHANGED
@@ -91,7 +91,7 @@ class DelegatedModule extends Module {
|
|
91
91
|
|
92
92
|
/**
|
93
93
|
* @param {NeedBuildContext} context context info
|
94
|
-
* @param {function(WebpackError=, boolean=): void} callback callback function, returns true, if the module needs a rebuild
|
94
|
+
* @param {function((WebpackError | null)=, boolean=): void} callback callback function, returns true, if the module needs a rebuild
|
95
95
|
* @returns {void}
|
96
96
|
*/
|
97
97
|
needBuild(context, callback) {
|
package/lib/Dependency.js
CHANGED
@@ -172,6 +172,16 @@ class Dependency {
|
|
172
172
|
this._loc = loc;
|
173
173
|
}
|
174
174
|
|
175
|
+
setLoc(startLine, startColumn, endLine, endColumn) {
|
176
|
+
this._locSL = startLine;
|
177
|
+
this._locSC = startColumn;
|
178
|
+
this._locEL = endLine;
|
179
|
+
this._locEC = endColumn;
|
180
|
+
this._locI = undefined;
|
181
|
+
this._locN = undefined;
|
182
|
+
this._loc = undefined;
|
183
|
+
}
|
184
|
+
|
175
185
|
/**
|
176
186
|
* @returns {string | null} an identifier to merge equal requests
|
177
187
|
*/
|
@@ -7,6 +7,7 @@
|
|
7
7
|
|
8
8
|
/** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
|
9
9
|
/** @typedef {import("./ChunkGraph")} ChunkGraph */
|
10
|
+
/** @typedef {import("./CodeGenerationResults")} CodeGenerationResults */
|
10
11
|
/** @typedef {import("./ConcatenationScope")} ConcatenationScope */
|
11
12
|
/** @typedef {import("./Dependency")} Dependency */
|
12
13
|
/** @typedef {import("./Dependency").RuntimeSpec} RuntimeSpec */
|
@@ -28,8 +29,16 @@
|
|
28
29
|
* @property {RuntimeSpec} runtime current runtimes, for which code is generated
|
29
30
|
* @property {InitFragment<GenerateContext>[]} initFragments mutable array of init fragments for the current module
|
30
31
|
* @property {ConcatenationScope=} concatenationScope when in a concatenated module, information about other concatenated modules
|
32
|
+
* @property {CodeGenerationResults} codeGenerationResults the code generation results
|
31
33
|
*/
|
32
34
|
|
35
|
+
/**
|
36
|
+
* @typedef {Object} CssDependencyTemplateContextExtras
|
37
|
+
* @property {Map<string, string>} cssExports the css exports
|
38
|
+
*/
|
39
|
+
|
40
|
+
/** @typedef {DependencyTemplateContext & CssDependencyTemplateContextExtras} CssDependencyTemplateContext */
|
41
|
+
|
33
42
|
class DependencyTemplate {
|
34
43
|
/* istanbul ignore next */
|
35
44
|
/**
|
@@ -57,7 +57,7 @@ class DependencyTemplates {
|
|
57
57
|
}
|
58
58
|
|
59
59
|
clone() {
|
60
|
-
const newInstance = new DependencyTemplates();
|
60
|
+
const newInstance = new DependencyTemplates(this._hashFunction);
|
61
61
|
newInstance._map = new Map(this._map);
|
62
62
|
newInstance._hash = this._hash;
|
63
63
|
return newInstance;
|
package/lib/DllModule.js
CHANGED
@@ -96,7 +96,7 @@ class DllModule extends Module {
|
|
96
96
|
|
97
97
|
/**
|
98
98
|
* @param {NeedBuildContext} context context info
|
99
|
-
* @param {function(WebpackError=, boolean=): void} callback callback function, returns true, if the module needs a rebuild
|
99
|
+
* @param {function((WebpackError | null)=, boolean=): void} callback callback function, returns true, if the module needs a rebuild
|
100
100
|
* @returns {void}
|
101
101
|
*/
|
102
102
|
needBuild(context, callback) {
|
@@ -8,6 +8,7 @@
|
|
8
8
|
const { ConcatSource, RawSource } = require("webpack-sources");
|
9
9
|
const ExternalModule = require("./ExternalModule");
|
10
10
|
const ModuleFilenameHelpers = require("./ModuleFilenameHelpers");
|
11
|
+
const RuntimeGlobals = require("./RuntimeGlobals");
|
11
12
|
const JavascriptModulesPlugin = require("./javascript/JavascriptModulesPlugin");
|
12
13
|
|
13
14
|
/** @typedef {import("webpack-sources").Source} Source */
|
@@ -77,7 +78,13 @@ class EvalDevToolModulePlugin {
|
|
77
78
|
.replace(/^\//, "")
|
78
79
|
);
|
79
80
|
const result = new RawSource(
|
80
|
-
`eval(${
|
81
|
+
`eval(${
|
82
|
+
compilation.outputOptions.trustedTypes
|
83
|
+
? `${RuntimeGlobals.createScript}(${JSON.stringify(
|
84
|
+
content + footer
|
85
|
+
)})`
|
86
|
+
: JSON.stringify(content + footer)
|
87
|
+
});`
|
81
88
|
);
|
82
89
|
cache.set(source, result);
|
83
90
|
return result;
|
@@ -95,6 +102,14 @@ class EvalDevToolModulePlugin {
|
|
95
102
|
hash.update("EvalDevToolModulePlugin");
|
96
103
|
hash.update("2");
|
97
104
|
});
|
105
|
+
if (compilation.outputOptions.trustedTypes) {
|
106
|
+
compilation.hooks.additionalModuleRuntimeRequirements.tap(
|
107
|
+
"EvalDevToolModulePlugin",
|
108
|
+
(module, set, context) => {
|
109
|
+
set.add(RuntimeGlobals.createScript);
|
110
|
+
}
|
111
|
+
);
|
112
|
+
}
|
98
113
|
});
|
99
114
|
}
|
100
115
|
}
|
@@ -8,6 +8,7 @@
|
|
8
8
|
const { ConcatSource, RawSource } = require("webpack-sources");
|
9
9
|
const ModuleFilenameHelpers = require("./ModuleFilenameHelpers");
|
10
10
|
const NormalModule = require("./NormalModule");
|
11
|
+
const RuntimeGlobals = require("./RuntimeGlobals");
|
11
12
|
const SourceMapDevToolModuleOptionsPlugin = require("./SourceMapDevToolModuleOptionsPlugin");
|
12
13
|
const JavascriptModulesPlugin = require("./javascript/JavascriptModulesPlugin");
|
13
14
|
const ConcatenatedModule = require("./optimize/ConcatenatedModule");
|
@@ -165,7 +166,15 @@ class EvalSourceMapDevToolPlugin {
|
|
165
166
|
) + `\n//# sourceURL=webpack-internal:///${moduleId}\n`; // workaround for chrome bug
|
166
167
|
|
167
168
|
return result(
|
168
|
-
new RawSource(
|
169
|
+
new RawSource(
|
170
|
+
`eval(${
|
171
|
+
compilation.outputOptions.trustedTypes
|
172
|
+
? `${RuntimeGlobals.createScript}(${JSON.stringify(
|
173
|
+
content + footer
|
174
|
+
)})`
|
175
|
+
: JSON.stringify(content + footer)
|
176
|
+
});`
|
177
|
+
)
|
169
178
|
);
|
170
179
|
}
|
171
180
|
);
|
@@ -181,6 +190,14 @@ class EvalSourceMapDevToolPlugin {
|
|
181
190
|
hash.update("EvalSourceMapDevToolPlugin");
|
182
191
|
hash.update("2");
|
183
192
|
});
|
193
|
+
if (compilation.outputOptions.trustedTypes) {
|
194
|
+
compilation.hooks.additionalModuleRuntimeRequirements.tap(
|
195
|
+
"EvalSourceMapDevToolPlugin",
|
196
|
+
(module, set, context) => {
|
197
|
+
set.add(RuntimeGlobals.createScript);
|
198
|
+
}
|
199
|
+
);
|
200
|
+
}
|
184
201
|
}
|
185
202
|
);
|
186
203
|
}
|
package/lib/ExportsInfo.js
CHANGED
@@ -291,15 +291,15 @@ class ExportsInfo {
|
|
291
291
|
}
|
292
292
|
}
|
293
293
|
for (const exportInfo of this._exports.values()) {
|
294
|
+
if (!canMangle && exportInfo.canMangleProvide !== false) {
|
295
|
+
exportInfo.canMangleProvide = false;
|
296
|
+
changed = true;
|
297
|
+
}
|
294
298
|
if (excludeExports && excludeExports.has(exportInfo.name)) continue;
|
295
299
|
if (exportInfo.provided !== true && exportInfo.provided !== null) {
|
296
300
|
exportInfo.provided = null;
|
297
301
|
changed = true;
|
298
302
|
}
|
299
|
-
if (!canMangle && exportInfo.canMangleProvide !== false) {
|
300
|
-
exportInfo.canMangleProvide = false;
|
301
|
-
changed = true;
|
302
|
-
}
|
303
303
|
if (targetKey) {
|
304
304
|
exportInfo.setTarget(targetKey, targetModule, [exportInfo.name], -1);
|
305
305
|
}
|