webpack 5.36.2 → 5.38.1
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 +5 -8
- package/bin/webpack.js +0 -0
- package/lib/CacheFacade.js +3 -3
- package/lib/Chunk.js +10 -5
- package/lib/Compilation.js +45 -57
- package/lib/Compiler.js +9 -6
- package/lib/ConcatenationScope.js +2 -1
- package/lib/ContextModule.js +3 -3
- package/lib/ContextReplacementPlugin.js +4 -3
- package/lib/DefinePlugin.js +16 -12
- package/lib/EntryPlugin.js +4 -4
- package/lib/EvalSourceMapDevToolPlugin.js +3 -1
- package/lib/ExportsInfo.js +20 -13
- package/lib/FileSystemInfo.js +25 -31
- package/lib/FlagDependencyExportsPlugin.js +8 -7
- package/lib/FlagDependencyUsagePlugin.js +2 -4
- package/lib/HotModuleReplacementPlugin.js +27 -32
- package/lib/JavascriptMetaInfoPlugin.js +2 -1
- package/lib/MainTemplate.js +2 -3
- package/lib/ModuleFilenameHelpers.js +4 -2
- package/lib/ModuleGraphConnection.js +6 -2
- package/lib/ModuleInfoHeaderPlugin.js +2 -3
- package/lib/MultiCompiler.js +31 -27
- package/lib/NormalModule.js +42 -8
- package/lib/NormalModuleFactory.js +2 -0
- package/lib/RecordIdsPlugin.js +5 -4
- package/lib/ResolverFactory.js +10 -7
- package/lib/RuntimeGlobals.js +7 -0
- package/lib/RuntimePlugin.js +19 -1
- package/lib/SourceMapDevToolPlugin.js +14 -15
- package/lib/Template.js +4 -2
- package/lib/Watching.js +91 -47
- package/lib/asset/AssetGenerator.js +46 -29
- package/lib/asset/AssetModulesPlugin.js +1 -1
- package/lib/buildChunkGraph.js +21 -21
- package/lib/cache/PackFileCacheStrategy.js +12 -9
- package/lib/config/defaults.js +31 -10
- package/lib/config/normalization.js +16 -7
- package/lib/config/target.js +7 -2
- package/lib/debug/ProfilingPlugin.js +4 -3
- package/lib/dependencies/AMDRequireDependency.js +3 -3
- package/lib/dependencies/CommonJsExportRequireDependency.js +2 -3
- package/lib/dependencies/CommonJsExportsParserPlugin.js +3 -1
- package/lib/dependencies/CommonJsImportsParserPlugin.js +2 -4
- package/lib/dependencies/CommonJsPlugin.js +8 -7
- package/lib/dependencies/CommonJsRequireContextDependency.js +2 -1
- package/lib/dependencies/ContextDependencyHelpers.js +10 -8
- package/lib/dependencies/CreateScriptUrlDependency.js +54 -0
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +11 -13
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +2 -4
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +4 -11
- package/lib/dependencies/ImportDependency.js +3 -3
- package/lib/dependencies/ImportParserPlugin.js +2 -4
- package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +2 -3
- package/lib/dependencies/RequireEnsureDependency.js +3 -3
- package/lib/dependencies/WorkerDependency.js +6 -6
- package/lib/dependencies/WorkerPlugin.js +32 -20
- package/lib/hmr/LazyCompilationPlugin.js +6 -4
- package/lib/ids/HashedModuleIdsPlugin.js +3 -3
- package/lib/ids/OccurrenceModuleIdsPlugin.js +2 -3
- package/lib/index.js +5 -3
- package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +4 -6
- package/lib/javascript/CommonJsChunkFormatPlugin.js +2 -3
- package/lib/javascript/JavascriptGenerator.js +3 -1
- package/lib/javascript/JavascriptModulesPlugin.js +15 -23
- package/lib/javascript/JavascriptParser.js +10 -8
- package/lib/library/AssignLibraryPlugin.js +4 -2
- package/lib/node/NodeEnvironmentPlugin.js +1 -0
- package/lib/node/NodeWatchFileSystem.js +19 -4
- package/lib/optimize/AggressiveSplittingPlugin.js +5 -4
- package/lib/optimize/ConcatenatedModule.js +31 -27
- package/lib/optimize/FlagIncludedChunksPlugin.js +4 -6
- package/lib/optimize/InnerGraph.js +9 -11
- package/lib/optimize/InnerGraphPlugin.js +3 -1
- package/lib/optimize/ModuleConcatenationPlugin.js +7 -10
- package/lib/optimize/RealContentHashPlugin.js +14 -16
- package/lib/optimize/SideEffectsFlagPlugin.js +6 -5
- package/lib/optimize/SplitChunksPlugin.js +13 -15
- package/lib/runtime/CreateScriptUrlRuntimeModule.js +61 -0
- package/lib/runtime/EnsureChunkRuntimeModule.js +9 -8
- package/lib/runtime/LoadScriptRuntimeModule.js +12 -5
- package/lib/runtime/OnChunksLoadedRuntimeModule.js +38 -37
- package/lib/schemes/DataUriPlugin.js +21 -2
- package/lib/serialization/BinaryMiddleware.js +5 -3
- package/lib/serialization/FileMiddleware.js +3 -1
- package/lib/serialization/ObjectMiddleware.js +11 -7
- package/lib/stats/DefaultStatsFactoryPlugin.js +7 -7
- package/lib/stats/DefaultStatsPrinterPlugin.js +11 -9
- package/lib/stats/StatsFactory.js +2 -1
- package/lib/stats/StatsPrinter.js +3 -3
- package/lib/util/LazyBucketSortedSet.js +3 -3
- package/lib/util/cleverMerge.js +3 -1
- package/lib/util/comparators.js +13 -13
- package/lib/util/createHash.js +5 -4
- package/lib/util/fs.js +8 -8
- package/lib/util/identifier.js +2 -1
- package/lib/util/internalSerializables.js +2 -0
- package/lib/util/serialization.js +108 -59
- package/lib/validateSchema.js +5 -3
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +4 -4
- package/lib/wasm-sync/WasmFinalizeExportsPlugin.js +5 -4
- package/lib/wasm-sync/WebAssemblyGenerator.js +89 -83
- package/lib/wasm-sync/WebAssemblyModulesPlugin.js +2 -1
- package/lib/wasm-sync/WebAssemblyParser.js +6 -5
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +2 -4
- package/lib/webpack.js +11 -7
- package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +13 -1
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +14 -4
- package/package.json +10 -7
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +107 -60
- package/types.d.ts +480 -285
- package/lib/util/DataURI.js +0 -32
@@ -16,7 +16,6 @@ const createHash = require("./util/createHash");
|
|
16
16
|
const { relative, dirname } = require("./util/fs");
|
17
17
|
const { absolutify } = require("./util/identifier");
|
18
18
|
|
19
|
-
/** @typedef {import("source-map").RawSourceMap} SourceMap */
|
20
19
|
/** @typedef {import("webpack-sources").MapOptions} MapOptions */
|
21
20
|
/** @typedef {import("webpack-sources").Source} Source */
|
22
21
|
/** @typedef {import("../declarations/plugins/SourceMapDevToolPlugin").SourceMapDevToolPluginOptions} SourceMapDevToolPluginOptions */
|
@@ -26,6 +25,7 @@ const { absolutify } = require("./util/identifier");
|
|
26
25
|
/** @typedef {import("./Compilation").AssetInfo} AssetInfo */
|
27
26
|
/** @typedef {import("./Compiler")} Compiler */
|
28
27
|
/** @typedef {import("./Module")} Module */
|
28
|
+
/** @typedef {import("./NormalModule").SourceMap} SourceMap */
|
29
29
|
/** @typedef {import("./util/Hash")} Hash */
|
30
30
|
|
31
31
|
const validate = createSchemaValidation(
|
@@ -430,19 +430,20 @@ class SourceMapDevToolPlugin {
|
|
430
430
|
currentSourceMappingURLComment !== false &&
|
431
431
|
/\.css($|\?)/i.test(file)
|
432
432
|
) {
|
433
|
-
currentSourceMappingURLComment =
|
434
|
-
|
435
|
-
|
436
|
-
|
433
|
+
currentSourceMappingURLComment =
|
434
|
+
currentSourceMappingURLComment.replace(
|
435
|
+
/^\n\/\/(.*)$/,
|
436
|
+
"\n/*$1*/"
|
437
|
+
);
|
437
438
|
}
|
438
439
|
const sourceMapString = JSON.stringify(sourceMap);
|
439
440
|
if (sourceMapFilename) {
|
440
441
|
let filename = file;
|
441
442
|
const sourceMapContentHash =
|
442
443
|
usesContentHash &&
|
443
|
-
/** @type {string} */ (
|
444
|
-
.update(sourceMapString)
|
445
|
-
|
444
|
+
/** @type {string} */ (
|
445
|
+
createHash("md4").update(sourceMapString).digest("hex")
|
446
|
+
);
|
446
447
|
const pathParams = {
|
447
448
|
chunk,
|
448
449
|
filename: options.fileContext
|
@@ -454,13 +455,11 @@ class SourceMapDevToolPlugin {
|
|
454
455
|
: filename,
|
455
456
|
contentHash: sourceMapContentHash
|
456
457
|
};
|
457
|
-
const {
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
pathParams
|
463
|
-
);
|
458
|
+
const { path: sourceMapFile, info: sourceMapInfo } =
|
459
|
+
compilation.getPathWithInfo(
|
460
|
+
sourceMapFilename,
|
461
|
+
pathParams
|
462
|
+
);
|
464
463
|
const sourceMapUrl = options.publicPath
|
465
464
|
? options.publicPath + sourceMapFile
|
466
465
|
: relative(
|
package/lib/Template.js
CHANGED
@@ -413,5 +413,7 @@ class Template {
|
|
413
413
|
}
|
414
414
|
|
415
415
|
module.exports = Template;
|
416
|
-
module.exports.NUMBER_OF_IDENTIFIER_START_CHARS =
|
417
|
-
|
416
|
+
module.exports.NUMBER_OF_IDENTIFIER_START_CHARS =
|
417
|
+
NUMBER_OF_IDENTIFIER_START_CHARS;
|
418
|
+
module.exports.NUMBER_OF_IDENTIFIER_CONTINUATION_CHARS =
|
419
|
+
NUMBER_OF_IDENTIFIER_CONTINUATION_CHARS;
|
package/lib/Watching.js
CHANGED
@@ -57,16 +57,70 @@ class Watching {
|
|
57
57
|
this._needRecords = true;
|
58
58
|
this.watcher = undefined;
|
59
59
|
this.pausedWatcher = undefined;
|
60
|
+
/** @type {Set<string>} */
|
61
|
+
this._collectedChangedFiles = undefined;
|
62
|
+
/** @type {Set<string>} */
|
63
|
+
this._collectedRemovedFiles = undefined;
|
60
64
|
this._done = this._done.bind(this);
|
61
65
|
process.nextTick(() => {
|
62
66
|
if (this._initial) this._invalidate();
|
63
67
|
});
|
64
68
|
}
|
65
69
|
|
66
|
-
|
70
|
+
_mergeWithCollected(changedFiles, removedFiles) {
|
71
|
+
if (!changedFiles) return;
|
72
|
+
if (!this._collectedChangedFiles) {
|
73
|
+
this._collectedChangedFiles = new Set(changedFiles);
|
74
|
+
this._collectedRemovedFiles = new Set(removedFiles);
|
75
|
+
} else {
|
76
|
+
for (const file of changedFiles) {
|
77
|
+
this._collectedChangedFiles.add(file);
|
78
|
+
this._collectedRemovedFiles.delete(file);
|
79
|
+
}
|
80
|
+
for (const file of removedFiles) {
|
81
|
+
this._collectedChangedFiles.delete(file);
|
82
|
+
this._collectedRemovedFiles.add(file);
|
83
|
+
}
|
84
|
+
}
|
85
|
+
}
|
86
|
+
|
87
|
+
_go(fileTimeInfoEntries, contextTimeInfoEntries, changedFiles, removedFiles) {
|
67
88
|
this._initial = false;
|
68
89
|
this.startTime = Date.now();
|
69
90
|
this.running = true;
|
91
|
+
if (this.watcher) {
|
92
|
+
this.pausedWatcher = this.watcher;
|
93
|
+
this.lastWatcherStartTime = Date.now();
|
94
|
+
this.watcher.pause();
|
95
|
+
this.watcher = null;
|
96
|
+
} else if (!this.lastWatcherStartTime) {
|
97
|
+
this.lastWatcherStartTime = Date.now();
|
98
|
+
}
|
99
|
+
this.compiler.fsStartTime = Date.now();
|
100
|
+
this._mergeWithCollected(
|
101
|
+
changedFiles ||
|
102
|
+
(this.pausedWatcher &&
|
103
|
+
this.pausedWatcher.getAggregatedChanges &&
|
104
|
+
this.pausedWatcher.getAggregatedChanges()),
|
105
|
+
(this.compiler.removedFiles =
|
106
|
+
removedFiles ||
|
107
|
+
(this.pausedWatcher &&
|
108
|
+
this.pausedWatcher.getAggregatedRemovals &&
|
109
|
+
this.pausedWatcher.getAggregatedRemovals()))
|
110
|
+
);
|
111
|
+
|
112
|
+
this.compiler.modifiedFiles = this._collectedChangedFiles;
|
113
|
+
this._collectedChangedFiles = undefined;
|
114
|
+
this.compiler.removedFiles = this._collectedRemovedFiles;
|
115
|
+
this._collectedRemovedFiles = undefined;
|
116
|
+
|
117
|
+
this.compiler.fileTimestamps =
|
118
|
+
fileTimeInfoEntries ||
|
119
|
+
(this.pausedWatcher && this.pausedWatcher.getFileTimeInfoEntries());
|
120
|
+
this.compiler.contextTimestamps =
|
121
|
+
contextTimeInfoEntries ||
|
122
|
+
(this.pausedWatcher && this.pausedWatcher.getContextTimeInfoEntries());
|
123
|
+
|
70
124
|
const run = () => {
|
71
125
|
if (this.compiler.idle) {
|
72
126
|
return this.compiler.cache.endIdle(err => {
|
@@ -159,13 +213,16 @@ class Watching {
|
|
159
213
|
|
160
214
|
let stats = null;
|
161
215
|
|
162
|
-
const handleError = err => {
|
216
|
+
const handleError = (err, cbs) => {
|
163
217
|
this.compiler.hooks.failed.call(err);
|
164
218
|
this.compiler.cache.beginIdle();
|
165
219
|
this.compiler.idle = true;
|
166
220
|
this.handler(err, stats);
|
167
|
-
|
168
|
-
|
221
|
+
if (!cbs) {
|
222
|
+
cbs = this.callbacks;
|
223
|
+
this.callbacks = [];
|
224
|
+
}
|
225
|
+
for (const cb of cbs) cb(err);
|
169
226
|
};
|
170
227
|
|
171
228
|
if (
|
@@ -197,17 +254,19 @@ class Watching {
|
|
197
254
|
}
|
198
255
|
if (err) return handleError(err);
|
199
256
|
|
257
|
+
const cbs = this.callbacks;
|
258
|
+
this.callbacks = [];
|
200
259
|
logger.time("done hook");
|
201
260
|
this.compiler.hooks.done.callAsync(stats, err => {
|
202
261
|
logger.timeEnd("done hook");
|
203
|
-
if (err) return handleError(err);
|
262
|
+
if (err) return handleError(err, cbs);
|
204
263
|
this.handler(null, stats);
|
205
264
|
logger.time("storeBuildDependencies");
|
206
265
|
this.compiler.cache.storeBuildDependencies(
|
207
266
|
compilation.buildDependencies,
|
208
267
|
err => {
|
209
268
|
logger.timeEnd("storeBuildDependencies");
|
210
|
-
if (err) return handleError(err);
|
269
|
+
if (err) return handleError(err, cbs);
|
211
270
|
logger.time("beginIdle");
|
212
271
|
this.compiler.cache.beginIdle();
|
213
272
|
this.compiler.idle = true;
|
@@ -221,8 +280,7 @@ class Watching {
|
|
221
280
|
);
|
222
281
|
}
|
223
282
|
});
|
224
|
-
for (const cb of
|
225
|
-
this.callbacks.length = 0;
|
283
|
+
for (const cb of cbs) cb(null);
|
226
284
|
this.compiler.hooks.afterDone.call(stats);
|
227
285
|
}
|
228
286
|
);
|
@@ -241,7 +299,7 @@ class Watching {
|
|
241
299
|
files,
|
242
300
|
dirs,
|
243
301
|
missing,
|
244
|
-
this.
|
302
|
+
this.lastWatcherStartTime,
|
245
303
|
this.watchOptions,
|
246
304
|
(
|
247
305
|
err,
|
@@ -250,25 +308,20 @@ class Watching {
|
|
250
308
|
changedFiles,
|
251
309
|
removedFiles
|
252
310
|
) => {
|
253
|
-
this.pausedWatcher = this.watcher;
|
254
|
-
this.watcher = null;
|
255
311
|
if (err) {
|
256
312
|
this.compiler.modifiedFiles = undefined;
|
257
313
|
this.compiler.removedFiles = undefined;
|
258
314
|
this.compiler.fileTimestamps = undefined;
|
259
315
|
this.compiler.contextTimestamps = undefined;
|
316
|
+
this.compiler.fsStartTime = undefined;
|
260
317
|
return this.handler(err);
|
261
318
|
}
|
262
|
-
this.
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
this.watcher.pause();
|
269
|
-
this.watcher = null;
|
270
|
-
}
|
271
|
-
this._invalidate();
|
319
|
+
this._invalidate(
|
320
|
+
fileTimeInfoEntries,
|
321
|
+
contextTimeInfoEntries,
|
322
|
+
changedFiles,
|
323
|
+
removedFiles
|
324
|
+
);
|
272
325
|
this._onChange();
|
273
326
|
},
|
274
327
|
(fileName, changeTime) => {
|
@@ -293,33 +346,31 @@ class Watching {
|
|
293
346
|
this._invalidReported = true;
|
294
347
|
this.compiler.hooks.invalid.call(null, Date.now());
|
295
348
|
}
|
349
|
+
this._onChange();
|
296
350
|
this._invalidate();
|
297
351
|
}
|
298
352
|
|
299
|
-
_invalidate(
|
300
|
-
|
301
|
-
|
302
|
-
|
353
|
+
_invalidate(
|
354
|
+
fileTimeInfoEntries,
|
355
|
+
contextTimeInfoEntries,
|
356
|
+
changedFiles,
|
357
|
+
removedFiles
|
358
|
+
) {
|
359
|
+
if (this.suspended || (this._isBlocked() && (this.blocked = true))) {
|
360
|
+
this._mergeWithCollected(changedFiles, removedFiles);
|
303
361
|
return;
|
304
362
|
}
|
305
|
-
if (this.watcher) {
|
306
|
-
this.compiler.modifiedFiles =
|
307
|
-
this.watcher.getAggregatedChanges &&
|
308
|
-
this.watcher.getAggregatedChanges();
|
309
|
-
this.compiler.removedFiles =
|
310
|
-
this.watcher.getAggregatedRemovals &&
|
311
|
-
this.watcher.getAggregatedRemovals();
|
312
|
-
this.compiler.fileTimestamps = this.watcher.getFileTimeInfoEntries();
|
313
|
-
this.compiler.contextTimestamps = this.watcher.getContextTimeInfoEntries();
|
314
|
-
this.pausedWatcher = this.watcher;
|
315
|
-
this.watcher.pause();
|
316
|
-
this.watcher = null;
|
317
|
-
}
|
318
363
|
|
319
364
|
if (this.running) {
|
365
|
+
this._mergeWithCollected(changedFiles, removedFiles);
|
320
366
|
this.invalid = true;
|
321
367
|
} else {
|
322
|
-
this._go(
|
368
|
+
this._go(
|
369
|
+
fileTimeInfoEntries,
|
370
|
+
contextTimeInfoEntries,
|
371
|
+
changedFiles,
|
372
|
+
removedFiles
|
373
|
+
);
|
323
374
|
}
|
324
375
|
}
|
325
376
|
|
@@ -334,14 +385,6 @@ class Watching {
|
|
334
385
|
}
|
335
386
|
}
|
336
387
|
|
337
|
-
_checkUnblocked() {
|
338
|
-
if (this.blocked && !this._isBlocked()) {
|
339
|
-
this.blocked = false;
|
340
|
-
this._needWatcherInfo = true;
|
341
|
-
this._invalidate();
|
342
|
-
}
|
343
|
-
}
|
344
|
-
|
345
388
|
/**
|
346
389
|
* @param {Callback<void>} callback signals when the watcher is closed
|
347
390
|
* @returns {void}
|
@@ -362,6 +405,7 @@ class Watching {
|
|
362
405
|
this.compiler.removedFiles = undefined;
|
363
406
|
this.compiler.fileTimestamps = undefined;
|
364
407
|
this.compiler.contextTimestamps = undefined;
|
408
|
+
this.compiler.fsStartTime = undefined;
|
365
409
|
const shutdown = () => {
|
366
410
|
this.compiler.cache.shutdown(err => {
|
367
411
|
this.compiler.hooks.watchClose.call();
|
@@ -120,12 +120,33 @@ class AssetGenerator extends Generator {
|
|
120
120
|
}
|
121
121
|
);
|
122
122
|
} else {
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
123
|
+
/** @type {string | false | undefined} */
|
124
|
+
let encoding = this.dataUrlOptions.encoding;
|
125
|
+
if (encoding === undefined) {
|
126
|
+
if (
|
127
|
+
module.resourceResolveData &&
|
128
|
+
module.resourceResolveData.encoding !== undefined
|
129
|
+
) {
|
130
|
+
encoding = module.resourceResolveData.encoding;
|
131
|
+
}
|
132
|
+
}
|
133
|
+
if (encoding === undefined) {
|
134
|
+
encoding = "base64";
|
135
|
+
}
|
136
|
+
let ext;
|
137
|
+
let mimeType = this.dataUrlOptions.mimetype;
|
138
|
+
if (mimeType === undefined) {
|
139
|
+
ext = path.extname(module.nameForCondition());
|
140
|
+
if (
|
141
|
+
module.resourceResolveData &&
|
142
|
+
module.resourceResolveData.mimetype !== undefined
|
143
|
+
) {
|
144
|
+
mimeType = module.resourceResolveData.mimetype;
|
145
|
+
} else if (ext) {
|
146
|
+
mimeType = mimeTypes.lookup(ext);
|
147
|
+
}
|
148
|
+
}
|
149
|
+
if (typeof mimeType !== "string") {
|
129
150
|
throw new Error(
|
130
151
|
"DataUrl can't be generated automatically, " +
|
131
152
|
`because there is no mimetype for "${ext}" in mimetype database. ` +
|
@@ -170,9 +191,9 @@ class AssetGenerator extends Generator {
|
|
170
191
|
hash.update(runtimeTemplate.outputOptions.hashSalt);
|
171
192
|
}
|
172
193
|
hash.update(originalSource.buffer());
|
173
|
-
const fullHash = /** @type {string} */ (
|
174
|
-
runtimeTemplate.outputOptions.hashDigest
|
175
|
-
)
|
194
|
+
const fullHash = /** @type {string} */ (
|
195
|
+
hash.digest(runtimeTemplate.outputOptions.hashDigest)
|
196
|
+
);
|
176
197
|
const contentHash = fullHash.slice(
|
177
198
|
0,
|
178
199
|
runtimeTemplate.outputOptions.hashDigestLength
|
@@ -183,26 +204,9 @@ class AssetGenerator extends Generator {
|
|
183
204
|
module.matchResource || module.resource,
|
184
205
|
runtimeTemplate.compilation.compiler.root
|
185
206
|
).replace(/^\.\//, "");
|
186
|
-
let {
|
187
|
-
|
188
|
-
|
189
|
-
} = runtimeTemplate.compilation.getAssetPathWithInfo(
|
190
|
-
assetModuleFilename,
|
191
|
-
{
|
192
|
-
module,
|
193
|
-
runtime,
|
194
|
-
filename: sourceFilename,
|
195
|
-
chunkGraph,
|
196
|
-
contentHash
|
197
|
-
}
|
198
|
-
);
|
199
|
-
let publicPath;
|
200
|
-
if (this.publicPath) {
|
201
|
-
const {
|
202
|
-
path,
|
203
|
-
info
|
204
|
-
} = runtimeTemplate.compilation.getAssetPathWithInfo(
|
205
|
-
this.publicPath,
|
207
|
+
let { path: filename, info: assetInfo } =
|
208
|
+
runtimeTemplate.compilation.getAssetPathWithInfo(
|
209
|
+
assetModuleFilename,
|
206
210
|
{
|
207
211
|
module,
|
208
212
|
runtime,
|
@@ -211,6 +215,19 @@ class AssetGenerator extends Generator {
|
|
211
215
|
contentHash
|
212
216
|
}
|
213
217
|
);
|
218
|
+
let publicPath;
|
219
|
+
if (this.publicPath) {
|
220
|
+
const { path, info } =
|
221
|
+
runtimeTemplate.compilation.getAssetPathWithInfo(
|
222
|
+
this.publicPath,
|
223
|
+
{
|
224
|
+
module,
|
225
|
+
runtime,
|
226
|
+
filename: sourceFilename,
|
227
|
+
chunkGraph,
|
228
|
+
contentHash
|
229
|
+
}
|
230
|
+
);
|
214
231
|
publicPath = JSON.stringify(path);
|
215
232
|
assetInfo = mergeAssetInfo(assetInfo, info);
|
216
233
|
} else {
|
package/lib/buildChunkGraph.js
CHANGED
@@ -519,7 +519,8 @@ const visitModules = (
|
|
519
519
|
if (skipConnectionBuffer.length > 0) {
|
520
520
|
let { skippedModuleConnections } = chunkGroupInfo;
|
521
521
|
if (skippedModuleConnections === undefined) {
|
522
|
-
chunkGroupInfo.skippedModuleConnections = skippedModuleConnections =
|
522
|
+
chunkGroupInfo.skippedModuleConnections = skippedModuleConnections =
|
523
|
+
new Set();
|
523
524
|
}
|
524
525
|
for (let i = skipConnectionBuffer.length - 1; i >= 0; i--) {
|
525
526
|
skippedModuleConnections.add(skipConnectionBuffer[i]);
|
@@ -695,7 +696,8 @@ const visitModules = (
|
|
695
696
|
let resultingAvailableModules;
|
696
697
|
if (minAvailableModules.size > minAvailableModules.plus.size) {
|
697
698
|
// resultingAvailableModules = (modules of chunk) + (minAvailableModules + minAvailableModules.plus)
|
698
|
-
resultingAvailableModules =
|
699
|
+
resultingAvailableModules =
|
700
|
+
/** @type {Set<Module> & {plus: Set<Module>}} */ (new Set());
|
699
701
|
for (const module of minAvailableModules.plus)
|
700
702
|
minAvailableModules.add(module);
|
701
703
|
minAvailableModules.plus = EMPTY_SET;
|
@@ -703,9 +705,10 @@ const visitModules = (
|
|
703
705
|
chunkGroupInfo.minAvailableModulesOwned = false;
|
704
706
|
} else {
|
705
707
|
// resultingAvailableModules = (minAvailableModules + modules of chunk) + (minAvailableModules.plus)
|
706
|
-
resultingAvailableModules =
|
707
|
-
|
708
|
-
|
708
|
+
resultingAvailableModules =
|
709
|
+
/** @type {Set<Module> & {plus: Set<Module>}} */ (
|
710
|
+
new Set(minAvailableModules)
|
711
|
+
);
|
709
712
|
resultingAvailableModules.plus = minAvailableModules.plus;
|
710
713
|
}
|
711
714
|
|
@@ -715,7 +718,8 @@ const visitModules = (
|
|
715
718
|
resultingAvailableModules.add(m);
|
716
719
|
}
|
717
720
|
}
|
718
|
-
return (chunkGroupInfo.resultingAvailableModules =
|
721
|
+
return (chunkGroupInfo.resultingAvailableModules =
|
722
|
+
resultingAvailableModules);
|
719
723
|
};
|
720
724
|
|
721
725
|
const processConnectQueue = () => {
|
@@ -732,9 +736,8 @@ const visitModules = (
|
|
732
736
|
}
|
733
737
|
|
734
738
|
// 2. Calculate resulting available modules
|
735
|
-
const resultingAvailableModules =
|
736
|
-
chunkGroupInfo
|
737
|
-
);
|
739
|
+
const resultingAvailableModules =
|
740
|
+
calculateResultingAvailableModules(chunkGroupInfo);
|
738
741
|
|
739
742
|
const runtime = chunkGroupInfo.runtime;
|
740
743
|
|
@@ -800,9 +803,8 @@ const visitModules = (
|
|
800
803
|
if (!availableModules.has(m) && !availableModules.plus.has(m)) {
|
801
804
|
// We can't remove modules from the plus part
|
802
805
|
// so we need to merge plus into the normal part to allow modifying it
|
803
|
-
const iterator =
|
804
|
-
Symbol.iterator
|
805
|
-
]();
|
806
|
+
const iterator =
|
807
|
+
cachedMinAvailableModules.plus[Symbol.iterator]();
|
806
808
|
// fast forward add all modules until m
|
807
809
|
/** @type {IteratorResult<Module>} */
|
808
810
|
let it;
|
@@ -951,13 +953,12 @@ const visitModules = (
|
|
951
953
|
statForkedMergedModulesCountPlus += availableModules.plus.size;
|
952
954
|
// construct a new Set as intersection of cachedMinAvailableModules and availableModules
|
953
955
|
// we already know that all modules directly from cachedMinAvailableModules are in availableModules too
|
954
|
-
const newSet = /** @type {ModuleSetPlus} */ (
|
955
|
-
cachedMinAvailableModules
|
956
|
-
)
|
956
|
+
const newSet = /** @type {ModuleSetPlus} */ (
|
957
|
+
new Set(cachedMinAvailableModules)
|
958
|
+
);
|
957
959
|
newSet.plus = EMPTY_SET;
|
958
|
-
const iterator =
|
959
|
-
Symbol.iterator
|
960
|
-
]();
|
960
|
+
const iterator =
|
961
|
+
cachedMinAvailableModules.plus[Symbol.iterator]();
|
961
962
|
// fast forward add all modules until m
|
962
963
|
/** @type {IteratorResult<Module>} */
|
963
964
|
let it;
|
@@ -1018,9 +1019,8 @@ const visitModules = (
|
|
1018
1019
|
};
|
1019
1020
|
// combine minAvailableModules from all resultingAvailableModules
|
1020
1021
|
for (const source of info.availableSources) {
|
1021
|
-
const resultingAvailableModules =
|
1022
|
-
source
|
1023
|
-
);
|
1022
|
+
const resultingAvailableModules =
|
1023
|
+
calculateResultingAvailableModules(source);
|
1024
1024
|
mergeSet(resultingAvailableModules);
|
1025
1025
|
mergeSet(resultingAvailableModules.plus);
|
1026
1026
|
}
|
@@ -1041,7 +1041,8 @@ class PackFileCacheStrategy {
|
|
1041
1041
|
if (newBuildDependencies)
|
1042
1042
|
this.newBuildDependencies.addAll(newBuildDependencies);
|
1043
1043
|
this.resolveResults = resolveResults;
|
1044
|
-
this.resolveBuildDependenciesSnapshot =
|
1044
|
+
this.resolveBuildDependenciesSnapshot =
|
1045
|
+
resolveBuildDependenciesSnapshot;
|
1045
1046
|
return pack;
|
1046
1047
|
}
|
1047
1048
|
return new Pack(logger, this.maxAge);
|
@@ -1163,10 +1164,11 @@ class PackFileCacheStrategy {
|
|
1163
1164
|
);
|
1164
1165
|
}
|
1165
1166
|
if (this.resolveBuildDependenciesSnapshot) {
|
1166
|
-
this.resolveBuildDependenciesSnapshot =
|
1167
|
-
this.
|
1168
|
-
|
1169
|
-
|
1167
|
+
this.resolveBuildDependenciesSnapshot =
|
1168
|
+
this.fileSystemInfo.mergeSnapshots(
|
1169
|
+
this.resolveBuildDependenciesSnapshot,
|
1170
|
+
snapshot
|
1171
|
+
);
|
1170
1172
|
} else {
|
1171
1173
|
this.resolveBuildDependenciesSnapshot = snapshot;
|
1172
1174
|
}
|
@@ -1194,10 +1196,11 @@ class PackFileCacheStrategy {
|
|
1194
1196
|
this.logger.debug("Captured build dependencies");
|
1195
1197
|
|
1196
1198
|
if (this.buildSnapshot) {
|
1197
|
-
this.buildSnapshot =
|
1198
|
-
this.
|
1199
|
-
|
1200
|
-
|
1199
|
+
this.buildSnapshot =
|
1200
|
+
this.fileSystemInfo.mergeSnapshots(
|
1201
|
+
this.buildSnapshot,
|
1202
|
+
snapshot
|
1203
|
+
);
|
1201
1204
|
} else {
|
1202
1205
|
this.buildSnapshot = snapshot;
|
1203
1206
|
}
|
package/lib/config/defaults.js
CHANGED
@@ -318,9 +318,10 @@ const applyCacheDefaults = (cache, { name, mode, development }) => {
|
|
318
318
|
const applySnapshotDefaults = (snapshot, { production }) => {
|
319
319
|
A(snapshot, "managedPaths", () => {
|
320
320
|
if (process.versions.pnp === "3") {
|
321
|
-
const match =
|
322
|
-
|
323
|
-
|
321
|
+
const match =
|
322
|
+
/^(.+?)[\\/]cache[\\/]watchpack-npm-[^\\/]+\.zip[\\/]node_modules[\\/]/.exec(
|
323
|
+
require.resolve("watchpack")
|
324
|
+
);
|
324
325
|
if (match) {
|
325
326
|
return [path.resolve(match[1], "unplugged")];
|
326
327
|
}
|
@@ -337,16 +338,18 @@ const applySnapshotDefaults = (snapshot, { production }) => {
|
|
337
338
|
});
|
338
339
|
A(snapshot, "immutablePaths", () => {
|
339
340
|
if (process.versions.pnp === "1") {
|
340
|
-
const match =
|
341
|
-
|
342
|
-
|
341
|
+
const match =
|
342
|
+
/^(.+?[\\/]v4)[\\/]npm-watchpack-[^\\/]+-[\da-f]{40}[\\/]node_modules[\\/]/.exec(
|
343
|
+
require.resolve("watchpack")
|
344
|
+
);
|
343
345
|
if (match) {
|
344
346
|
return [match[1]];
|
345
347
|
}
|
346
348
|
} else if (process.versions.pnp === "3") {
|
347
|
-
const match =
|
348
|
-
|
349
|
-
|
349
|
+
const match =
|
350
|
+
/^(.+?)[\\/]watchpack-npm-[^\\/]+\.zip[\\/]node_modules[\\/]/.exec(
|
351
|
+
require.resolve("watchpack")
|
352
|
+
);
|
350
353
|
if (match) {
|
351
354
|
return [match[1]];
|
352
355
|
}
|
@@ -475,7 +478,15 @@ const applyModuleDefaults = (
|
|
475
478
|
},
|
476
479
|
{
|
477
480
|
dependency: "url",
|
478
|
-
|
481
|
+
oneOf: [
|
482
|
+
{
|
483
|
+
scheme: /^data$/,
|
484
|
+
type: "asset/inline"
|
485
|
+
},
|
486
|
+
{
|
487
|
+
type: "asset/resource"
|
488
|
+
}
|
489
|
+
]
|
479
490
|
}
|
480
491
|
];
|
481
492
|
if (asyncWebAssembly) {
|
@@ -732,6 +743,16 @@ const applyOutputDefaults = (
|
|
732
743
|
F(output.environment, "dynamicImport", () => tp && tp.dynamicImport);
|
733
744
|
F(output.environment, "module", () => tp && tp.module);
|
734
745
|
|
746
|
+
const { trustedTypes } = output;
|
747
|
+
if (trustedTypes) {
|
748
|
+
F(
|
749
|
+
trustedTypes,
|
750
|
+
"policyName",
|
751
|
+
() =>
|
752
|
+
output.uniqueName.replace(/[^a-zA-Z0-9\-#=_/@.%]+/g, "_") || "webpack"
|
753
|
+
);
|
754
|
+
}
|
755
|
+
|
735
756
|
/**
|
736
757
|
* @param {function(EntryDescription): void} fn iterator
|
737
758
|
* @returns {void}
|
@@ -92,9 +92,9 @@ const keyedNestedConfig = (value, fn, customKeys) => {
|
|
92
92
|
? {}
|
93
93
|
: Object.keys(value).reduce(
|
94
94
|
(obj, key) => (
|
95
|
-
(obj[key] = (
|
96
|
-
? customKeys[key]
|
97
|
-
|
95
|
+
(obj[key] = (
|
96
|
+
customKeys && key in customKeys ? customKeys[key] : fn
|
97
|
+
)(value[key])),
|
98
98
|
obj
|
99
99
|
),
|
100
100
|
/** @type {Record<string, R>} */ ({})
|
@@ -163,10 +163,10 @@ const getNormalizedWebpackOptions = config => {
|
|
163
163
|
config.entry === undefined
|
164
164
|
? { main: {} }
|
165
165
|
: typeof config.entry === "function"
|
166
|
-
? (
|
167
|
-
|
168
|
-
|
169
|
-
)
|
166
|
+
? (
|
167
|
+
fn => () =>
|
168
|
+
Promise.resolve().then(fn).then(getNormalizedEntryStatic)
|
169
|
+
)(config.entry)
|
170
170
|
: getNormalizedEntryStatic(config.entry),
|
171
171
|
experiments: cloneObject(config.experiments),
|
172
172
|
externals: config.externals,
|
@@ -338,6 +338,15 @@ const getNormalizedWebpackOptions = config => {
|
|
338
338
|
sourceMapFilename: output.sourceMapFilename,
|
339
339
|
sourcePrefix: output.sourcePrefix,
|
340
340
|
strictModuleExceptionHandling: output.strictModuleExceptionHandling,
|
341
|
+
trustedTypes: optionalNestedConfig(
|
342
|
+
output.trustedTypes,
|
343
|
+
trustedTypes => {
|
344
|
+
if (trustedTypes === true) return {};
|
345
|
+
if (typeof trustedTypes === "string")
|
346
|
+
return { policyName: trustedTypes };
|
347
|
+
return { ...trustedTypes };
|
348
|
+
}
|
349
|
+
),
|
341
350
|
uniqueName: output.uniqueName,
|
342
351
|
wasmLoading: output.wasmLoading,
|
343
352
|
webassemblyModuleFilename: output.webassemblyModuleFilename,
|