webpack 5.100.2 → 5.101.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.
- package/README.md +12 -10
- package/bin/webpack.js +7 -7
- package/lib/APIPlugin.js +12 -14
- package/lib/AutomaticPrefetchPlugin.js +2 -2
- package/lib/BannerPlugin.js +4 -4
- package/lib/Cache.js +1 -1
- package/lib/CacheFacade.js +7 -7
- package/lib/CaseSensitiveModulesWarning.js +2 -2
- package/lib/Chunk.js +3 -3
- package/lib/ChunkGraph.js +63 -18
- package/lib/ChunkGroup.js +4 -4
- package/lib/CleanPlugin.js +19 -53
- package/lib/CodeGenerationResults.js +3 -3
- package/lib/CompatibilityPlugin.js +6 -6
- package/lib/Compilation.js +168 -116
- package/lib/Compiler.js +37 -37
- package/lib/ConcatenationScope.js +39 -1
- package/lib/ConstPlugin.js +11 -11
- package/lib/ContextExclusionPlugin.js +3 -3
- package/lib/ContextModule.js +12 -11
- package/lib/ContextModuleFactory.js +11 -11
- package/lib/ContextReplacementPlugin.js +5 -5
- package/lib/DefinePlugin.js +24 -22
- package/lib/DelegatedModuleFactoryPlugin.js +1 -1
- package/lib/Dependency.js +2 -1
- package/lib/DllEntryPlugin.js +1 -1
- package/lib/DllReferencePlugin.js +1 -1
- package/lib/DynamicEntryPlugin.js +3 -3
- package/lib/EntryPlugin.js +1 -1
- package/lib/EnvironmentPlugin.js +1 -1
- package/lib/ErrorHelpers.js +2 -2
- package/lib/EvalDevToolModulePlugin.js +2 -2
- package/lib/EvalSourceMapDevToolPlugin.js +5 -5
- package/lib/ExportsInfo.js +9 -9
- package/lib/ExportsInfoApiPlugin.js +2 -2
- package/lib/ExternalModule.js +163 -48
- package/lib/ExternalModuleFactoryPlugin.js +2 -2
- package/lib/ExternalsPlugin.js +45 -0
- package/lib/FileSystemInfo.js +64 -61
- package/lib/FlagAllModulesAsUsedPlugin.js +2 -2
- package/lib/FlagDependencyExportsPlugin.js +7 -7
- package/lib/FlagDependencyUsagePlugin.js +4 -4
- package/lib/FlagEntryExportAsUsedPlugin.js +1 -1
- package/lib/HotModuleReplacementPlugin.js +27 -27
- package/lib/IgnorePlugin.js +3 -3
- package/lib/IgnoreWarningsPlugin.js +4 -4
- package/lib/InitFragment.js +6 -0
- package/lib/InvalidDependenciesModuleWarning.js +1 -1
- package/lib/JavascriptMetaInfoPlugin.js +1 -1
- package/lib/LibManifestPlugin.js +2 -2
- package/lib/LoaderOptionsPlugin.js +1 -1
- package/lib/LoaderTargetPlugin.js +2 -2
- package/lib/MainTemplate.js +1 -1
- package/lib/Module.js +3 -2
- package/lib/ModuleFilenameHelpers.js +3 -3
- package/lib/ModuleGraph.js +23 -38
- package/lib/ModuleInfoHeaderPlugin.js +3 -3
- package/lib/ModuleParseError.js +5 -3
- package/lib/ModuleTemplate.js +3 -2
- package/lib/MultiCompiler.js +29 -24
- package/lib/MultiStats.js +18 -13
- package/lib/MultiWatching.js +1 -1
- package/lib/NoEmitOnErrorsPlugin.js +2 -2
- package/lib/NodeStuffPlugin.js +27 -15
- package/lib/NormalModule.js +23 -23
- package/lib/NormalModuleFactory.js +23 -21
- package/lib/NormalModuleReplacementPlugin.js +3 -3
- package/lib/PrefetchPlugin.js +1 -1
- package/lib/ProgressPlugin.js +11 -11
- package/lib/ProvidePlugin.js +2 -2
- package/lib/RecordIdsPlugin.js +3 -3
- package/lib/ResolverFactory.js +3 -3
- package/lib/RuntimeGlobals.js +20 -0
- package/lib/RuntimePlugin.js +16 -16
- package/lib/RuntimeTemplate.js +35 -26
- package/lib/SizeFormatHelpers.js +1 -1
- package/lib/SourceMapDevToolModuleOptionsPlugin.js +4 -4
- package/lib/SourceMapDevToolPlugin.js +9 -9
- package/lib/Stats.js +2 -2
- package/lib/Template.js +1 -1
- package/lib/TemplatedPathPlugin.js +2 -2
- package/lib/UseStrictPlugin.js +1 -1
- package/lib/WarnCaseSensitiveModulesPlugin.js +1 -1
- package/lib/WarnDeprecatedOptionPlugin.js +1 -1
- package/lib/WarnNoModeSetPlugin.js +1 -1
- package/lib/WatchIgnorePlugin.js +2 -2
- package/lib/Watching.js +12 -14
- package/lib/WebpackIsIncludedPlugin.js +2 -2
- package/lib/WebpackOptionsApply.js +3 -3
- package/lib/asset/AssetGenerator.js +1 -1
- package/lib/asset/AssetModulesPlugin.js +6 -6
- package/lib/async-modules/AsyncModuleHelpers.js +1 -1
- package/lib/async-modules/AwaitDependenciesInitFragment.js +36 -24
- package/lib/async-modules/InferAsyncModulesPlugin.js +3 -3
- package/lib/buildChunkGraph.js +5 -5
- package/lib/cache/AddBuildDependenciesPlugin.js +1 -1
- package/lib/cache/IdleFileCachePlugin.js +5 -5
- package/lib/cache/PackFileCacheStrategy.js +20 -20
- package/lib/cache/ResolverCachePlugin.js +4 -4
- package/lib/cli.js +196 -14
- package/lib/config/browserslistTargetHandler.js +6 -6
- package/lib/config/defaults.js +23 -14
- package/lib/config/normalization.js +41 -38
- package/lib/config/target.js +4 -4
- package/lib/container/ContainerEntryModule.js +3 -3
- package/lib/container/ContainerPlugin.js +3 -3
- package/lib/container/ContainerReferencePlugin.js +3 -3
- package/lib/container/FallbackModule.js +1 -1
- package/lib/container/HoistContainerReferencesPlugin.js +7 -7
- package/lib/container/options.js +4 -4
- package/lib/css/CssGenerator.js +5 -3
- package/lib/css/CssLoadingRuntimeModule.js +1 -1
- package/lib/css/CssModulesPlugin.js +25 -22
- package/lib/css/CssParser.js +5 -5
- package/lib/css/walkCssTokens.js +9 -9
- package/lib/debug/ProfilingPlugin.js +5 -5
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +4 -4
- package/lib/dependencies/AMDPlugin.js +3 -3
- package/lib/dependencies/AMDRequireArrayDependency.js +1 -1
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +3 -3
- package/lib/dependencies/CommonJsExportRequireDependency.js +2 -2
- package/lib/dependencies/CommonJsExportsParserPlugin.js +12 -10
- package/lib/dependencies/CommonJsImportsParserPlugin.js +21 -19
- package/lib/dependencies/CommonJsPlugin.js +2 -2
- package/lib/dependencies/ContextDependency.js +1 -1
- package/lib/dependencies/ContextDependencyHelpers.js +3 -3
- package/lib/dependencies/CssIcssExportDependency.js +2 -2
- package/lib/dependencies/CssLocalIdentifierDependency.js +2 -2
- package/lib/dependencies/CssUrlDependency.js +4 -4
- package/lib/dependencies/DynamicExports.js +5 -5
- package/lib/dependencies/HarmonyAcceptDependency.js +91 -5
- package/lib/dependencies/HarmonyDetectionParserPlugin.js +2 -2
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +17 -13
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +7 -8
- package/lib/dependencies/HarmonyExportInitFragment.js +1 -1
- package/lib/dependencies/HarmonyExports.js +1 -1
- package/lib/dependencies/HarmonyImportDependency.js +28 -9
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +56 -48
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +4 -5
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +3 -4
- package/lib/dependencies/HarmonyModulesPlugin.js +2 -8
- package/lib/dependencies/HarmonyTopLevelThisParserPlugin.js +1 -1
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +4 -4
- package/lib/dependencies/ImportMetaPlugin.js +7 -7
- package/lib/dependencies/ImportParserPlugin.js +4 -4
- package/lib/dependencies/JsonExportsDependency.js +7 -2
- package/lib/dependencies/LoaderPlugin.js +4 -4
- package/lib/dependencies/ModuleDependency.js +2 -1
- package/lib/dependencies/ProvidedDependency.js +2 -2
- package/lib/dependencies/PureExpressionDependency.js +1 -1
- package/lib/dependencies/RequireContextDependencyParserPlugin.js +1 -1
- package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +1 -1
- package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +3 -3
- package/lib/dependencies/SystemPlugin.js +3 -3
- package/lib/dependencies/WorkerPlugin.js +5 -5
- package/lib/dependencies/getFunctionExpression.js +1 -1
- package/lib/esm/ExportWebpackRequireRuntimeModule.js +8 -1
- package/lib/esm/ModuleChunkFormatPlugin.js +35 -69
- package/lib/esm/ModuleChunkLoadingPlugin.js +3 -6
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +15 -11
- package/lib/formatLocation.js +2 -2
- package/lib/hmr/HotModuleReplacement.runtime.js +39 -27
- package/lib/hmr/JavascriptHotModuleReplacement.runtime.js +43 -32
- package/lib/hmr/JavascriptHotModuleReplacementHelper.js +1 -1
- package/lib/hmr/LazyCompilationPlugin.js +6 -6
- package/lib/hmr/lazyCompilationBackend.js +6 -6
- package/lib/ids/ChunkModuleIdRangePlugin.js +4 -4
- package/lib/ids/DeterministicChunkIdsPlugin.js +5 -4
- package/lib/ids/DeterministicModuleIdsPlugin.js +2 -2
- package/lib/ids/HashedModuleIdsPlugin.js +1 -1
- package/lib/ids/IdHelpers.js +9 -9
- package/lib/ids/NamedChunkIdsPlugin.js +5 -5
- package/lib/ids/NamedModuleIdsPlugin.js +2 -2
- package/lib/ids/NaturalChunkIdsPlugin.js +2 -2
- package/lib/ids/NaturalModuleIdsPlugin.js +1 -1
- package/lib/ids/OccurrenceChunkIdsPlugin.js +2 -2
- package/lib/ids/OccurrenceModuleIdsPlugin.js +4 -4
- package/lib/ids/SyncModuleIdsPlugin.js +4 -4
- package/lib/index.js +18 -6
- package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +1 -1
- package/lib/javascript/BasicEvaluatedExpression.js +3 -3
- package/lib/javascript/ChunkFormatHelpers.js +70 -0
- package/lib/javascript/CommonJsChunkFormatPlugin.js +10 -21
- package/lib/javascript/EnableChunkLoadingPlugin.js +1 -1
- package/lib/javascript/JavascriptGenerator.js +1 -1
- package/lib/javascript/JavascriptModulesPlugin.js +108 -54
- package/lib/javascript/JavascriptParser.js +80 -78
- package/lib/javascript/JavascriptParserHelpers.js +3 -3
- package/lib/javascript/StartupHelpers.js +2 -2
- package/lib/json/JsonGenerator.js +2 -2
- package/lib/json/JsonModulesPlugin.js +2 -2
- package/lib/library/AbstractLibraryPlugin.js +30 -3
- package/lib/library/AmdLibraryPlugin.js +3 -3
- package/lib/library/AssignLibraryPlugin.js +2 -2
- package/lib/library/EnableLibraryPlugin.js +2 -2
- package/lib/library/ModuleLibraryPlugin.js +49 -31
- package/lib/library/SystemLibraryPlugin.js +6 -4
- package/lib/library/UmdLibraryPlugin.js +14 -14
- package/lib/logging/createConsoleLogger.js +4 -4
- package/lib/logging/runtime.js +3 -3
- package/lib/logging/truncateArgs.js +4 -4
- package/lib/node/CommonJsChunkLoadingPlugin.js +2 -2
- package/lib/node/NodeEnvironmentPlugin.js +1 -1
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +16 -14
- package/lib/node/ReadFileCompileAsyncWasmPlugin.js +7 -7
- package/lib/node/ReadFileCompileWasmPlugin.js +7 -7
- package/lib/node/RequireChunkLoadingRuntimeModule.js +13 -6
- package/lib/node/nodeConsole.js +2 -2
- package/lib/optimize/AggressiveMergingPlugin.js +2 -2
- package/lib/optimize/AggressiveSplittingPlugin.js +10 -10
- package/lib/optimize/ConcatenatedModule.js +186 -77
- package/lib/optimize/EnsureChunkConditionsPlugin.js +2 -2
- package/lib/optimize/FlagIncludedChunksPlugin.js +2 -2
- package/lib/optimize/InnerGraph.js +5 -5
- package/lib/optimize/InnerGraphPlugin.js +14 -12
- package/lib/optimize/LimitChunkCountPlugin.js +5 -5
- package/lib/optimize/MangleExportsPlugin.js +5 -5
- package/lib/optimize/MergeDuplicateChunksPlugin.js +2 -2
- package/lib/optimize/MinChunkSizePlugin.js +3 -3
- package/lib/optimize/ModuleConcatenationPlugin.js +45 -38
- package/lib/optimize/RealContentHashPlugin.js +23 -23
- package/lib/optimize/RemoveEmptyChunksPlugin.js +2 -2
- package/lib/optimize/RemoveParentModulesPlugin.js +3 -3
- package/lib/optimize/RuntimeChunkPlugin.js +2 -2
- package/lib/optimize/SideEffectsFlagPlugin.js +5 -5
- package/lib/optimize/SplitChunksPlugin.js +20 -20
- package/lib/performance/AssetsOverSizeLimitWarning.js +1 -1
- package/lib/performance/EntrypointsOverSizeLimitWarning.js +2 -2
- package/lib/performance/SizeLimitsPlugin.js +4 -4
- package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +1 -1
- package/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js +3 -3
- package/lib/rules/BasicMatcherRulePlugin.js +1 -1
- package/lib/rules/RuleSetCompiler.js +10 -10
- package/lib/rules/UseEffectRulePlugin.js +2 -2
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +19 -15
- package/lib/runtime/GetMainFilenameRuntimeModule.js +1 -1
- package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +1 -1
- package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +1 -1
- package/lib/runtime/StartupChunkDependenciesPlugin.js +2 -2
- package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +3 -3
- package/lib/schemes/DataUriPlugin.js +3 -3
- package/lib/schemes/FileUriPlugin.js +1 -1
- package/lib/schemes/HttpUriPlugin.js +40 -36
- package/lib/schemes/VirtualUrlPlugin.js +1 -1
- package/lib/serialization/BinaryMiddleware.js +11 -11
- package/lib/serialization/FileMiddleware.js +18 -17
- package/lib/serialization/ObjectMiddleware.js +8 -8
- package/lib/serialization/Serializer.js +2 -2
- package/lib/serialization/SerializerMiddleware.js +2 -2
- package/lib/sharing/ConsumeSharedPlugin.js +4 -4
- package/lib/sharing/ProvideSharedPlugin.js +4 -4
- package/lib/sharing/SharePlugin.js +1 -1
- package/lib/sharing/resolveMatchedConfigs.js +1 -1
- package/lib/stats/DefaultStatsFactoryPlugin.js +85 -80
- package/lib/stats/DefaultStatsPresetPlugin.js +15 -15
- package/lib/stats/DefaultStatsPrinterPlugin.js +87 -87
- package/lib/stats/StatsFactory.js +7 -7
- package/lib/stats/StatsPrinter.js +9 -9
- package/lib/url/URLParserPlugin.js +5 -5
- package/lib/util/AsyncQueue.js +4 -4
- package/lib/util/IterableHelpers.js +2 -2
- package/lib/util/LazyBucketSortedSet.js +3 -3
- package/lib/util/SetHelpers.js +2 -2
- package/lib/util/StackedCacheMap.js +1 -1
- package/lib/util/StackedMap.js +1 -1
- package/lib/util/TupleSet.js +1 -1
- package/lib/util/WeakTupleMap.js +1 -1
- package/lib/util/cleverMerge.js +8 -8
- package/lib/util/comparators.js +10 -10
- package/lib/util/compileBooleanMatcher.js +20 -20
- package/lib/util/concatenate.js +3 -3
- package/lib/util/conventions.js +4 -4
- package/lib/util/create-schema-validation.js +1 -1
- package/lib/util/createHash.js +1 -1
- package/lib/util/deprecation.js +4 -4
- package/lib/util/deterministicGrouping.js +7 -7
- package/lib/util/findGraphRoots.js +1 -1
- package/lib/util/fs.js +4 -4
- package/lib/util/identifier.js +14 -14
- package/lib/util/magicComment.js +5 -1
- package/lib/util/memoize.js +1 -1
- package/lib/util/processAsyncTree.js +2 -2
- package/lib/util/propertyName.js +1 -1
- package/lib/util/removeBOM.js +1 -1
- package/lib/util/runtime.js +6 -6
- package/lib/util/semver.js +16 -16
- package/lib/util/serialization.js +5 -5
- package/lib/util/smartGrouping.js +1 -1
- package/lib/validateSchema.js +2 -2
- package/lib/wasm/EnableWasmLoadingPlugin.js +1 -1
- package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +1 -1
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +1 -1
- package/lib/wasm-async/UniversalCompileAsyncWasmPlugin.js +4 -4
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +13 -9
- package/lib/wasm-sync/WasmFinalizeExportsPlugin.js +2 -2
- package/lib/wasm-sync/WebAssemblyGenerator.js +16 -17
- package/lib/wasm-sync/WebAssemblyInInitialChunkError.js +4 -2
- package/lib/wasm-sync/WebAssemblyParser.js +2 -2
- package/lib/web/FetchCompileAsyncWasmPlugin.js +4 -4
- package/lib/web/FetchCompileWasmPlugin.js +4 -4
- package/lib/web/JsonpChunkLoadingPlugin.js +2 -2
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +1 -1
- package/lib/webpack.js +17 -12
- package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +2 -2
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +1 -1
- package/package.json +16 -16
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +4 -0
- package/types.d.ts +275 -64
|
@@ -59,8 +59,8 @@ class InnerGraphPlugin {
|
|
|
59
59
|
/**
|
|
60
60
|
* @param {Expression} sup sup
|
|
61
61
|
*/
|
|
62
|
-
const onUsageSuper = sup => {
|
|
63
|
-
InnerGraph.onUsage(parser.state, usedByExports => {
|
|
62
|
+
const onUsageSuper = (sup) => {
|
|
63
|
+
InnerGraph.onUsage(parser.state, (usedByExports) => {
|
|
64
64
|
switch (usedByExports) {
|
|
65
65
|
case undefined:
|
|
66
66
|
case true:
|
|
@@ -115,7 +115,7 @@ class InnerGraphPlugin {
|
|
|
115
115
|
|
|
116
116
|
// The following hooks are used during prewalking:
|
|
117
117
|
|
|
118
|
-
parser.hooks.preStatement.tap(PLUGIN_NAME, statement => {
|
|
118
|
+
parser.hooks.preStatement.tap(PLUGIN_NAME, (statement) => {
|
|
119
119
|
if (!InnerGraph.isEnabled(parser.state)) return;
|
|
120
120
|
|
|
121
121
|
if (
|
|
@@ -131,7 +131,7 @@ class InnerGraphPlugin {
|
|
|
131
131
|
}
|
|
132
132
|
});
|
|
133
133
|
|
|
134
|
-
parser.hooks.blockPreStatement.tap(PLUGIN_NAME, statement => {
|
|
134
|
+
parser.hooks.blockPreStatement.tap(PLUGIN_NAME, (statement) => {
|
|
135
135
|
if (!InnerGraph.isEnabled(parser.state)) return;
|
|
136
136
|
|
|
137
137
|
if (parser.scope.topLevelScope === true) {
|
|
@@ -250,7 +250,7 @@ class InnerGraphPlugin {
|
|
|
250
250
|
|
|
251
251
|
// The following hooks are called during walking:
|
|
252
252
|
|
|
253
|
-
parser.hooks.statement.tap(PLUGIN_NAME, statement => {
|
|
253
|
+
parser.hooks.statement.tap(PLUGIN_NAME, (statement) => {
|
|
254
254
|
if (!InnerGraph.isEnabled(parser.state)) return;
|
|
255
255
|
if (parser.scope.topLevelScope === true) {
|
|
256
256
|
InnerGraph.setTopLevelSymbol(parser.state, undefined);
|
|
@@ -260,7 +260,7 @@ class InnerGraphPlugin {
|
|
|
260
260
|
InnerGraph.setTopLevelSymbol(parser.state, fn);
|
|
261
261
|
const purePart = statementPurePart.get(statement);
|
|
262
262
|
if (purePart) {
|
|
263
|
-
InnerGraph.onUsage(parser.state, usedByExports => {
|
|
263
|
+
InnerGraph.onUsage(parser.state, (usedByExports) => {
|
|
264
264
|
switch (usedByExports) {
|
|
265
265
|
case undefined:
|
|
266
266
|
case true:
|
|
@@ -336,7 +336,7 @@ class InnerGraphPlugin {
|
|
|
336
336
|
) {
|
|
337
337
|
InnerGraph.setTopLevelSymbol(parser.state, fn);
|
|
338
338
|
if (element.type !== "MethodDefinition" && element.static) {
|
|
339
|
-
InnerGraph.onUsage(parser.state, usedByExports => {
|
|
339
|
+
InnerGraph.onUsage(parser.state, (usedByExports) => {
|
|
340
340
|
switch (usedByExports) {
|
|
341
341
|
case undefined:
|
|
342
342
|
case true:
|
|
@@ -378,7 +378,7 @@ class InnerGraphPlugin {
|
|
|
378
378
|
onUsageSuper(decl.init.superClass);
|
|
379
379
|
}
|
|
380
380
|
} else {
|
|
381
|
-
InnerGraph.onUsage(parser.state, usedByExports => {
|
|
381
|
+
InnerGraph.onUsage(parser.state, (usedByExports) => {
|
|
382
382
|
switch (usedByExports) {
|
|
383
383
|
case undefined:
|
|
384
384
|
case true:
|
|
@@ -433,10 +433,12 @@ class InnerGraphPlugin {
|
|
|
433
433
|
currentTopLevelSymbol || true
|
|
434
434
|
);
|
|
435
435
|
});
|
|
436
|
-
parser.hooks.assign
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
436
|
+
parser.hooks.assign
|
|
437
|
+
.for(topLevelSymbolTag)
|
|
438
|
+
.tap(PLUGIN_NAME, (expr) => {
|
|
439
|
+
if (!InnerGraph.isEnabled(parser.state)) return;
|
|
440
|
+
if (expr.operator === "=") return true;
|
|
441
|
+
});
|
|
440
442
|
};
|
|
441
443
|
normalModuleFactory.hooks.parser
|
|
442
444
|
.for(JAVASCRIPT_MODULE_TYPE_AUTO)
|
|
@@ -68,13 +68,13 @@ class LimitChunkCountPlugin {
|
|
|
68
68
|
*/
|
|
69
69
|
apply(compiler) {
|
|
70
70
|
const options = this.options;
|
|
71
|
-
compiler.hooks.compilation.tap(PLUGIN_NAME, compilation => {
|
|
71
|
+
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
|
|
72
72
|
compilation.hooks.optimizeChunks.tap(
|
|
73
73
|
{
|
|
74
74
|
name: PLUGIN_NAME,
|
|
75
75
|
stage: STAGE_ADVANCED
|
|
76
76
|
},
|
|
77
|
-
chunks => {
|
|
77
|
+
(chunks) => {
|
|
78
78
|
const chunkGraph = compilation.chunkGraph;
|
|
79
79
|
const maxChunks = options.maxChunks;
|
|
80
80
|
if (!maxChunks) return;
|
|
@@ -95,7 +95,7 @@ class LimitChunkCountPlugin {
|
|
|
95
95
|
/** @type {LazyBucketSortedSet<ChunkCombination, number>} */
|
|
96
96
|
const combinations = new LazyBucketSortedSet(
|
|
97
97
|
// Layer 1: ordered by largest size benefit
|
|
98
|
-
c => c.sizeDiff,
|
|
98
|
+
(c) => c.sizeDiff,
|
|
99
99
|
(a, b) => b - a,
|
|
100
100
|
|
|
101
101
|
// Layer 2: ordered by smallest combined size
|
|
@@ -103,7 +103,7 @@ class LimitChunkCountPlugin {
|
|
|
103
103
|
* @param {ChunkCombination} c combination
|
|
104
104
|
* @returns {number} integrated size
|
|
105
105
|
*/
|
|
106
|
-
c => c.integratedSize,
|
|
106
|
+
(c) => c.integratedSize,
|
|
107
107
|
/**
|
|
108
108
|
* @param {number} a a
|
|
109
109
|
* @param {number} b b
|
|
@@ -116,7 +116,7 @@ class LimitChunkCountPlugin {
|
|
|
116
116
|
* @param {ChunkCombination} c combination
|
|
117
117
|
* @returns {number} position difference
|
|
118
118
|
*/
|
|
119
|
-
c => c.bIdx - c.aIdx,
|
|
119
|
+
(c) => c.bIdx - c.aIdx,
|
|
120
120
|
/**
|
|
121
121
|
* @param {number} a a
|
|
122
122
|
* @param {number} b b
|
|
@@ -22,7 +22,7 @@ const { compareSelect, compareStringsNumeric } = require("../util/comparators");
|
|
|
22
22
|
* @param {ExportsInfo} exportsInfo exports info
|
|
23
23
|
* @returns {boolean} mangle is possible
|
|
24
24
|
*/
|
|
25
|
-
const canMangle = exportsInfo => {
|
|
25
|
+
const canMangle = (exportsInfo) => {
|
|
26
26
|
if (exportsInfo.otherExportsInfo.getUsed(undefined) !== UsageState.Unused) {
|
|
27
27
|
return false;
|
|
28
28
|
}
|
|
@@ -36,7 +36,7 @@ const canMangle = exportsInfo => {
|
|
|
36
36
|
};
|
|
37
37
|
|
|
38
38
|
// Sort by name
|
|
39
|
-
const comparator = compareSelect(e => e.name, compareStringsNumeric);
|
|
39
|
+
const comparator = compareSelect((e) => e.name, compareStringsNumeric);
|
|
40
40
|
/**
|
|
41
41
|
* @param {boolean} deterministic use deterministic names
|
|
42
42
|
* @param {ExportsInfo} exportsInfo exports info
|
|
@@ -100,7 +100,7 @@ const mangleExportsInfo = (deterministic, exportsInfo, isNamespace) => {
|
|
|
100
100
|
if (deterministic) {
|
|
101
101
|
assignDeterministicIds(
|
|
102
102
|
mangleableExports,
|
|
103
|
-
e => e.name,
|
|
103
|
+
(e) => e.name,
|
|
104
104
|
comparator,
|
|
105
105
|
(e, id) => {
|
|
106
106
|
const name = numberToIdentifier(id);
|
|
@@ -160,9 +160,9 @@ class MangleExportsPlugin {
|
|
|
160
160
|
*/
|
|
161
161
|
apply(compiler) {
|
|
162
162
|
const { _deterministic: deterministic } = this;
|
|
163
|
-
compiler.hooks.compilation.tap(PLUGIN_NAME, compilation => {
|
|
163
|
+
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
|
|
164
164
|
const moduleGraph = compilation.moduleGraph;
|
|
165
|
-
compilation.hooks.optimizeCodeGeneration.tap(PLUGIN_NAME, modules => {
|
|
165
|
+
compilation.hooks.optimizeCodeGeneration.tap(PLUGIN_NAME, (modules) => {
|
|
166
166
|
if (compilation.moduleMemCaches) {
|
|
167
167
|
throw new Error(
|
|
168
168
|
"optimization.mangleExports can't be used with cacheUnaffected as export mangling is a global effect"
|
|
@@ -38,13 +38,13 @@ class MergeDuplicateChunksPlugin {
|
|
|
38
38
|
* @returns {void}
|
|
39
39
|
*/
|
|
40
40
|
apply(compiler) {
|
|
41
|
-
compiler.hooks.compilation.tap(PLUGIN_NAME, compilation => {
|
|
41
|
+
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
|
|
42
42
|
compilation.hooks.optimizeChunks.tap(
|
|
43
43
|
{
|
|
44
44
|
name: PLUGIN_NAME,
|
|
45
45
|
stage: this.options.stage
|
|
46
46
|
},
|
|
47
|
-
chunks => {
|
|
47
|
+
(chunks) => {
|
|
48
48
|
const { chunkGraph, moduleGraph } = compilation;
|
|
49
49
|
|
|
50
50
|
// remember already tested chunks for performance
|
|
@@ -40,13 +40,13 @@ class MinChunkSizePlugin {
|
|
|
40
40
|
apply(compiler) {
|
|
41
41
|
const options = this.options;
|
|
42
42
|
const minChunkSize = options.minChunkSize;
|
|
43
|
-
compiler.hooks.compilation.tap(PLUGIN_NAME, compilation => {
|
|
43
|
+
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
|
|
44
44
|
compilation.hooks.optimizeChunks.tap(
|
|
45
45
|
{
|
|
46
46
|
name: PLUGIN_NAME,
|
|
47
47
|
stage: STAGE_ADVANCED
|
|
48
48
|
},
|
|
49
|
-
chunks => {
|
|
49
|
+
(chunks) => {
|
|
50
50
|
const chunkGraph = compilation.chunkGraph;
|
|
51
51
|
const equalOptions = {
|
|
52
52
|
chunkOverhead: 1,
|
|
@@ -81,7 +81,7 @@ class MinChunkSizePlugin {
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
const sortedSizeFilteredExtendedPairCombinations = combinations
|
|
84
|
-
.map(pair => {
|
|
84
|
+
.map((pair) => {
|
|
85
85
|
// extend combination pairs with size and integrated size
|
|
86
86
|
const a = chunkSizesMap.get(pair[0]);
|
|
87
87
|
const b = chunkSizesMap.get(pair[1]);
|
|
@@ -46,7 +46,7 @@ const ConcatenatedModule = require("./ConcatenatedModule");
|
|
|
46
46
|
* @param {string} msg message
|
|
47
47
|
* @returns {string} formatted message
|
|
48
48
|
*/
|
|
49
|
-
const formatBailoutReason = msg => `ModuleConcatenation bailout: ${msg}`;
|
|
49
|
+
const formatBailoutReason = (msg) => `ModuleConcatenation bailout: ${msg}`;
|
|
50
50
|
|
|
51
51
|
const PLUGIN_NAME = "ModuleConcatenationPlugin";
|
|
52
52
|
|
|
@@ -58,7 +58,7 @@ class ModuleConcatenationPlugin {
|
|
|
58
58
|
*/
|
|
59
59
|
apply(compiler) {
|
|
60
60
|
const { _backCompat: backCompat } = compiler;
|
|
61
|
-
compiler.hooks.compilation.tap(PLUGIN_NAME, compilation => {
|
|
61
|
+
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
|
|
62
62
|
if (compilation.moduleMemCaches) {
|
|
63
63
|
throw new Error(
|
|
64
64
|
"optimization.concatenateModules can't be used with cacheUnaffected as module concatenation is a global effect"
|
|
@@ -78,7 +78,7 @@ class ModuleConcatenationPlugin {
|
|
|
78
78
|
.getOptimizationBailout(module)
|
|
79
79
|
.push(
|
|
80
80
|
typeof reason === "function"
|
|
81
|
-
? rs => formatBailoutReason(reason(rs))
|
|
81
|
+
? (rs) => formatBailoutReason(reason(rs))
|
|
82
82
|
: formatBailoutReason(reason)
|
|
83
83
|
);
|
|
84
84
|
};
|
|
@@ -107,7 +107,7 @@ class ModuleConcatenationPlugin {
|
|
|
107
107
|
* @param {Module | ((requestShortener: RequestShortener) => string)} problem the problem
|
|
108
108
|
* @returns {(requestShortener: RequestShortener) => string} the reason
|
|
109
109
|
*/
|
|
110
|
-
const formatBailoutWarning = (module, problem) => requestShortener => {
|
|
110
|
+
const formatBailoutWarning = (module, problem) => (requestShortener) => {
|
|
111
111
|
if (typeof problem === "function") {
|
|
112
112
|
return formatBailoutReason(
|
|
113
113
|
`Cannot concat with ${module.readableIdentifier(
|
|
@@ -149,6 +149,7 @@ class ModuleConcatenationPlugin {
|
|
|
149
149
|
chunkGraph,
|
|
150
150
|
moduleGraph
|
|
151
151
|
};
|
|
152
|
+
const deferEnabled = compilation.options.experiments.deferImport;
|
|
152
153
|
logger.time("select relevant modules");
|
|
153
154
|
for (const module of modules) {
|
|
154
155
|
let canBeRoot = true;
|
|
@@ -182,7 +183,7 @@ class ModuleConcatenationPlugin {
|
|
|
182
183
|
const exportsInfo = moduleGraph.getExportsInfo(module);
|
|
183
184
|
const relevantExports = exportsInfo.getRelevantExports(undefined);
|
|
184
185
|
const unknownReexports = relevantExports.filter(
|
|
185
|
-
exportInfo =>
|
|
186
|
+
(exportInfo) =>
|
|
186
187
|
exportInfo.isReexport() && !exportInfo.getTarget(moduleGraph)
|
|
187
188
|
);
|
|
188
189
|
if (unknownReexports.length > 0) {
|
|
@@ -190,7 +191,7 @@ class ModuleConcatenationPlugin {
|
|
|
190
191
|
module,
|
|
191
192
|
`Reexports in this module do not have a static target (${Array.from(
|
|
192
193
|
unknownReexports,
|
|
193
|
-
exportInfo =>
|
|
194
|
+
(exportInfo) =>
|
|
194
195
|
`${
|
|
195
196
|
exportInfo.name || "other exports"
|
|
196
197
|
}: ${exportInfo.getUsedInfo()}`
|
|
@@ -201,14 +202,14 @@ class ModuleConcatenationPlugin {
|
|
|
201
202
|
|
|
202
203
|
// Root modules must have a static list of exports
|
|
203
204
|
const unknownProvidedExports = relevantExports.filter(
|
|
204
|
-
exportInfo => exportInfo.provided !== true
|
|
205
|
+
(exportInfo) => exportInfo.provided !== true
|
|
205
206
|
);
|
|
206
207
|
if (unknownProvidedExports.length > 0) {
|
|
207
208
|
setBailoutReason(
|
|
208
209
|
module,
|
|
209
210
|
`List of module exports is dynamic (${Array.from(
|
|
210
211
|
unknownProvidedExports,
|
|
211
|
-
exportInfo =>
|
|
212
|
+
(exportInfo) =>
|
|
212
213
|
`${
|
|
213
214
|
exportInfo.name || "other exports"
|
|
214
215
|
}: ${exportInfo.getProvidedInfo()} and ${exportInfo.getUsedInfo()}`
|
|
@@ -223,7 +224,7 @@ class ModuleConcatenationPlugin {
|
|
|
223
224
|
canBeInner = false;
|
|
224
225
|
}
|
|
225
226
|
|
|
226
|
-
if (moduleGraph.isDeferred(module)) {
|
|
227
|
+
if (deferEnabled && moduleGraph.isDeferred(module)) {
|
|
227
228
|
setInnerBailoutReason(module, "Module is deferred");
|
|
228
229
|
canBeInner = false;
|
|
229
230
|
}
|
|
@@ -277,7 +278,7 @@ class ModuleConcatenationPlugin {
|
|
|
277
278
|
chunkRuntime = mergeRuntimeOwned(chunkRuntime, r);
|
|
278
279
|
}
|
|
279
280
|
const exportsInfo = moduleGraph.getExportsInfo(currentRoot);
|
|
280
|
-
const filteredRuntime = filterRuntime(chunkRuntime, r =>
|
|
281
|
+
const filteredRuntime = filterRuntime(chunkRuntime, (r) =>
|
|
281
282
|
exportsInfo.isModuleUsed(r)
|
|
282
283
|
);
|
|
283
284
|
const activeRuntime =
|
|
@@ -407,7 +408,7 @@ class ModuleConcatenationPlugin {
|
|
|
407
408
|
(null),
|
|
408
409
|
/** @type {EXPECTED_ANY} */
|
|
409
410
|
(null),
|
|
410
|
-
err => {
|
|
411
|
+
(err) => {
|
|
411
412
|
if (err) {
|
|
412
413
|
if (!err.module) {
|
|
413
414
|
err.module = newModule;
|
|
@@ -441,7 +442,7 @@ class ModuleConcatenationPlugin {
|
|
|
441
442
|
moduleGraph.copyOutgoingModuleConnections(
|
|
442
443
|
m,
|
|
443
444
|
newModule,
|
|
444
|
-
c =>
|
|
445
|
+
(c) =>
|
|
445
446
|
c.originModule === m &&
|
|
446
447
|
!(
|
|
447
448
|
c.dependency instanceof HarmonyImportDependency &&
|
|
@@ -477,14 +478,18 @@ class ModuleConcatenationPlugin {
|
|
|
477
478
|
// remove module from chunk
|
|
478
479
|
chunkGraph.replaceModule(rootModule, newModule);
|
|
479
480
|
// replace module references with the concatenated module
|
|
480
|
-
moduleGraph.moveModuleConnections(
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
481
|
+
moduleGraph.moveModuleConnections(
|
|
482
|
+
rootModule,
|
|
483
|
+
newModule,
|
|
484
|
+
(c) => {
|
|
485
|
+
const otherModule =
|
|
486
|
+
c.module === rootModule ? c.originModule : c.module;
|
|
487
|
+
const innerConnection =
|
|
488
|
+
c.dependency instanceof HarmonyImportDependency &&
|
|
489
|
+
modules.has(/** @type {Module} */ (otherModule));
|
|
490
|
+
return !innerConnection;
|
|
491
|
+
}
|
|
492
|
+
);
|
|
488
493
|
// add concatenated module to the compilation
|
|
489
494
|
compilation.modules.add(newModule);
|
|
490
495
|
|
|
@@ -493,7 +498,7 @@ class ModuleConcatenationPlugin {
|
|
|
493
498
|
|
|
494
499
|
build();
|
|
495
500
|
},
|
|
496
|
-
err => {
|
|
501
|
+
(err) => {
|
|
497
502
|
logger.timeEnd("create concatenated modules");
|
|
498
503
|
process.nextTick(callback.bind(null, err));
|
|
499
504
|
}
|
|
@@ -532,7 +537,7 @@ class ModuleConcatenationPlugin {
|
|
|
532
537
|
);
|
|
533
538
|
|
|
534
539
|
if (
|
|
535
|
-
importedNames.every(i =>
|
|
540
|
+
importedNames.every((i) =>
|
|
536
541
|
Array.isArray(i) ? i.length > 0 : i.name.length > 0
|
|
537
542
|
) ||
|
|
538
543
|
Array.isArray(moduleGraph.getProvidedExports(module))
|
|
@@ -592,22 +597,22 @@ class ModuleConcatenationPlugin {
|
|
|
592
597
|
// Module must be in the correct chunks
|
|
593
598
|
const missingChunks = [
|
|
594
599
|
...chunkGraph.getModuleChunksIterable(config.rootModule)
|
|
595
|
-
].filter(chunk => !chunkGraph.isModuleInChunk(module, chunk));
|
|
600
|
+
].filter((chunk) => !chunkGraph.isModuleInChunk(module, chunk));
|
|
596
601
|
if (missingChunks.length > 0) {
|
|
597
602
|
/**
|
|
598
603
|
* @param {RequestShortener} requestShortener request shortener
|
|
599
604
|
* @returns {string} problem description
|
|
600
605
|
*/
|
|
601
|
-
const problem = requestShortener => {
|
|
606
|
+
const problem = (requestShortener) => {
|
|
602
607
|
const missingChunksList = [
|
|
603
608
|
...new Set(
|
|
604
|
-
missingChunks.map(chunk => chunk.name || "unnamed chunk(s)")
|
|
609
|
+
missingChunks.map((chunk) => chunk.name || "unnamed chunk(s)")
|
|
605
610
|
)
|
|
606
611
|
].sort();
|
|
607
612
|
const chunks = [
|
|
608
613
|
...new Set(
|
|
609
614
|
[...chunkGraph.getModuleChunksIterable(module)].map(
|
|
610
|
-
chunk => chunk.name || "unnamed chunk(s)"
|
|
615
|
+
(chunk) => chunk.name || "unnamed chunk(s)"
|
|
611
616
|
)
|
|
612
617
|
)
|
|
613
618
|
].sort();
|
|
@@ -631,7 +636,7 @@ class ModuleConcatenationPlugin {
|
|
|
631
636
|
incomingConnections.get(null) || incomingConnections.get(undefined);
|
|
632
637
|
if (incomingConnectionsFromNonModules) {
|
|
633
638
|
const activeNonModulesConnections =
|
|
634
|
-
incomingConnectionsFromNonModules.filter(connection =>
|
|
639
|
+
incomingConnectionsFromNonModules.filter((connection) =>
|
|
635
640
|
// We are not interested in inactive connections
|
|
636
641
|
// or connections without dependency
|
|
637
642
|
connection.isActive(runtime)
|
|
@@ -641,9 +646,11 @@ class ModuleConcatenationPlugin {
|
|
|
641
646
|
* @param {RequestShortener} requestShortener request shortener
|
|
642
647
|
* @returns {string} problem description
|
|
643
648
|
*/
|
|
644
|
-
const problem = requestShortener => {
|
|
649
|
+
const problem = (requestShortener) => {
|
|
645
650
|
const importingExplanations = new Set(
|
|
646
|
-
activeNonModulesConnections
|
|
651
|
+
activeNonModulesConnections
|
|
652
|
+
.map((c) => c.explanation)
|
|
653
|
+
.filter(Boolean)
|
|
647
654
|
);
|
|
648
655
|
const explanations = [...importingExplanations].sort();
|
|
649
656
|
return `Module ${module.readableIdentifier(
|
|
@@ -676,7 +683,7 @@ class ModuleConcatenationPlugin {
|
|
|
676
683
|
if (!intersectRuntime(runtime, originRuntime)) continue;
|
|
677
684
|
|
|
678
685
|
// We are not interested in inactive connections
|
|
679
|
-
const activeConnections = connections.filter(connection =>
|
|
686
|
+
const activeConnections = connections.filter((connection) =>
|
|
680
687
|
connection.isActive(runtime)
|
|
681
688
|
);
|
|
682
689
|
if (activeConnections.length > 0) {
|
|
@@ -688,7 +695,7 @@ class ModuleConcatenationPlugin {
|
|
|
688
695
|
const incomingModules = [...incomingConnectionsFromModules.keys()];
|
|
689
696
|
|
|
690
697
|
// Module must be in the same chunks like the referencing module
|
|
691
|
-
const otherChunkModules = incomingModules.filter(originModule => {
|
|
698
|
+
const otherChunkModules = incomingModules.filter((originModule) => {
|
|
692
699
|
for (const chunk of chunkGraph.getModuleChunksIterable(
|
|
693
700
|
config.rootModule
|
|
694
701
|
)) {
|
|
@@ -703,9 +710,9 @@ class ModuleConcatenationPlugin {
|
|
|
703
710
|
* @param {RequestShortener} requestShortener request shortener
|
|
704
711
|
* @returns {string} problem description
|
|
705
712
|
*/
|
|
706
|
-
const problem = requestShortener => {
|
|
713
|
+
const problem = (requestShortener) => {
|
|
707
714
|
const names = otherChunkModules
|
|
708
|
-
.map(m => m.readableIdentifier(requestShortener))
|
|
715
|
+
.map((m) => m.readableIdentifier(requestShortener))
|
|
709
716
|
.sort();
|
|
710
717
|
return `Module ${module.readableIdentifier(
|
|
711
718
|
requestShortener
|
|
@@ -722,7 +729,7 @@ class ModuleConcatenationPlugin {
|
|
|
722
729
|
const nonHarmonyConnections = new Map();
|
|
723
730
|
for (const [originModule, connections] of incomingConnectionsFromModules) {
|
|
724
731
|
const selected = connections.filter(
|
|
725
|
-
connection =>
|
|
732
|
+
(connection) =>
|
|
726
733
|
!connection.dependency ||
|
|
727
734
|
!(connection.dependency instanceof HarmonyImportDependency)
|
|
728
735
|
);
|
|
@@ -735,7 +742,7 @@ class ModuleConcatenationPlugin {
|
|
|
735
742
|
* @param {RequestShortener} requestShortener request shortener
|
|
736
743
|
* @returns {string} problem description
|
|
737
744
|
*/
|
|
738
|
-
const problem = requestShortener => {
|
|
745
|
+
const problem = (requestShortener) => {
|
|
739
746
|
const names = [...nonHarmonyConnections]
|
|
740
747
|
.map(
|
|
741
748
|
([originModule, connections]) =>
|
|
@@ -744,7 +751,7 @@ class ModuleConcatenationPlugin {
|
|
|
744
751
|
)} (referenced with ${[
|
|
745
752
|
...new Set(
|
|
746
753
|
connections
|
|
747
|
-
.map(c => c.dependency && c.dependency.type)
|
|
754
|
+
.map((c) => c.dependency && c.dependency.type)
|
|
748
755
|
.filter(Boolean)
|
|
749
756
|
)
|
|
750
757
|
]
|
|
@@ -774,7 +781,7 @@ class ModuleConcatenationPlugin {
|
|
|
774
781
|
/** @type {false | RuntimeSpec} */
|
|
775
782
|
let currentRuntimeCondition = false;
|
|
776
783
|
for (const connection of connections) {
|
|
777
|
-
const runtimeCondition = filterRuntime(runtime, runtime =>
|
|
784
|
+
const runtimeCondition = filterRuntime(runtime, (runtime) =>
|
|
778
785
|
connection.isTargetActive(runtime)
|
|
779
786
|
);
|
|
780
787
|
if (runtimeCondition === false) continue;
|
|
@@ -796,7 +803,7 @@ class ModuleConcatenationPlugin {
|
|
|
796
803
|
* @param {RequestShortener} requestShortener request shortener
|
|
797
804
|
* @returns {string} problem description
|
|
798
805
|
*/
|
|
799
|
-
const problem = requestShortener =>
|
|
806
|
+
const problem = (requestShortener) =>
|
|
800
807
|
`Module ${module.readableIdentifier(
|
|
801
808
|
requestShortener
|
|
802
809
|
)} is runtime-dependent referenced by these modules: ${Array.from(
|
|
@@ -61,7 +61,7 @@ const mapAndDeduplicateBuffers = (input, fn) => {
|
|
|
61
61
|
* @param {string} str String to quote
|
|
62
62
|
* @returns {string} Escaped string
|
|
63
63
|
*/
|
|
64
|
-
const quoteMeta = str => str.replace(/[-[\]\\/{}()*+?.^$|]/g, "\\$&");
|
|
64
|
+
const quoteMeta = (str) => str.replace(/[-[\]\\/{}()*+?.^$|]/g, "\\$&");
|
|
65
65
|
|
|
66
66
|
const cachedSourceMap = new WeakMap();
|
|
67
67
|
|
|
@@ -69,7 +69,7 @@ const cachedSourceMap = new WeakMap();
|
|
|
69
69
|
* @param {Source} source source
|
|
70
70
|
* @returns {CachedSource} cached source
|
|
71
71
|
*/
|
|
72
|
-
const toCachedSource = source => {
|
|
72
|
+
const toCachedSource = (source) => {
|
|
73
73
|
if (source instanceof CachedSource) {
|
|
74
74
|
return source;
|
|
75
75
|
}
|
|
@@ -150,7 +150,7 @@ class RealContentHashPlugin {
|
|
|
150
150
|
* @returns {void}
|
|
151
151
|
*/
|
|
152
152
|
apply(compiler) {
|
|
153
|
-
compiler.hooks.compilation.tap(PLUGIN_NAME, compilation => {
|
|
153
|
+
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
|
|
154
154
|
const cacheAnalyse = compilation.getCache(
|
|
155
155
|
"RealContentHashPlugin|analyse"
|
|
156
156
|
);
|
|
@@ -205,7 +205,7 @@ class RealContentHashPlugin {
|
|
|
205
205
|
"g"
|
|
206
206
|
);
|
|
207
207
|
await Promise.all(
|
|
208
|
-
assetsWithInfo.map(async asset => {
|
|
208
|
+
assetsWithInfo.map(async (asset) => {
|
|
209
209
|
const { name, source, content, hashes } = asset;
|
|
210
210
|
if (Buffer.isBuffer(content)) {
|
|
211
211
|
asset.referencedHashes = EMPTY_SET;
|
|
@@ -238,10 +238,10 @@ class RealContentHashPlugin {
|
|
|
238
238
|
* @param {string} hash the hash
|
|
239
239
|
* @returns {undefined | ReferencedHashes} the referenced hashes
|
|
240
240
|
*/
|
|
241
|
-
const getDependencies = hash => {
|
|
241
|
+
const getDependencies = (hash) => {
|
|
242
242
|
const assets = hashToAssets.get(hash);
|
|
243
243
|
if (!assets) {
|
|
244
|
-
const referencingAssets = assetsWithInfo.filter(asset =>
|
|
244
|
+
const referencingAssets = assetsWithInfo.filter((asset) =>
|
|
245
245
|
/** @type {ReferencedHashes} */ (asset.referencedHashes).has(
|
|
246
246
|
hash
|
|
247
247
|
)
|
|
@@ -252,7 +252,7 @@ An asset was cached with a reference to another asset (${hash}) that's not in th
|
|
|
252
252
|
Either the asset was incorrectly cached, or the referenced asset should also be restored from cache.
|
|
253
253
|
Referenced by:
|
|
254
254
|
${referencingAssets
|
|
255
|
-
.map(a => {
|
|
255
|
+
.map((a) => {
|
|
256
256
|
const match = new RegExp(`.{0,20}${quoteMeta(hash)}.{0,20}`).exec(
|
|
257
257
|
a.content
|
|
258
258
|
);
|
|
@@ -281,11 +281,11 @@ ${referencingAssets
|
|
|
281
281
|
* @param {string} hash the hash
|
|
282
282
|
* @returns {string} the hash info
|
|
283
283
|
*/
|
|
284
|
-
const hashInfo = hash => {
|
|
284
|
+
const hashInfo = (hash) => {
|
|
285
285
|
const assets = hashToAssets.get(hash);
|
|
286
286
|
return `${hash} (${Array.from(
|
|
287
287
|
/** @type {AssetInfoForRealContentHash[]} */ (assets),
|
|
288
|
-
a => a.name
|
|
288
|
+
(a) => a.name
|
|
289
289
|
)})`;
|
|
290
290
|
};
|
|
291
291
|
/** @type {Set<string>} */
|
|
@@ -323,26 +323,26 @@ ${referencingAssets
|
|
|
323
323
|
* @param {AssetInfoForRealContentHash} asset asset info
|
|
324
324
|
* @returns {Etag} etag
|
|
325
325
|
*/
|
|
326
|
-
const getEtag = asset =>
|
|
326
|
+
const getEtag = (asset) =>
|
|
327
327
|
cacheGenerate.mergeEtags(
|
|
328
328
|
cacheGenerate.getLazyHashedEtag(asset.source),
|
|
329
329
|
Array.from(
|
|
330
330
|
/** @type {ReferencedHashes} */ (asset.referencedHashes),
|
|
331
|
-
hash => hashToNewHash.get(hash)
|
|
331
|
+
(hash) => hashToNewHash.get(hash)
|
|
332
332
|
).join("|")
|
|
333
333
|
);
|
|
334
334
|
/**
|
|
335
335
|
* @param {AssetInfoForRealContentHash} asset asset info
|
|
336
336
|
* @returns {Promise<void>}
|
|
337
337
|
*/
|
|
338
|
-
const computeNewContent = asset => {
|
|
338
|
+
const computeNewContent = (asset) => {
|
|
339
339
|
if (asset.contentComputePromise) return asset.contentComputePromise;
|
|
340
340
|
return (asset.contentComputePromise = (async () => {
|
|
341
341
|
if (
|
|
342
342
|
/** @type {OwnHashes} */ (asset.ownHashes).size > 0 ||
|
|
343
343
|
[
|
|
344
344
|
.../** @type {ReferencedHashes} */ (asset.referencedHashes)
|
|
345
|
-
].some(hash => hashToNewHash.get(hash) !== hash)
|
|
345
|
+
].some((hash) => hashToNewHash.get(hash) !== hash)
|
|
346
346
|
) {
|
|
347
347
|
const identifier = asset.name;
|
|
348
348
|
const etag = getEtag(asset);
|
|
@@ -352,7 +352,7 @@ ${referencingAssets
|
|
|
352
352
|
() => {
|
|
353
353
|
const newContent = asset.content.replace(
|
|
354
354
|
hashRegExp,
|
|
355
|
-
hash => /** @type {string} */ (hashToNewHash.get(hash))
|
|
355
|
+
(hash) => /** @type {string} */ (hashToNewHash.get(hash))
|
|
356
356
|
);
|
|
357
357
|
return new RawSource(newContent);
|
|
358
358
|
}
|
|
@@ -364,7 +364,7 @@ ${referencingAssets
|
|
|
364
364
|
* @param {AssetInfoForRealContentHash} asset asset info
|
|
365
365
|
* @returns {Promise<void>}
|
|
366
366
|
*/
|
|
367
|
-
const computeNewContentWithoutOwn = asset => {
|
|
367
|
+
const computeNewContentWithoutOwn = (asset) => {
|
|
368
368
|
if (asset.contentComputeWithoutOwnPromise) {
|
|
369
369
|
return asset.contentComputeWithoutOwnPromise;
|
|
370
370
|
}
|
|
@@ -373,7 +373,7 @@ ${referencingAssets
|
|
|
373
373
|
/** @type {OwnHashes} */ (asset.ownHashes).size > 0 ||
|
|
374
374
|
[
|
|
375
375
|
.../** @type {ReferencedHashes} */ (asset.referencedHashes)
|
|
376
|
-
].some(hash => hashToNewHash.get(hash) !== hash)
|
|
376
|
+
].some((hash) => hashToNewHash.get(hash) !== hash)
|
|
377
377
|
) {
|
|
378
378
|
const identifier = `${asset.name}|without-own`;
|
|
379
379
|
const etag = getEtag(asset);
|
|
@@ -383,7 +383,7 @@ ${referencingAssets
|
|
|
383
383
|
() => {
|
|
384
384
|
const newContent = asset.content.replace(
|
|
385
385
|
hashRegExp,
|
|
386
|
-
hash => {
|
|
386
|
+
(hash) => {
|
|
387
387
|
if (
|
|
388
388
|
/** @type {OwnHashes} */
|
|
389
389
|
(asset.ownHashes).has(hash)
|
|
@@ -399,20 +399,20 @@ ${referencingAssets
|
|
|
399
399
|
}
|
|
400
400
|
})());
|
|
401
401
|
};
|
|
402
|
-
const comparator = compareSelect(a => a.name, compareStrings);
|
|
402
|
+
const comparator = compareSelect((a) => a.name, compareStrings);
|
|
403
403
|
for (const oldHash of hashesInOrder) {
|
|
404
404
|
const assets =
|
|
405
405
|
/** @type {AssetInfoForRealContentHash[]} */
|
|
406
406
|
(hashToAssets.get(oldHash));
|
|
407
407
|
assets.sort(comparator);
|
|
408
408
|
await Promise.all(
|
|
409
|
-
assets.map(asset =>
|
|
409
|
+
assets.map((asset) =>
|
|
410
410
|
/** @type {OwnHashes} */ (asset.ownHashes).has(oldHash)
|
|
411
411
|
? computeNewContentWithoutOwn(asset)
|
|
412
412
|
: computeNewContent(asset)
|
|
413
413
|
)
|
|
414
414
|
);
|
|
415
|
-
const assetsContent = mapAndDeduplicateBuffers(assets, asset => {
|
|
415
|
+
const assetsContent = mapAndDeduplicateBuffers(assets, (asset) => {
|
|
416
416
|
if (/** @type {OwnHashes} */ (asset.ownHashes).has(oldHash)) {
|
|
417
417
|
return asset.newSourceWithoutOwn
|
|
418
418
|
? asset.newSourceWithoutOwn.buffer()
|
|
@@ -437,18 +437,18 @@ ${referencingAssets
|
|
|
437
437
|
hashToNewHash.set(oldHash, newHash);
|
|
438
438
|
}
|
|
439
439
|
await Promise.all(
|
|
440
|
-
assetsWithInfo.map(async asset => {
|
|
440
|
+
assetsWithInfo.map(async (asset) => {
|
|
441
441
|
await computeNewContent(asset);
|
|
442
442
|
const newName = asset.name.replace(
|
|
443
443
|
hashRegExp,
|
|
444
|
-
hash => /** @type {string} */ (hashToNewHash.get(hash))
|
|
444
|
+
(hash) => /** @type {string} */ (hashToNewHash.get(hash))
|
|
445
445
|
);
|
|
446
446
|
|
|
447
447
|
const infoUpdate = {};
|
|
448
448
|
const hash = /** @type {string} */ (asset.info.contenthash);
|
|
449
449
|
infoUpdate.contenthash = Array.isArray(hash)
|
|
450
450
|
? hash.map(
|
|
451
|
-
hash => /** @type {string} */ (hashToNewHash.get(hash))
|
|
451
|
+
(hash) => /** @type {string} */ (hashToNewHash.get(hash))
|
|
452
452
|
)
|
|
453
453
|
: /** @type {string} */ (hashToNewHash.get(hash));
|
|
454
454
|
|
|
@@ -19,12 +19,12 @@ class RemoveEmptyChunksPlugin {
|
|
|
19
19
|
* @returns {void}
|
|
20
20
|
*/
|
|
21
21
|
apply(compiler) {
|
|
22
|
-
compiler.hooks.compilation.tap(PLUGIN_NAME, compilation => {
|
|
22
|
+
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
|
|
23
23
|
/**
|
|
24
24
|
* @param {Iterable<Chunk>} chunks the chunks array
|
|
25
25
|
* @returns {void}
|
|
26
26
|
*/
|
|
27
|
-
const handler = chunks => {
|
|
27
|
+
const handler = (chunks) => {
|
|
28
28
|
const chunkGraph = compilation.chunkGraph;
|
|
29
29
|
for (const chunk of chunks) {
|
|
30
30
|
if (
|