webpack 5.37.0 → 5.39.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 +5 -8
- package/bin/webpack.js +20 -5
- package/lib/AsyncDependencyToInitialChunkError.js +0 -2
- package/lib/CacheFacade.js +3 -3
- package/lib/CaseSensitiveModulesWarning.js +0 -2
- package/lib/Chunk.js +8 -5
- package/lib/ChunkRenderError.js +0 -2
- package/lib/CodeGenerationError.js +0 -2
- package/lib/CommentCompilationWarning.js +0 -2
- package/lib/Compilation.js +43 -55
- package/lib/Compiler.js +7 -4
- package/lib/ConcatenationScope.js +2 -1
- package/lib/ConcurrentCompilationError.js +0 -2
- package/lib/ContextModule.js +5 -4
- package/lib/ContextModuleFactory.js +3 -1
- package/lib/ContextReplacementPlugin.js +4 -3
- package/lib/DefinePlugin.js +16 -12
- package/lib/DllReferencePlugin.js +0 -2
- package/lib/EntryPlugin.js +3 -3
- package/lib/EvalSourceMapDevToolPlugin.js +3 -1
- package/lib/ExportsInfo.js +20 -13
- package/lib/FileSystemInfo.js +24 -30
- package/lib/FlagDependencyExportsPlugin.js +8 -7
- package/lib/FlagDependencyUsagePlugin.js +2 -4
- package/lib/HarmonyLinkingError.js +0 -2
- package/lib/HookWebpackError.js +0 -1
- package/lib/HotModuleReplacementPlugin.js +27 -32
- package/lib/InvalidDependenciesModuleWarning.js +0 -2
- package/lib/JavascriptMetaInfoPlugin.js +2 -1
- package/lib/MainTemplate.js +2 -3
- package/lib/ModuleBuildError.js +0 -2
- package/lib/ModuleDependencyError.js +0 -2
- package/lib/ModuleDependencyWarning.js +0 -2
- package/lib/ModuleError.js +0 -2
- package/lib/ModuleFilenameHelpers.js +4 -2
- package/lib/ModuleGraphConnection.js +6 -2
- package/lib/ModuleInfoHeaderPlugin.js +2 -3
- package/lib/ModuleNotFoundError.js +0 -2
- package/lib/ModuleParseError.js +0 -2
- package/lib/ModuleRestoreError.js +0 -2
- package/lib/ModuleStoreError.js +0 -2
- package/lib/ModuleWarning.js +0 -2
- package/lib/MultiCompiler.js +31 -27
- package/lib/NoModeWarning.js +0 -2
- package/lib/NormalModule.js +26 -8
- package/lib/NormalModuleFactory.js +2 -0
- package/lib/RecordIdsPlugin.js +5 -4
- package/lib/ResolverFactory.js +10 -7
- package/lib/SourceMapDevToolPlugin.js +13 -14
- package/lib/Template.js +4 -2
- package/lib/UnsupportedFeatureWarning.js +0 -2
- package/lib/WarnDeprecatedOptionPlugin.js +0 -2
- package/lib/Watching.js +91 -47
- package/lib/WebpackError.js +0 -2
- 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 +21 -10
- package/lib/config/normalization.js +8 -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/ContextElementDependency.js +6 -1
- package/lib/dependencies/CriticalDependencyWarning.js +0 -2
- 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 +3 -4
- package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +2 -3
- package/lib/dependencies/RequireEnsureDependency.js +3 -3
- package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +0 -2
- package/lib/dependencies/SystemPlugin.js +0 -2
- package/lib/dependencies/WorkerDependency.js +6 -6
- package/lib/dependencies/WorkerPlugin.js +18 -19
- package/lib/errors/BuildCycleError.js +0 -1
- package/lib/hmr/LazyCompilationPlugin.js +9 -5
- 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/performance/AssetsOverSizeLimitWarning.js +0 -2
- package/lib/performance/EntrypointsOverSizeLimitWarning.js +0 -2
- package/lib/performance/NoAsyncChunksWarning.js +0 -2
- package/lib/runtime/EnsureChunkRuntimeModule.js +9 -8
- package/lib/runtime/LoadScriptRuntimeModule.js +2 -3
- 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/identifier.js +2 -1
- 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/UnsupportedWebAssemblyFeatureError.js +0 -2
- package/lib/wasm-sync/WasmFinalizeExportsPlugin.js +5 -4
- package/lib/wasm-sync/WebAssemblyGenerator.js +89 -83
- package/lib/wasm-sync/WebAssemblyInInitialChunkError.js +0 -2
- 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/package.json +9 -6
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +76 -60
- package/types.d.ts +112 -262
- package/lib/util/DataURI.js +0 -32
package/lib/NormalModule.js
CHANGED
@@ -164,8 +164,6 @@ class NonErrorEmittedError extends WebpackError {
|
|
164
164
|
|
165
165
|
this.name = "NonErrorEmittedError";
|
166
166
|
this.message = "(Emitted value instead of an instance of Error) " + error;
|
167
|
-
|
168
|
-
Error.captureStackTrace(this, this.constructor);
|
169
167
|
}
|
170
168
|
}
|
171
169
|
|
@@ -219,6 +217,7 @@ class NormalModule extends Module {
|
|
219
217
|
* @param {string} options.rawRequest request without resolving
|
220
218
|
* @param {LoaderItem[]} options.loaders list of loaders
|
221
219
|
* @param {string} options.resource path + query of the real resource
|
220
|
+
* @param {Record<string, any>=} options.resourceResolveData resource resolve data
|
222
221
|
* @param {string | undefined} options.matchResource path + query of the matched resource (virtual)
|
223
222
|
* @param {Parser} options.parser the parser used
|
224
223
|
* @param {object} options.parserOptions the options of the parser used
|
@@ -234,6 +233,7 @@ class NormalModule extends Module {
|
|
234
233
|
rawRequest,
|
235
234
|
loaders,
|
236
235
|
resource,
|
236
|
+
resourceResolveData,
|
237
237
|
matchResource,
|
238
238
|
parser,
|
239
239
|
parserOptions,
|
@@ -260,6 +260,7 @@ class NormalModule extends Module {
|
|
260
260
|
this.generatorOptions = generatorOptions;
|
261
261
|
/** @type {string} */
|
262
262
|
this.resource = resource;
|
263
|
+
this.resourceResolveData = resourceResolveData;
|
263
264
|
/** @type {string | undefined} */
|
264
265
|
this.matchResource = matchResource;
|
265
266
|
/** @type {LoaderItem[]} */
|
@@ -276,6 +277,8 @@ class NormalModule extends Module {
|
|
276
277
|
this._source = null;
|
277
278
|
/** @private @type {Map<string, number> | undefined} **/
|
278
279
|
this._sourceSizes = undefined;
|
280
|
+
/** @private @type {Set<string>} */
|
281
|
+
this._sourceTypes = undefined;
|
279
282
|
|
280
283
|
// Cache
|
281
284
|
this._lastSuccessfulBuildMeta = {};
|
@@ -347,12 +350,19 @@ class NormalModule extends Module {
|
|
347
350
|
this.resource = m.resource;
|
348
351
|
this.matchResource = m.matchResource;
|
349
352
|
this.loaders = m.loaders;
|
353
|
+
this._sourceTypes = m._sourceTypes;
|
354
|
+
this._sourceSizes = m._sourceSizes;
|
350
355
|
}
|
351
356
|
|
352
357
|
/**
|
353
358
|
* Assuming this module is in the cache. Remove internal references to allow freeing some memory.
|
354
359
|
*/
|
355
360
|
cleanupForCache() {
|
361
|
+
// Make sure to cache types and sizes before cleanup
|
362
|
+
if (this._sourceTypes === undefined) this.getSourceTypes();
|
363
|
+
for (const type of this._sourceTypes) {
|
364
|
+
this.size(type);
|
365
|
+
}
|
356
366
|
super.cleanupForCache();
|
357
367
|
this.parser = undefined;
|
358
368
|
this.parserOptions = undefined;
|
@@ -390,6 +400,7 @@ class NormalModule extends Module {
|
|
390
400
|
this.type,
|
391
401
|
this.generatorOptions
|
392
402
|
);
|
403
|
+
// we assume the generator behaves identically and keep cached sourceTypes/Sizes
|
393
404
|
}
|
394
405
|
|
395
406
|
/**
|
@@ -765,7 +776,11 @@ class NormalModule extends Module {
|
|
765
776
|
},
|
766
777
|
(err, result) => {
|
767
778
|
// Cleanup loaderContext to avoid leaking memory in ICs
|
768
|
-
loaderContext._compilation =
|
779
|
+
loaderContext._compilation =
|
780
|
+
loaderContext._compiler =
|
781
|
+
loaderContext._module =
|
782
|
+
loaderContext.fs =
|
783
|
+
undefined;
|
769
784
|
|
770
785
|
if (!result) {
|
771
786
|
return processResult(
|
@@ -869,6 +884,7 @@ class NormalModule extends Module {
|
|
869
884
|
this._forceBuild = false;
|
870
885
|
this._source = null;
|
871
886
|
if (this._sourceSizes !== undefined) this._sourceSizes.clear();
|
887
|
+
this._sourceTypes = undefined;
|
872
888
|
this._ast = null;
|
873
889
|
this.error = null;
|
874
890
|
this.clearWarningsAndErrors();
|
@@ -887,7 +903,7 @@ class NormalModule extends Module {
|
|
887
903
|
assetsInfo: undefined
|
888
904
|
};
|
889
905
|
|
890
|
-
const startTime = Date.now();
|
906
|
+
const startTime = compilation.compiler.fsStartTime || Date.now();
|
891
907
|
|
892
908
|
return this.doBuild(options, compilation, resolver, fs, err => {
|
893
909
|
// if we have an error mark module as failed and exit
|
@@ -958,7 +974,8 @@ class NormalModule extends Module {
|
|
958
974
|
checkDependencies(this.buildInfo.missingDependencies);
|
959
975
|
checkDependencies(this.buildInfo.contextDependencies);
|
960
976
|
if (nonAbsoluteDependencies !== undefined) {
|
961
|
-
const InvalidDependenciesModuleWarning =
|
977
|
+
const InvalidDependenciesModuleWarning =
|
978
|
+
getInvalidDependenciesModuleWarning();
|
962
979
|
this.addWarning(
|
963
980
|
new InvalidDependenciesModuleWarning(this, nonAbsoluteDependencies)
|
964
981
|
);
|
@@ -1070,7 +1087,10 @@ class NormalModule extends Module {
|
|
1070
1087
|
* @returns {Set<string>} types available (do not mutate)
|
1071
1088
|
*/
|
1072
1089
|
getSourceTypes() {
|
1073
|
-
|
1090
|
+
if (this._sourceTypes === undefined) {
|
1091
|
+
this._sourceTypes = this.generator.getTypes(this);
|
1092
|
+
}
|
1093
|
+
return this._sourceTypes;
|
1074
1094
|
}
|
1075
1095
|
|
1076
1096
|
/**
|
@@ -1259,7 +1279,6 @@ class NormalModule extends Module {
|
|
1259
1279
|
const { write } = context;
|
1260
1280
|
// deserialize
|
1261
1281
|
write(this._source);
|
1262
|
-
write(this._sourceSizes);
|
1263
1282
|
write(this.error);
|
1264
1283
|
write(this._lastSuccessfulBuildMeta);
|
1265
1284
|
write(this._forceBuild);
|
@@ -1291,7 +1310,6 @@ class NormalModule extends Module {
|
|
1291
1310
|
deserialize(context) {
|
1292
1311
|
const { read } = context;
|
1293
1312
|
this._source = read();
|
1294
|
-
this._sourceSizes = read();
|
1295
1313
|
this.error = read();
|
1296
1314
|
this._lastSuccessfulBuildMeta = read();
|
1297
1315
|
this._forceBuild = read();
|
@@ -168,6 +168,7 @@ const unsafeCacheData = new WeakMap();
|
|
168
168
|
|
169
169
|
const ruleSetCompiler = new RuleSetCompiler([
|
170
170
|
new BasicMatcherRulePlugin("test", "resource"),
|
171
|
+
new BasicMatcherRulePlugin("scheme"),
|
171
172
|
new BasicMatcherRulePlugin("mimetype"),
|
172
173
|
new BasicMatcherRulePlugin("dependency"),
|
173
174
|
new BasicMatcherRulePlugin("include", "resource"),
|
@@ -443,6 +444,7 @@ class NormalModuleFactory extends ModuleFactory {
|
|
443
444
|
realResource: resourceData.path,
|
444
445
|
resourceQuery: resourceDataForRules.query,
|
445
446
|
resourceFragment: resourceDataForRules.fragment,
|
447
|
+
scheme,
|
446
448
|
mimetype: matchResourceData ? "" : resourceData.data.mimetype || "",
|
447
449
|
dependency: dependencyType,
|
448
450
|
descriptionData: matchResourceData
|
package/lib/RecordIdsPlugin.js
CHANGED
@@ -48,10 +48,11 @@ class RecordIdsPlugin {
|
|
48
48
|
apply(compiler) {
|
49
49
|
const portableIds = this.options.portableIds;
|
50
50
|
|
51
|
-
const makePathsRelative =
|
52
|
-
|
53
|
-
|
54
|
-
|
51
|
+
const makePathsRelative =
|
52
|
+
identifierUtils.makePathsRelative.bindContextCache(
|
53
|
+
compiler.context,
|
54
|
+
compiler.root
|
55
|
+
);
|
55
56
|
|
56
57
|
/**
|
57
58
|
* @param {Module} module the module
|
package/lib/ResolverFactory.js
CHANGED
@@ -42,9 +42,9 @@ const convertToResolveOptions = resolveOptionsWithDepType => {
|
|
42
42
|
...remaining,
|
43
43
|
plugins:
|
44
44
|
plugins &&
|
45
|
-
/** @type {ResolvePluginInstance[]} */ (
|
46
|
-
item => item !== "..."
|
47
|
-
)
|
45
|
+
/** @type {ResolvePluginInstance[]} */ (
|
46
|
+
plugins.filter(item => item !== "...")
|
47
|
+
)
|
48
48
|
};
|
49
49
|
|
50
50
|
if (!partialOptions.fileSystem) {
|
@@ -53,7 +53,10 @@ const convertToResolveOptions = resolveOptionsWithDepType => {
|
|
53
53
|
);
|
54
54
|
}
|
55
55
|
// These weird types validate that we checked all non-optional properties
|
56
|
-
const options =
|
56
|
+
const options =
|
57
|
+
/** @type {Partial<ResolveOptions> & Pick<ResolveOptions, "fileSystem">} */ (
|
58
|
+
partialOptions
|
59
|
+
);
|
57
60
|
|
58
61
|
return removeOperations(
|
59
62
|
resolveByProperty(options, "byDependency", dependencyType)
|
@@ -124,9 +127,9 @@ module.exports = class ResolverFactory {
|
|
124
127
|
const resolveOptions = convertToResolveOptions(
|
125
128
|
this.hooks.resolveOptions.for(type).call(resolveOptionsWithDepType)
|
126
129
|
);
|
127
|
-
const resolver = /** @type {ResolverWithOptions} */ (
|
128
|
-
resolveOptions
|
129
|
-
)
|
130
|
+
const resolver = /** @type {ResolverWithOptions} */ (
|
131
|
+
Factory.createResolver(resolveOptions)
|
132
|
+
);
|
130
133
|
if (!resolver) {
|
131
134
|
throw new Error("No resolver created");
|
132
135
|
}
|
@@ -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();
|
package/lib/WebpackError.js
CHANGED
@@ -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 {
|