webpack 5.100.1 → 5.101.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.
- 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 +21 -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 +127 -114
- 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/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 +1 -1
- package/lib/ModuleFilenameHelpers.js +3 -3
- package/lib/ModuleGraph.js +86 -5
- package/lib/ModuleInfoHeaderPlugin.js +3 -3
- package/lib/ModuleParseError.js +5 -3
- 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 +28 -24
- 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 +42 -44
- 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 -12
- package/lib/WebpackIsIncludedPlugin.js +2 -2
- package/lib/WebpackOptionsApply.js +10 -3
- package/lib/asset/AssetGenerator.js +3 -3
- package/lib/asset/AssetModulesPlugin.js +6 -6
- package/lib/async-modules/AsyncModuleHelpers.js +50 -0
- 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 +39 -5
- package/lib/dependencies/HarmonyDetectionParserPlugin.js +2 -2
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +17 -23
- 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 +59 -75
- 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 +1 -1
- package/lib/dependencies/LoaderPlugin.js +4 -4
- 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/ModuleChunkFormatPlugin.js +5 -5
- package/lib/esm/ModuleChunkLoadingPlugin.js +2 -2
- 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 +10 -6
- package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +1 -1
- package/lib/javascript/BasicEvaluatedExpression.js +3 -3
- package/lib/javascript/CommonJsChunkFormatPlugin.js +1 -1
- package/lib/javascript/EnableChunkLoadingPlugin.js +1 -1
- package/lib/javascript/JavascriptGenerator.js +1 -1
- package/lib/javascript/JavascriptModulesPlugin.js +16 -16
- package/lib/javascript/JavascriptParser.js +90 -83
- 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 +3 -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 +7 -2
- 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 +6 -4
- 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 +161 -52
- 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 +22 -6
- 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 +15 -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 +17 -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 +86 -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 +107 -8
- 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 +3 -3
- 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 +14 -14
- 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 +13 -13
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +4 -0
- package/types.d.ts +186 -54
|
@@ -131,7 +131,7 @@ class SideEffectsFlagPlugin {
|
|
|
131
131
|
* @param {JavascriptParser} parser the parser
|
|
132
132
|
* @returns {void}
|
|
133
133
|
*/
|
|
134
|
-
const parserHandler = parser => {
|
|
134
|
+
const parserHandler = (parser) => {
|
|
135
135
|
/** @type {undefined | Statement | ModuleDeclaration | MaybeNamedFunctionDeclaration | MaybeNamedClassDeclaration} */
|
|
136
136
|
let sideEffectsStatement;
|
|
137
137
|
parser.hooks.program.tap(PLUGIN_NAME, () => {
|
|
@@ -139,7 +139,7 @@ class SideEffectsFlagPlugin {
|
|
|
139
139
|
});
|
|
140
140
|
parser.hooks.statement.tap(
|
|
141
141
|
{ name: PLUGIN_NAME, stage: -100 },
|
|
142
|
-
statement => {
|
|
142
|
+
(statement) => {
|
|
143
143
|
if (sideEffectsStatement) return;
|
|
144
144
|
if (parser.scope.topLevelScope !== true) return;
|
|
145
145
|
switch (statement.type) {
|
|
@@ -277,7 +277,7 @@ class SideEffectsFlagPlugin {
|
|
|
277
277
|
name: PLUGIN_NAME,
|
|
278
278
|
stage: STAGE_DEFAULT
|
|
279
279
|
},
|
|
280
|
-
modules => {
|
|
280
|
+
(modules) => {
|
|
281
281
|
const logger = compilation.getLogger(
|
|
282
282
|
"webpack.SideEffectsFlagPlugin"
|
|
283
283
|
);
|
|
@@ -289,7 +289,7 @@ class SideEffectsFlagPlugin {
|
|
|
289
289
|
/**
|
|
290
290
|
* @param {Module} module module
|
|
291
291
|
*/
|
|
292
|
-
const optimizeIncomingConnections = module => {
|
|
292
|
+
const optimizeIncomingConnections = (module) => {
|
|
293
293
|
if (optimizedModules.has(module)) return;
|
|
294
294
|
optimizedModules.add(module);
|
|
295
295
|
if (module.getSideEffectsConnectionState(moduleGraph) === false) {
|
|
@@ -320,8 +320,17 @@ class SideEffectsFlagPlugin {
|
|
|
320
320
|
({ module }) =>
|
|
321
321
|
module.getSideEffectsConnectionState(moduleGraph) ===
|
|
322
322
|
false,
|
|
323
|
-
({
|
|
323
|
+
({
|
|
324
|
+
module: newModule,
|
|
325
|
+
export: exportName,
|
|
326
|
+
connection: targetConnection
|
|
327
|
+
}) => {
|
|
324
328
|
moduleGraph.updateModule(dep, newModule);
|
|
329
|
+
moduleGraph.updateParent(
|
|
330
|
+
dep,
|
|
331
|
+
targetConnection,
|
|
332
|
+
/** @type {Module} */ (connection.originModule)
|
|
333
|
+
);
|
|
325
334
|
moduleGraph.addExplanation(
|
|
326
335
|
dep,
|
|
327
336
|
"(skipped side-effect-free modules)"
|
|
@@ -353,6 +362,13 @@ class SideEffectsFlagPlugin {
|
|
|
353
362
|
if (!target) continue;
|
|
354
363
|
|
|
355
364
|
moduleGraph.updateModule(dep, target.module);
|
|
365
|
+
moduleGraph.updateParent(
|
|
366
|
+
dep,
|
|
367
|
+
/** @type {ModuleGraphConnection} */ (
|
|
368
|
+
target.connection
|
|
369
|
+
),
|
|
370
|
+
/** @type {Module} */ (connection.originModule)
|
|
371
|
+
);
|
|
356
372
|
moduleGraph.addExplanation(
|
|
357
373
|
dep,
|
|
358
374
|
"(skipped side-effect-free modules)"
|
|
@@ -394,7 +410,7 @@ class SideEffectsFlagPlugin {
|
|
|
394
410
|
case "string":
|
|
395
411
|
return globToRegexp(flagValue, cache).test(moduleName);
|
|
396
412
|
case "object":
|
|
397
|
-
return flagValue.some(glob =>
|
|
413
|
+
return flagValue.some((glob) =>
|
|
398
414
|
SideEffectsFlagPlugin.moduleHasSideEffects(moduleName, glob, cache)
|
|
399
415
|
);
|
|
400
416
|
}
|
|
@@ -195,7 +195,7 @@ const hashFilename = (name, outputOptions) => {
|
|
|
195
195
|
* @param {Chunk} chunk the chunk
|
|
196
196
|
* @returns {number} the number of requests
|
|
197
197
|
*/
|
|
198
|
-
const getRequests = chunk => {
|
|
198
|
+
const getRequests = (chunk) => {
|
|
199
199
|
let requests = 0;
|
|
200
200
|
for (const chunkGroup of chunk.groupsIterable) {
|
|
201
201
|
requests = Math.max(requests, chunkGroup.chunks.length);
|
|
@@ -272,17 +272,17 @@ const compareEntries = (a, b) => {
|
|
|
272
272
|
* @param {Chunk} chunk the chunk
|
|
273
273
|
* @returns {boolean} true, if the chunk is an entry chunk
|
|
274
274
|
*/
|
|
275
|
-
const INITIAL_CHUNK_FILTER = chunk => chunk.canBeInitial();
|
|
275
|
+
const INITIAL_CHUNK_FILTER = (chunk) => chunk.canBeInitial();
|
|
276
276
|
/**
|
|
277
277
|
* @param {Chunk} chunk the chunk
|
|
278
278
|
* @returns {boolean} true, if the chunk is an async chunk
|
|
279
279
|
*/
|
|
280
|
-
const ASYNC_CHUNK_FILTER = chunk => !chunk.canBeInitial();
|
|
280
|
+
const ASYNC_CHUNK_FILTER = (chunk) => !chunk.canBeInitial();
|
|
281
281
|
/**
|
|
282
282
|
* @param {Chunk} _chunk the chunk
|
|
283
283
|
* @returns {boolean} always true
|
|
284
284
|
*/
|
|
285
|
-
const ALL_CHUNK_FILTER = _chunk => true;
|
|
285
|
+
const ALL_CHUNK_FILTER = (_chunk) => true;
|
|
286
286
|
|
|
287
287
|
/**
|
|
288
288
|
* @param {OptimizationSplitChunksSizes | undefined} value the sizes
|
|
@@ -318,7 +318,7 @@ const mergeSizes = (...sizes) => {
|
|
|
318
318
|
* @param {SplitChunksSizes} sizes the sizes
|
|
319
319
|
* @returns {boolean} true, if there are sizes > 0
|
|
320
320
|
*/
|
|
321
|
-
const hasNonZeroSizes = sizes => {
|
|
321
|
+
const hasNonZeroSizes = (sizes) => {
|
|
322
322
|
for (const key of Object.keys(sizes)) {
|
|
323
323
|
if (sizes[key] > 0) return true;
|
|
324
324
|
}
|
|
@@ -398,7 +398,7 @@ const getViolatingMinSizes = (sizes, minSize) => {
|
|
|
398
398
|
* @param {SplitChunksSizes} sizes the sizes
|
|
399
399
|
* @returns {number} the total size
|
|
400
400
|
*/
|
|
401
|
-
const totalSize = sizes => {
|
|
401
|
+
const totalSize = (sizes) => {
|
|
402
402
|
let size = 0;
|
|
403
403
|
for (const key of Object.keys(sizes)) {
|
|
404
404
|
size += sizes[key];
|
|
@@ -410,7 +410,7 @@ const totalSize = sizes => {
|
|
|
410
410
|
* @param {OptimizationSplitChunksCacheGroup["name"]} name the chunk name
|
|
411
411
|
* @returns {GetName | undefined} a function to get the name of the chunk
|
|
412
412
|
*/
|
|
413
|
-
const normalizeName = name => {
|
|
413
|
+
const normalizeName = (name) => {
|
|
414
414
|
if (typeof name === "string") {
|
|
415
415
|
return () => name;
|
|
416
416
|
}
|
|
@@ -423,7 +423,7 @@ const normalizeName = name => {
|
|
|
423
423
|
* @param {OptimizationSplitChunksCacheGroup["chunks"]} chunks the chunk filter option
|
|
424
424
|
* @returns {ChunkFilterFunction | undefined} the chunk filter function
|
|
425
425
|
*/
|
|
426
|
-
const normalizeChunksFilter = chunks => {
|
|
426
|
+
const normalizeChunksFilter = (chunks) => {
|
|
427
427
|
if (chunks === "initial") {
|
|
428
428
|
return INITIAL_CHUNK_FILTER;
|
|
429
429
|
}
|
|
@@ -434,7 +434,7 @@ const normalizeChunksFilter = chunks => {
|
|
|
434
434
|
return ALL_CHUNK_FILTER;
|
|
435
435
|
}
|
|
436
436
|
if (chunks instanceof RegExp) {
|
|
437
|
-
return chunk => (chunk.name ? chunks.test(chunk.name) : false);
|
|
437
|
+
return (chunk) => (chunk.name ? chunks.test(chunk.name) : false);
|
|
438
438
|
}
|
|
439
439
|
if (typeof chunks === "function") {
|
|
440
440
|
return chunks;
|
|
@@ -824,7 +824,7 @@ module.exports = class SplitChunksPlugin {
|
|
|
824
824
|
compiler.context,
|
|
825
825
|
compiler.root
|
|
826
826
|
);
|
|
827
|
-
compiler.hooks.thisCompilation.tap(PLUGIN_NAME, compilation => {
|
|
827
|
+
compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation) => {
|
|
828
828
|
const logger = compilation.getLogger(`webpack.${PLUGIN_NAME}`);
|
|
829
829
|
let alreadyOptimized = false;
|
|
830
830
|
compilation.hooks.unseal.tap(PLUGIN_NAME, () => {
|
|
@@ -835,7 +835,7 @@ module.exports = class SplitChunksPlugin {
|
|
|
835
835
|
name: PLUGIN_NAME,
|
|
836
836
|
stage: STAGE_ADVANCED
|
|
837
837
|
},
|
|
838
|
-
chunks => {
|
|
838
|
+
(chunks) => {
|
|
839
839
|
if (alreadyOptimized) return;
|
|
840
840
|
alreadyOptimized = true;
|
|
841
841
|
logger.time("prepare");
|
|
@@ -859,7 +859,7 @@ module.exports = class SplitChunksPlugin {
|
|
|
859
859
|
* @param {Iterable<Chunk>} chunks list of chunks
|
|
860
860
|
* @returns {bigint | Chunk} key of the chunks
|
|
861
861
|
*/
|
|
862
|
-
const getKey = chunks => {
|
|
862
|
+
const getKey = (chunks) => {
|
|
863
863
|
const iterator = chunks[Symbol.iterator]();
|
|
864
864
|
let result = iterator.next();
|
|
865
865
|
if (result.done) return ZERO;
|
|
@@ -879,7 +879,7 @@ module.exports = class SplitChunksPlugin {
|
|
|
879
879
|
* @param {bigint | Chunk} key key of the chunks
|
|
880
880
|
* @returns {string} stringified key
|
|
881
881
|
*/
|
|
882
|
-
const keyToString = key => {
|
|
882
|
+
const keyToString = (key) => {
|
|
883
883
|
if (typeof key === "bigint") return key.toString(16);
|
|
884
884
|
return /** @type {bigint} */ (chunkIndexMap.get(key)).toString(16);
|
|
885
885
|
};
|
|
@@ -907,7 +907,7 @@ module.exports = class SplitChunksPlugin {
|
|
|
907
907
|
* @param {Module} module the module
|
|
908
908
|
* @returns {Iterable<Chunk[]>} groups of chunks with equal exports
|
|
909
909
|
*/
|
|
910
|
-
const groupChunksByExports = module => {
|
|
910
|
+
const groupChunksByExports = (module) => {
|
|
911
911
|
const exportsInfo = moduleGraph.getExportsInfo(module);
|
|
912
912
|
const groupedByUsedExports = new Map();
|
|
913
913
|
for (const chunk of chunkGraph.getModuleChunksIterable(module)) {
|
|
@@ -954,7 +954,7 @@ module.exports = class SplitChunksPlugin {
|
|
|
954
954
|
* @param {IterableIterator<Set<Chunk>>} chunkSets set of sets of chunks
|
|
955
955
|
* @returns {Map<number, Array<Set<Chunk>>>} map of sets of chunks by count
|
|
956
956
|
*/
|
|
957
|
-
const groupChunkSetsByCount = chunkSets => {
|
|
957
|
+
const groupChunkSetsByCount = (chunkSets) => {
|
|
958
958
|
/** @type {Map<number, Array<Set<Chunk>>>} */
|
|
959
959
|
const chunkSetsByCount = new Map();
|
|
960
960
|
for (const chunksSet of chunkSets) {
|
|
@@ -994,7 +994,7 @@ module.exports = class SplitChunksPlugin {
|
|
|
994
994
|
/** @type {Map<bigint | Chunk, (Set<Chunk> | Chunk)[]>} */
|
|
995
995
|
const combinationsCache = new Map();
|
|
996
996
|
|
|
997
|
-
return key => {
|
|
997
|
+
return (key) => {
|
|
998
998
|
const cacheEntry = combinationsCache.get(key);
|
|
999
999
|
if (cacheEntry !== undefined) return cacheEntry;
|
|
1000
1000
|
if (key instanceof Chunk) {
|
|
@@ -1040,7 +1040,7 @@ module.exports = class SplitChunksPlugin {
|
|
|
1040
1040
|
* @param {bigint | Chunk} key key
|
|
1041
1041
|
* @returns {(Set<Chunk> | Chunk)[]} combinations by key
|
|
1042
1042
|
*/
|
|
1043
|
-
const getCombinations = key => getCombinationsFactory()(key);
|
|
1043
|
+
const getCombinations = (key) => getCombinationsFactory()(key);
|
|
1044
1044
|
|
|
1045
1045
|
const getExportsCombinationsFactory = memoize(() => {
|
|
1046
1046
|
const { chunkSetsInGraph, singleChunkSets } =
|
|
@@ -1055,7 +1055,7 @@ module.exports = class SplitChunksPlugin {
|
|
|
1055
1055
|
* @param {bigint | Chunk} key key
|
|
1056
1056
|
* @returns {(Set<Chunk> | Chunk)[]} exports combinations by key
|
|
1057
1057
|
*/
|
|
1058
|
-
const getExportsCombinations = key =>
|
|
1058
|
+
const getExportsCombinations = (key) =>
|
|
1059
1059
|
getExportsCombinationsFactory()(key);
|
|
1060
1060
|
|
|
1061
1061
|
/**
|
|
@@ -1321,7 +1321,7 @@ module.exports = class SplitChunksPlugin {
|
|
|
1321
1321
|
const removeModulesWithSourceType = (info, sourceTypes) => {
|
|
1322
1322
|
for (const module of info.modules) {
|
|
1323
1323
|
const types = module.getSourceTypes();
|
|
1324
|
-
if (sourceTypes.some(type => types.has(type))) {
|
|
1324
|
+
if (sourceTypes.some((type) => types.has(type))) {
|
|
1325
1325
|
info.modules.delete(module);
|
|
1326
1326
|
for (const type of types) {
|
|
1327
1327
|
info.sizes[type] -= module.size(type);
|
|
@@ -1334,7 +1334,7 @@ module.exports = class SplitChunksPlugin {
|
|
|
1334
1334
|
* @param {ChunksInfoItem} info entry
|
|
1335
1335
|
* @returns {boolean} true, if entry become empty
|
|
1336
1336
|
*/
|
|
1337
|
-
const removeMinSizeViolatingModules = info => {
|
|
1337
|
+
const removeMinSizeViolatingModules = (info) => {
|
|
1338
1338
|
if (!info.cacheGroup._validateSize) return false;
|
|
1339
1339
|
const violatingSizes = getViolatingMinSizes(
|
|
1340
1340
|
info.sizes,
|
|
@@ -17,7 +17,7 @@ module.exports = class AssetsOverSizeLimitWarning extends WebpackError {
|
|
|
17
17
|
*/
|
|
18
18
|
constructor(assetsOverSizeLimit, assetLimit) {
|
|
19
19
|
const assetLists = assetsOverSizeLimit
|
|
20
|
-
.map(asset => `\n ${asset.name} (${formatSize(asset.size)})`)
|
|
20
|
+
.map((asset) => `\n ${asset.name} (${formatSize(asset.size)})`)
|
|
21
21
|
.join("");
|
|
22
22
|
|
|
23
23
|
super(`asset size limit: The following asset(s) exceed the recommended size limit (${formatSize(
|
|
@@ -18,10 +18,10 @@ module.exports = class EntrypointsOverSizeLimitWarning extends WebpackError {
|
|
|
18
18
|
constructor(entrypoints, entrypointLimit) {
|
|
19
19
|
const entrypointList = entrypoints
|
|
20
20
|
.map(
|
|
21
|
-
entrypoint =>
|
|
21
|
+
(entrypoint) =>
|
|
22
22
|
`\n ${entrypoint.name} (${formatSize(
|
|
23
23
|
entrypoint.size
|
|
24
|
-
)})\n${entrypoint.files.map(asset => ` ${asset}`).join("\n")}`
|
|
24
|
+
)})\n${entrypoint.files.map((asset) => ` ${asset}`).join("\n")}`
|
|
25
25
|
)
|
|
26
26
|
.join("");
|
|
27
27
|
super(`entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit (${formatSize(
|
|
@@ -73,7 +73,7 @@ module.exports = class SizeLimitsPlugin {
|
|
|
73
73
|
const hints = this.hints;
|
|
74
74
|
const assetFilter = this.assetFilter || excludeSourceMap;
|
|
75
75
|
|
|
76
|
-
compiler.hooks.afterEmit.tap(PLUGIN_NAME, compilation => {
|
|
76
|
+
compiler.hooks.afterEmit.tap(PLUGIN_NAME, (compilation) => {
|
|
77
77
|
/** @type {WebpackError[]} */
|
|
78
78
|
const warnings = [];
|
|
79
79
|
|
|
@@ -81,7 +81,7 @@ module.exports = class SizeLimitsPlugin {
|
|
|
81
81
|
* @param {Entrypoint} entrypoint an entrypoint
|
|
82
82
|
* @returns {number} the size of the entrypoint
|
|
83
83
|
*/
|
|
84
|
-
const getEntrypointSize = entrypoint => {
|
|
84
|
+
const getEntrypointSize = (entrypoint) => {
|
|
85
85
|
let size = 0;
|
|
86
86
|
for (const file of entrypoint.getFiles()) {
|
|
87
87
|
const asset = compilation.getAsset(file);
|
|
@@ -117,7 +117,7 @@ module.exports = class SizeLimitsPlugin {
|
|
|
117
117
|
* @param {Asset["name"]} name the name
|
|
118
118
|
* @returns {boolean | undefined} result
|
|
119
119
|
*/
|
|
120
|
-
const fileFilter = name => {
|
|
120
|
+
const fileFilter = (name) => {
|
|
121
121
|
const asset = compilation.getAsset(name);
|
|
122
122
|
return asset && assetFilter(asset.name, asset.source, asset.info);
|
|
123
123
|
};
|
|
@@ -162,7 +162,7 @@ module.exports = class SizeLimitsPlugin {
|
|
|
162
162
|
if (warnings.length > 0) {
|
|
163
163
|
const someAsyncChunk = find(
|
|
164
164
|
compilation.chunks,
|
|
165
|
-
chunk => !chunk.canBeInitial()
|
|
165
|
+
(chunk) => !chunk.canBeInitial()
|
|
166
166
|
);
|
|
167
167
|
|
|
168
168
|
if (!someAsyncChunk) {
|
|
@@ -23,7 +23,7 @@ class ChunkPrefetchPreloadPlugin {
|
|
|
23
23
|
* @returns {void}
|
|
24
24
|
*/
|
|
25
25
|
apply(compiler) {
|
|
26
|
-
compiler.hooks.compilation.tap(PLUGIN_NAME, compilation => {
|
|
26
|
+
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
|
|
27
27
|
compilation.hooks.additionalChunkRuntimeRequirements.tap(
|
|
28
28
|
PLUGIN_NAME,
|
|
29
29
|
(chunk, set, { chunkGraph }) => {
|
|
@@ -34,16 +34,16 @@ class ChunkPrefetchStartupRuntimeModule extends RuntimeModule {
|
|
|
34
34
|
({ onChunks, chunks }) =>
|
|
35
35
|
`${RuntimeGlobals.onChunksLoaded}(0, ${JSON.stringify(
|
|
36
36
|
// This need to include itself to delay execution after this chunk has been fully loaded
|
|
37
|
-
onChunks.filter(c => c === chunk).map(c => c.id)
|
|
37
|
+
onChunks.filter((c) => c === chunk).map((c) => c.id)
|
|
38
38
|
)}, ${runtimeTemplate.basicFunction(
|
|
39
39
|
"",
|
|
40
40
|
chunks.size < 3
|
|
41
41
|
? Array.from(
|
|
42
42
|
chunks,
|
|
43
|
-
c =>
|
|
43
|
+
(c) =>
|
|
44
44
|
`${RuntimeGlobals.prefetchChunk}(${JSON.stringify(c.id)});`
|
|
45
45
|
)
|
|
46
|
-
: `${JSON.stringify(Array.from(chunks, c => c.id))}.map(${
|
|
46
|
+
: `${JSON.stringify(Array.from(chunks, (c) => c.id))}.map(${
|
|
47
47
|
RuntimeGlobals.prefetchChunk
|
|
48
48
|
});`
|
|
49
49
|
)}, 5);`
|
|
@@ -183,7 +183,7 @@ class RuleSetCompiler {
|
|
|
183
183
|
|
|
184
184
|
return {
|
|
185
185
|
references: refs,
|
|
186
|
-
exec: data => {
|
|
186
|
+
exec: (data) => {
|
|
187
187
|
/** @type {Effect[]} */
|
|
188
188
|
const effects = [];
|
|
189
189
|
for (const rule of rules) {
|
|
@@ -222,7 +222,7 @@ class RuleSetCompiler {
|
|
|
222
222
|
/** @type {Set<string>} */
|
|
223
223
|
const unhandledProperties = new Set(
|
|
224
224
|
Object.keys(rule).filter(
|
|
225
|
-
key => rule[/** @type {keyof RuleSetRule} */ (key)] !== undefined
|
|
225
|
+
(key) => rule[/** @type {keyof RuleSetRule} */ (key)] !== undefined
|
|
226
226
|
)
|
|
227
227
|
);
|
|
228
228
|
|
|
@@ -274,7 +274,7 @@ class RuleSetCompiler {
|
|
|
274
274
|
if (condition === "") {
|
|
275
275
|
return {
|
|
276
276
|
matchWhenEmpty: true,
|
|
277
|
-
fn: str => str === ""
|
|
277
|
+
fn: (str) => str === ""
|
|
278
278
|
};
|
|
279
279
|
}
|
|
280
280
|
if (!condition) {
|
|
@@ -287,7 +287,7 @@ class RuleSetCompiler {
|
|
|
287
287
|
if (typeof condition === "string") {
|
|
288
288
|
return {
|
|
289
289
|
matchWhenEmpty: condition.length === 0,
|
|
290
|
-
fn: str => typeof str === "string" && str.startsWith(condition)
|
|
290
|
+
fn: (str) => typeof str === "string" && str.startsWith(condition)
|
|
291
291
|
};
|
|
292
292
|
}
|
|
293
293
|
if (typeof condition === "function") {
|
|
@@ -307,7 +307,7 @@ class RuleSetCompiler {
|
|
|
307
307
|
if (condition instanceof RegExp) {
|
|
308
308
|
return {
|
|
309
309
|
matchWhenEmpty: condition.test(""),
|
|
310
|
-
fn: v => typeof v === "string" && condition.test(v)
|
|
310
|
+
fn: (v) => typeof v === "string" && condition.test(v)
|
|
311
311
|
};
|
|
312
312
|
}
|
|
313
313
|
if (Array.isArray(condition)) {
|
|
@@ -363,7 +363,7 @@ class RuleSetCompiler {
|
|
|
363
363
|
const fn = matcher.fn;
|
|
364
364
|
conditions.push({
|
|
365
365
|
matchWhenEmpty: !matcher.matchWhenEmpty,
|
|
366
|
-
fn: /** @type {RuleConditionFunction} */ (v => !fn(v))
|
|
366
|
+
fn: /** @type {RuleConditionFunction} */ ((v) => !fn(v))
|
|
367
367
|
});
|
|
368
368
|
}
|
|
369
369
|
break;
|
|
@@ -399,8 +399,8 @@ class RuleSetCompiler {
|
|
|
399
399
|
return conditions[0];
|
|
400
400
|
}
|
|
401
401
|
return {
|
|
402
|
-
matchWhenEmpty: conditions.some(c => c.matchWhenEmpty),
|
|
403
|
-
fn: v => conditions.some(c => c.fn(v))
|
|
402
|
+
matchWhenEmpty: conditions.some((c) => c.matchWhenEmpty),
|
|
403
|
+
fn: (v) => conditions.some((c) => c.fn(v))
|
|
404
404
|
};
|
|
405
405
|
}
|
|
406
406
|
|
|
@@ -418,8 +418,8 @@ class RuleSetCompiler {
|
|
|
418
418
|
return conditions[0];
|
|
419
419
|
}
|
|
420
420
|
return {
|
|
421
|
-
matchWhenEmpty: conditions.every(c => c.matchWhenEmpty),
|
|
422
|
-
fn: v => conditions.every(c => c.fn(v))
|
|
421
|
+
matchWhenEmpty: conditions.every((c) => c.matchWhenEmpty),
|
|
422
|
+
fn: (v) => conditions.every((c) => c.fn(v))
|
|
423
423
|
};
|
|
424
424
|
}
|
|
425
425
|
|
|
@@ -65,7 +65,7 @@ class UseEffectRulePlugin {
|
|
|
65
65
|
*/
|
|
66
66
|
const useToEffect = (path, defaultIdent, item) => {
|
|
67
67
|
if (typeof item === "function") {
|
|
68
|
-
return data =>
|
|
68
|
+
return (data) =>
|
|
69
69
|
useToEffectsWithoutIdent(
|
|
70
70
|
path,
|
|
71
71
|
/** @type {RuleSetUseItem | RuleSetUseItem[]} */
|
|
@@ -165,7 +165,7 @@ class UseEffectRulePlugin {
|
|
|
165
165
|
};
|
|
166
166
|
|
|
167
167
|
if (typeof use === "function") {
|
|
168
|
-
result.effects.push(data =>
|
|
168
|
+
result.effects.push((data) =>
|
|
169
169
|
useToEffectsWithoutIdent(`${path}.use`, use(data))
|
|
170
170
|
);
|
|
171
171
|
} else {
|
|
@@ -53,7 +53,7 @@ class GetChunkFilenameRuntimeModule extends RuntimeModule {
|
|
|
53
53
|
* @param {Chunk} c the chunk
|
|
54
54
|
* @returns {void}
|
|
55
55
|
*/
|
|
56
|
-
const addChunk = c => {
|
|
56
|
+
const addChunk = (c) => {
|
|
57
57
|
const chunkFilename = getFilenameForChunk(c);
|
|
58
58
|
if (chunkFilename) {
|
|
59
59
|
let set = chunkFilenames.get(chunkFilename);
|
|
@@ -128,7 +128,7 @@ class GetChunkFilenameRuntimeModule extends RuntimeModule {
|
|
|
128
128
|
* @param {string | number} value a value
|
|
129
129
|
* @returns {string} string to put in quotes
|
|
130
130
|
*/
|
|
131
|
-
const unquotedStringify = value => {
|
|
131
|
+
const unquotedStringify = (value) => {
|
|
132
132
|
const str = `${value}`;
|
|
133
133
|
if (str.length >= 5 && str === `${c.id}`) {
|
|
134
134
|
// This is shorter and generates the same result
|
|
@@ -141,7 +141,7 @@ class GetChunkFilenameRuntimeModule extends RuntimeModule {
|
|
|
141
141
|
* @param {string} value string
|
|
142
142
|
* @returns {(length: number) => string} string to put in quotes with length
|
|
143
143
|
*/
|
|
144
|
-
const unquotedStringifyWithLength = value => length =>
|
|
144
|
+
const unquotedStringifyWithLength = (value) => (length) =>
|
|
145
145
|
unquotedStringify(`${value}`.slice(0, length));
|
|
146
146
|
const chunkFilenameValue =
|
|
147
147
|
typeof chunkFilename === "function"
|
|
@@ -154,7 +154,7 @@ class GetChunkFilenameRuntimeModule extends RuntimeModule {
|
|
|
154
154
|
: JSON.stringify(chunkFilename);
|
|
155
155
|
const staticChunkFilename = compilation.getPath(chunkFilenameValue, {
|
|
156
156
|
hash: `" + ${RuntimeGlobals.getFullHash}() + "`,
|
|
157
|
-
hashWithLength: length =>
|
|
157
|
+
hashWithLength: (length) =>
|
|
158
158
|
`" + ${RuntimeGlobals.getFullHash}().slice(0, ${length}) + "`,
|
|
159
159
|
chunk: {
|
|
160
160
|
id: unquotedStringify(/** @type {ChunkId} */ (c.id)),
|
|
@@ -193,7 +193,7 @@ class GetChunkFilenameRuntimeModule extends RuntimeModule {
|
|
|
193
193
|
* @param {(chunk: Chunk) => string | number} fn function from chunk to value
|
|
194
194
|
* @returns {string} code with static mapping of results of fn
|
|
195
195
|
*/
|
|
196
|
-
const createMap = fn => {
|
|
196
|
+
const createMap = (fn) => {
|
|
197
197
|
/** @type {Record<number | string, number | string>} */
|
|
198
198
|
const obj = {};
|
|
199
199
|
let useId = false;
|
|
@@ -227,33 +227,33 @@ class GetChunkFilenameRuntimeModule extends RuntimeModule {
|
|
|
227
227
|
* @param {(chunk: Chunk) => string | number} fn function from chunk to value
|
|
228
228
|
* @returns {string} code with static mapping of results of fn for including in quoted string
|
|
229
229
|
*/
|
|
230
|
-
const mapExpr = fn => `" + ${createMap(fn)} + "`;
|
|
230
|
+
const mapExpr = (fn) => `" + ${createMap(fn)} + "`;
|
|
231
231
|
|
|
232
232
|
/**
|
|
233
233
|
* @param {(chunk: Chunk) => string | number} fn function from chunk to value
|
|
234
234
|
* @returns {(length: number) => string} function which generates code with static mapping of results of fn for including in quoted string for specific length
|
|
235
235
|
*/
|
|
236
|
-
const mapExprWithLength = fn => length =>
|
|
237
|
-
`" + ${createMap(c => `${fn(c)}`.slice(0, length))} + "`;
|
|
236
|
+
const mapExprWithLength = (fn) => (length) =>
|
|
237
|
+
`" + ${createMap((c) => `${fn(c)}`.slice(0, length))} + "`;
|
|
238
238
|
|
|
239
239
|
const url =
|
|
240
240
|
dynamicFilename &&
|
|
241
241
|
compilation.getPath(JSON.stringify(dynamicFilename), {
|
|
242
242
|
hash: `" + ${RuntimeGlobals.getFullHash}() + "`,
|
|
243
|
-
hashWithLength: length =>
|
|
243
|
+
hashWithLength: (length) =>
|
|
244
244
|
`" + ${RuntimeGlobals.getFullHash}().slice(0, ${length}) + "`,
|
|
245
245
|
chunk: {
|
|
246
246
|
id: '" + chunkId + "',
|
|
247
|
-
hash: mapExpr(c => /** @type {string} */ (c.renderedHash)),
|
|
247
|
+
hash: mapExpr((c) => /** @type {string} */ (c.renderedHash)),
|
|
248
248
|
hashWithLength: mapExprWithLength(
|
|
249
|
-
c => /** @type {string} */ (c.renderedHash)
|
|
249
|
+
(c) => /** @type {string} */ (c.renderedHash)
|
|
250
250
|
),
|
|
251
|
-
name: mapExpr(c => c.name || /** @type {number | string} */ (c.id)),
|
|
251
|
+
name: mapExpr((c) => c.name || /** @type {number | string} */ (c.id)),
|
|
252
252
|
contentHash: {
|
|
253
|
-
[contentType]: mapExpr(c => c.contentHash[contentType])
|
|
253
|
+
[contentType]: mapExpr((c) => c.contentHash[contentType])
|
|
254
254
|
},
|
|
255
255
|
contentHashWithLength: {
|
|
256
|
-
[contentType]: mapExprWithLength(c => c.contentHash[contentType])
|
|
256
|
+
[contentType]: mapExprWithLength((c) => c.contentHash[contentType])
|
|
257
257
|
}
|
|
258
258
|
},
|
|
259
259
|
contentHashType: contentType
|
|
@@ -277,7 +277,7 @@ class GetChunkFilenameRuntimeModule extends RuntimeModule {
|
|
|
277
277
|
? `chunkId === ${JSON.stringify(first(ids))}`
|
|
278
278
|
: `{${Array.from(
|
|
279
279
|
ids,
|
|
280
|
-
id => `${JSON.stringify(id)}:1`
|
|
280
|
+
(id) => `${JSON.stringify(id)}:1`
|
|
281
281
|
).join(",")}}[chunkId]`;
|
|
282
282
|
return `if (${condition}) return ${url};`;
|
|
283
283
|
})
|
|
@@ -33,7 +33,7 @@ class GetMainFilenameRuntimeModule extends RuntimeModule {
|
|
|
33
33
|
const { runtimeTemplate } = compilation;
|
|
34
34
|
const url = compilation.getPath(JSON.stringify(filename), {
|
|
35
35
|
hash: `" + ${RuntimeGlobals.getFullHash}() + "`,
|
|
36
|
-
hashWithLength: length =>
|
|
36
|
+
hashWithLength: (length) =>
|
|
37
37
|
`" + ${RuntimeGlobals.getFullHash}().slice(0, ${length}) + "`,
|
|
38
38
|
chunk,
|
|
39
39
|
runtime: chunk.runtime
|
|
@@ -69,7 +69,7 @@ class GetTrustedTypesPolicyRuntimeModule extends HelperRuntimeModule {
|
|
|
69
69
|
`policy = trustedTypes.createPolicy(${JSON.stringify(
|
|
70
70
|
trustedTypes.policyName
|
|
71
71
|
)}, policy);`
|
|
72
|
-
].map(line =>
|
|
72
|
+
].map((line) =>
|
|
73
73
|
wrapPolicyCreationInTryCatch ? Template.indent(line) : line
|
|
74
74
|
),
|
|
75
75
|
...(wrapPolicyCreationInTryCatch
|
|
@@ -54,7 +54,7 @@ function getOptimizedDeferredModule(
|
|
|
54
54
|
isAsync
|
|
55
55
|
? `[${
|
|
56
56
|
RuntimeGlobals.makeDeferredNamespaceObjectSymbol
|
|
57
|
-
}]: ${JSON.stringify(asyncDepsIds.filter(x => x !== null))}`
|
|
57
|
+
}]: ${JSON.stringify(asyncDepsIds.filter((x) => x !== null))}`
|
|
58
58
|
: ""
|
|
59
59
|
];
|
|
60
60
|
return Template.asString(["{", Template.indent(props), "}"]);
|
|
@@ -38,13 +38,13 @@ class StartupChunkDependenciesPlugin {
|
|
|
38
38
|
* @returns {void}
|
|
39
39
|
*/
|
|
40
40
|
apply(compiler) {
|
|
41
|
-
compiler.hooks.thisCompilation.tap(PLUGIN_NAME, compilation => {
|
|
41
|
+
compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation) => {
|
|
42
42
|
const globalChunkLoading = compilation.outputOptions.chunkLoading;
|
|
43
43
|
/**
|
|
44
44
|
* @param {Chunk} chunk chunk to check
|
|
45
45
|
* @returns {boolean} true, when the plugin is enabled for the chunk
|
|
46
46
|
*/
|
|
47
|
-
const isEnabledForChunk = chunk => {
|
|
47
|
+
const isEnabledForChunk = (chunk) => {
|
|
48
48
|
const options = chunk.getEntryOptions();
|
|
49
49
|
const chunkLoading =
|
|
50
50
|
options && options.chunkLoading !== undefined
|
|
@@ -30,7 +30,7 @@ class StartupChunkDependenciesRuntimeModule extends RuntimeModule {
|
|
|
30
30
|
const chunk = /** @type {Chunk} */ (this.chunk);
|
|
31
31
|
const chunkIds = [
|
|
32
32
|
...chunkGraph.getChunkEntryDependentChunksIterable(chunk)
|
|
33
|
-
].map(chunk => chunk.id);
|
|
33
|
+
].map((chunk) => chunk.id);
|
|
34
34
|
const compilation = /** @type {Compilation} */ (this.compilation);
|
|
35
35
|
const { runtimeTemplate } = compilation;
|
|
36
36
|
return Template.asString([
|
|
@@ -40,7 +40,7 @@ class StartupChunkDependenciesRuntimeModule extends RuntimeModule {
|
|
|
40
40
|
!this.asyncChunkLoading
|
|
41
41
|
? [
|
|
42
42
|
...chunkIds.map(
|
|
43
|
-
id => `${RuntimeGlobals.ensureChunk}(${JSON.stringify(id)});`
|
|
43
|
+
(id) => `${RuntimeGlobals.ensureChunk}(${JSON.stringify(id)});`
|
|
44
44
|
),
|
|
45
45
|
"return next();"
|
|
46
46
|
]
|
|
@@ -61,7 +61,7 @@ class StartupChunkDependenciesRuntimeModule extends RuntimeModule {
|
|
|
61
61
|
Template.indent(
|
|
62
62
|
chunkIds
|
|
63
63
|
.map(
|
|
64
|
-
id =>
|
|
64
|
+
(id) =>
|
|
65
65
|
`${RuntimeGlobals.ensureChunk}(${JSON.stringify(id)})`
|
|
66
66
|
)
|
|
67
67
|
.join(",\n")
|
|
@@ -17,7 +17,7 @@ const URIRegEx = /^data:([^;,]+)?((?:;[^;,]+)*?)(?:;(base64)?)?,(.*)$/i;
|
|
|
17
17
|
* @param {string} uri data URI
|
|
18
18
|
* @returns {Buffer | null} decoded data
|
|
19
19
|
*/
|
|
20
|
-
const decodeDataURI = uri => {
|
|
20
|
+
const decodeDataURI = (uri) => {
|
|
21
21
|
const match = URIRegEx.exec(uri);
|
|
22
22
|
if (!match) return null;
|
|
23
23
|
|
|
@@ -51,7 +51,7 @@ class DataUriPlugin {
|
|
|
51
51
|
(compilation, { normalModuleFactory }) => {
|
|
52
52
|
normalModuleFactory.hooks.resolveForScheme
|
|
53
53
|
.for("data")
|
|
54
|
-
.tap(PLUGIN_NAME, resourceData => {
|
|
54
|
+
.tap(PLUGIN_NAME, (resourceData) => {
|
|
55
55
|
const match = URIRegEx.exec(resourceData.resource);
|
|
56
56
|
if (match) {
|
|
57
57
|
resourceData.data.mimetype = match[1] || "";
|
|
@@ -64,7 +64,7 @@ class DataUriPlugin {
|
|
|
64
64
|
});
|
|
65
65
|
NormalModule.getCompilationHooks(compilation)
|
|
66
66
|
.readResourceForScheme.for("data")
|
|
67
|
-
.tap(PLUGIN_NAME, resource => decodeDataURI(resource));
|
|
67
|
+
.tap(PLUGIN_NAME, (resource) => decodeDataURI(resource));
|
|
68
68
|
}
|
|
69
69
|
);
|
|
70
70
|
}
|
|
@@ -24,7 +24,7 @@ class FileUriPlugin {
|
|
|
24
24
|
(compilation, { normalModuleFactory }) => {
|
|
25
25
|
normalModuleFactory.hooks.resolveForScheme
|
|
26
26
|
.for("file")
|
|
27
|
-
.tap(PLUGIN_NAME, resourceData => {
|
|
27
|
+
.tap(PLUGIN_NAME, (resourceData) => {
|
|
28
28
|
const url = new URL(resourceData.resource);
|
|
29
29
|
const path = fileURLToPath(url);
|
|
30
30
|
const query = url.search;
|