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
package/lib/RuntimeTemplate.js
CHANGED
|
@@ -8,6 +8,9 @@
|
|
|
8
8
|
const InitFragment = require("./InitFragment");
|
|
9
9
|
const RuntimeGlobals = require("./RuntimeGlobals");
|
|
10
10
|
const Template = require("./Template");
|
|
11
|
+
const {
|
|
12
|
+
getOutgoingAsyncModules
|
|
13
|
+
} = require("./async-modules/AsyncModuleHelpers");
|
|
11
14
|
const {
|
|
12
15
|
getMakeDeferredNamespaceModeFromExportsType,
|
|
13
16
|
getOptimizedDeferredModule
|
|
@@ -46,12 +49,12 @@ This should not happen.
|
|
|
46
49
|
It's in these chunks: ${
|
|
47
50
|
Array.from(
|
|
48
51
|
chunkGraph.getModuleChunksIterable(module),
|
|
49
|
-
c => c.name || c.id || c.debugId
|
|
52
|
+
(c) => c.name || c.id || c.debugId
|
|
50
53
|
).join(", ") || "none"
|
|
51
54
|
} (If module is in no chunk this indicates a bug in some chunk/module optimization logic)
|
|
52
55
|
Module has these incoming connections: ${Array.from(
|
|
53
56
|
chunkGraph.moduleGraph.getIncomingConnections(module),
|
|
54
|
-
connection =>
|
|
57
|
+
(connection) =>
|
|
55
58
|
`\n - ${
|
|
56
59
|
connection.originModule && connection.originModule.identifier()
|
|
57
60
|
} ${connection.dependency && connection.dependency.type} ${
|
|
@@ -159,6 +162,16 @@ class RuntimeTemplate {
|
|
|
159
162
|
return this.outputOptions.environment.nodePrefixForCoreModules;
|
|
160
163
|
}
|
|
161
164
|
|
|
165
|
+
/**
|
|
166
|
+
* @param {string} mod a module
|
|
167
|
+
* @returns {string} a module with `node:` prefix when supported, otherwise an original name
|
|
168
|
+
*/
|
|
169
|
+
renderNodePrefixForCoreModule(mod) {
|
|
170
|
+
return this.outputOptions.environment.nodePrefixForCoreModules
|
|
171
|
+
? `"node:${mod}"`
|
|
172
|
+
: `"${mod}"`;
|
|
173
|
+
}
|
|
174
|
+
|
|
162
175
|
/**
|
|
163
176
|
* @param {string} returnValue return value
|
|
164
177
|
* @param {string} args arguments
|
|
@@ -226,7 +239,7 @@ class RuntimeTemplate {
|
|
|
226
239
|
if (concatenationCost <= templateCost) return this._es5Concatenation(args);
|
|
227
240
|
|
|
228
241
|
return `\`${args
|
|
229
|
-
.map(arg => (typeof arg === "string" ? arg : `\${${arg.expr}}`))
|
|
242
|
+
.map((arg) => (typeof arg === "string" ? arg : `\${${arg.expr}}`))
|
|
230
243
|
.join("")}\``;
|
|
231
244
|
}
|
|
232
245
|
|
|
@@ -237,7 +250,7 @@ class RuntimeTemplate {
|
|
|
237
250
|
*/
|
|
238
251
|
_es5Concatenation(args) {
|
|
239
252
|
const str = args
|
|
240
|
-
.map(arg => (typeof arg === "string" ? JSON.stringify(arg) : arg.expr))
|
|
253
|
+
.map((arg) => (typeof arg === "string" ? JSON.stringify(arg) : arg.expr))
|
|
241
254
|
.join(" + ");
|
|
242
255
|
|
|
243
256
|
// when the first two args are expression, we need to prepend "" + to force string
|
|
@@ -287,7 +300,9 @@ class RuntimeTemplate {
|
|
|
287
300
|
return this.supportsDestructuring()
|
|
288
301
|
? `var {${items.join(", ")}} = ${value};`
|
|
289
302
|
: Template.asString(
|
|
290
|
-
items.map(
|
|
303
|
+
items.map(
|
|
304
|
+
(item) => `var ${item} = ${value}${propertyAccess([item])};`
|
|
305
|
+
)
|
|
291
306
|
);
|
|
292
307
|
}
|
|
293
308
|
|
|
@@ -329,12 +344,12 @@ class RuntimeTemplate {
|
|
|
329
344
|
if (this.outputOptions.pathinfo) {
|
|
330
345
|
content = [message, request, chunkName, chunkReason]
|
|
331
346
|
.filter(Boolean)
|
|
332
|
-
.map(item => this.requestShortener.shorten(item))
|
|
347
|
+
.map((item) => this.requestShortener.shorten(item))
|
|
333
348
|
.join(" | ");
|
|
334
349
|
} else {
|
|
335
350
|
content = [message, chunkName, chunkReason]
|
|
336
351
|
.filter(Boolean)
|
|
337
|
-
.map(item => this.requestShortener.shorten(item))
|
|
352
|
+
.map((item) => this.requestShortener.shorten(item))
|
|
338
353
|
.join(" | ");
|
|
339
354
|
}
|
|
340
355
|
if (!content) return "";
|
|
@@ -760,14 +775,14 @@ class RuntimeTemplate {
|
|
|
760
775
|
if (typeof runtimeCondition === "boolean") return `${runtimeCondition}`;
|
|
761
776
|
/** @type {Set<string>} */
|
|
762
777
|
const positiveRuntimeIds = new Set();
|
|
763
|
-
forEachRuntime(runtimeCondition, runtime =>
|
|
778
|
+
forEachRuntime(runtimeCondition, (runtime) =>
|
|
764
779
|
positiveRuntimeIds.add(
|
|
765
780
|
`${chunkGraph.getRuntimeId(/** @type {string} */ (runtime))}`
|
|
766
781
|
)
|
|
767
782
|
);
|
|
768
783
|
/** @type {Set<string>} */
|
|
769
784
|
const negativeRuntimeIds = new Set();
|
|
770
|
-
forEachRuntime(subtractRuntime(runtime, runtimeCondition), runtime =>
|
|
785
|
+
forEachRuntime(subtractRuntime(runtime, runtimeCondition), (runtime) =>
|
|
771
786
|
negativeRuntimeIds.add(
|
|
772
787
|
`${chunkGraph.getRuntimeId(/** @type {string} */ (runtime))}`
|
|
773
788
|
)
|
|
@@ -814,28 +829,6 @@ class RuntimeTemplate {
|
|
|
814
829
|
];
|
|
815
830
|
}
|
|
816
831
|
|
|
817
|
-
/** @type {Set<Module>} */
|
|
818
|
-
const innerAsyncDependencies = new Set();
|
|
819
|
-
defer = defer && (module.buildMeta ? !module.buildMeta.async : true);
|
|
820
|
-
|
|
821
|
-
if (this.compilation.options.experiments.deferImport && defer) {
|
|
822
|
-
const seen = new Set();
|
|
823
|
-
(function gatherInnerAsyncDependencies(mod) {
|
|
824
|
-
if (!moduleGraph.isAsync(mod) || seen.has(mod)) return;
|
|
825
|
-
seen.add(mod);
|
|
826
|
-
if (mod.buildMeta && mod.buildMeta.async) {
|
|
827
|
-
innerAsyncDependencies.add(mod);
|
|
828
|
-
} else {
|
|
829
|
-
for (const dep of mod.dependencies) {
|
|
830
|
-
const module = moduleGraph.getModule(dep);
|
|
831
|
-
if (module) {
|
|
832
|
-
gatherInnerAsyncDependencies(module);
|
|
833
|
-
}
|
|
834
|
-
}
|
|
835
|
-
}
|
|
836
|
-
})(module);
|
|
837
|
-
}
|
|
838
|
-
|
|
839
832
|
if (chunkGraph.getModuleId(module) === null) {
|
|
840
833
|
if (weak) {
|
|
841
834
|
// only weak referenced modules don't get an id
|
|
@@ -872,18 +865,22 @@ class RuntimeTemplate {
|
|
|
872
865
|
);
|
|
873
866
|
runtimeRequirements.add(RuntimeGlobals.require);
|
|
874
867
|
let importContent;
|
|
875
|
-
if (defer) {
|
|
868
|
+
if (defer && !(/** @type {BuildMeta} */ (module.buildMeta).async)) {
|
|
869
|
+
/** @type {Set<Module>} */
|
|
870
|
+
const outgoingAsyncModules = getOutgoingAsyncModules(moduleGraph, module);
|
|
871
|
+
|
|
876
872
|
importContent = `/* deferred harmony import */ ${optDeclaration}${importVar} = ${getOptimizedDeferredModule(
|
|
877
873
|
this,
|
|
878
874
|
exportsType,
|
|
879
875
|
moduleId,
|
|
880
|
-
Array.from(
|
|
876
|
+
Array.from(outgoingAsyncModules, (mod) => chunkGraph.getModuleId(mod))
|
|
881
877
|
)};\n`;
|
|
882
|
-
|
|
883
|
-
importContent
|
|
878
|
+
|
|
879
|
+
return [importContent, ""];
|
|
884
880
|
}
|
|
881
|
+
importContent = `/* harmony import */ ${optDeclaration}${importVar} = ${RuntimeGlobals.require}(${moduleId});\n`;
|
|
885
882
|
|
|
886
|
-
if (exportsType === "dynamic"
|
|
883
|
+
if (exportsType === "dynamic") {
|
|
887
884
|
runtimeRequirements.add(RuntimeGlobals.compatGetDefaultExport);
|
|
888
885
|
return [
|
|
889
886
|
importContent,
|
|
@@ -935,8 +932,6 @@ class RuntimeTemplate {
|
|
|
935
932
|
request
|
|
936
933
|
});
|
|
937
934
|
}
|
|
938
|
-
|
|
939
|
-
defer = defer && (module.buildMeta ? !module.buildMeta.async : true);
|
|
940
935
|
if (!Array.isArray(exportName)) {
|
|
941
936
|
exportName = exportName ? [exportName] : [];
|
|
942
937
|
}
|
|
@@ -946,10 +941,13 @@ class RuntimeTemplate {
|
|
|
946
941
|
(originModule.buildMeta).strictHarmonyModule
|
|
947
942
|
);
|
|
948
943
|
|
|
944
|
+
const isDeferred =
|
|
945
|
+
defer && !(/** @type {BuildMeta} */ (module.buildMeta).async);
|
|
946
|
+
|
|
949
947
|
if (defaultInterop) {
|
|
950
948
|
// when the defaultInterop is used (when a ESM imports a CJS module),
|
|
951
949
|
if (exportName.length > 0 && exportName[0] === "default") {
|
|
952
|
-
if (
|
|
950
|
+
if (isDeferred && exportsType !== "namespace") {
|
|
953
951
|
const access = `${importVar}.a${propertyAccess(exportName, 1)}`;
|
|
954
952
|
if (isCall || asiSafe === undefined) {
|
|
955
953
|
return access;
|
|
@@ -994,7 +992,7 @@ class RuntimeTemplate {
|
|
|
994
992
|
) {
|
|
995
993
|
return "/* __esModule */true";
|
|
996
994
|
}
|
|
997
|
-
} else if (
|
|
995
|
+
} else if (isDeferred) {
|
|
998
996
|
// now exportName.length is 0
|
|
999
997
|
// fall through to the end of this function, create the namespace there.
|
|
1000
998
|
} else if (
|
|
@@ -1037,7 +1035,7 @@ class RuntimeTemplate {
|
|
|
1037
1035
|
? ""
|
|
1038
1036
|
: `${Template.toNormalComment(propertyAccess(exportName))} `;
|
|
1039
1037
|
const access = `${importVar}${
|
|
1040
|
-
|
|
1038
|
+
isDeferred ? ".a" : ""
|
|
1041
1039
|
}${comment}${propertyAccess(used)}`;
|
|
1042
1040
|
if (isCall && callContext === false) {
|
|
1043
1041
|
return asiSafe
|
|
@@ -1048,7 +1046,7 @@ class RuntimeTemplate {
|
|
|
1048
1046
|
}
|
|
1049
1047
|
return access;
|
|
1050
1048
|
}
|
|
1051
|
-
if (
|
|
1049
|
+
if (isDeferred) {
|
|
1052
1050
|
initFragments.push(
|
|
1053
1051
|
new InitFragment(
|
|
1054
1052
|
`var ${importVar}_deferred_namespace_cache;\n`,
|
|
@@ -1098,7 +1096,7 @@ class RuntimeTemplate {
|
|
|
1098
1096
|
return `Promise.resolve(${comment.trim()})`;
|
|
1099
1097
|
}
|
|
1100
1098
|
const chunks = chunkGroup.chunks.filter(
|
|
1101
|
-
chunk => !chunk.hasRuntime() && chunk.id !== null
|
|
1099
|
+
(chunk) => !chunk.hasRuntime() && chunk.id !== null
|
|
1102
1100
|
);
|
|
1103
1101
|
const comment = this.comment({
|
|
1104
1102
|
message,
|
|
@@ -1130,7 +1128,7 @@ class RuntimeTemplate {
|
|
|
1130
1128
|
* @param {Chunk} chunk chunk
|
|
1131
1129
|
* @returns {string} require chunk id code
|
|
1132
1130
|
*/
|
|
1133
|
-
const requireChunkId = chunk =>
|
|
1131
|
+
const requireChunkId = (chunk) =>
|
|
1134
1132
|
`${RuntimeGlobals.ensureChunk}(${JSON.stringify(chunk.id)}${
|
|
1135
1133
|
fetchPriority ? `, ${JSON.stringify(fetchPriority)}` : ""
|
|
1136
1134
|
})`;
|
package/lib/SizeFormatHelpers.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* @param {number} size the size in bytes
|
|
10
10
|
* @returns {string} the formatted size
|
|
11
11
|
*/
|
|
12
|
-
module.exports.formatSize = size => {
|
|
12
|
+
module.exports.formatSize = (size) => {
|
|
13
13
|
if (typeof size !== "number" || Number.isNaN(size) === true) {
|
|
14
14
|
return "unknown size";
|
|
15
15
|
}
|
|
@@ -27,17 +27,17 @@ class SourceMapDevToolModuleOptionsPlugin {
|
|
|
27
27
|
apply(compilation) {
|
|
28
28
|
const options = this.options;
|
|
29
29
|
if (options.module !== false) {
|
|
30
|
-
compilation.hooks.buildModule.tap(PLUGIN_NAME, module => {
|
|
30
|
+
compilation.hooks.buildModule.tap(PLUGIN_NAME, (module) => {
|
|
31
31
|
module.useSourceMap = true;
|
|
32
32
|
});
|
|
33
|
-
compilation.hooks.runtimeModule.tap(PLUGIN_NAME, module => {
|
|
33
|
+
compilation.hooks.runtimeModule.tap(PLUGIN_NAME, (module) => {
|
|
34
34
|
module.useSourceMap = true;
|
|
35
35
|
});
|
|
36
36
|
} else {
|
|
37
|
-
compilation.hooks.buildModule.tap(PLUGIN_NAME, module => {
|
|
37
|
+
compilation.hooks.buildModule.tap(PLUGIN_NAME, (module) => {
|
|
38
38
|
module.useSimpleSourceMap = true;
|
|
39
39
|
});
|
|
40
|
-
compilation.hooks.runtimeModule.tap(PLUGIN_NAME, module => {
|
|
40
|
+
compilation.hooks.runtimeModule.tap(PLUGIN_NAME, (module) => {
|
|
41
41
|
module.useSimpleSourceMap = true;
|
|
42
42
|
});
|
|
43
43
|
}
|
|
@@ -65,7 +65,7 @@ const URL_FORMATTING_REGEXP = /^\n\/\/(.*)$/;
|
|
|
65
65
|
* @param {RegExp} regexp Stateful Regular Expression to be reset
|
|
66
66
|
* @returns {void}
|
|
67
67
|
*/
|
|
68
|
-
const resetRegexpState = regexp => {
|
|
68
|
+
const resetRegexpState = (regexp) => {
|
|
69
69
|
regexp.lastIndex = -1;
|
|
70
70
|
};
|
|
71
71
|
|
|
@@ -74,7 +74,7 @@ const resetRegexpState = regexp => {
|
|
|
74
74
|
* @param {string} str String to quote
|
|
75
75
|
* @returns {string} Escaped string
|
|
76
76
|
*/
|
|
77
|
-
const quoteMeta = str => str.replace(METACHARACTERS_REGEXP, "\\$&");
|
|
77
|
+
const quoteMeta = (str) => str.replace(METACHARACTERS_REGEXP, "\\$&");
|
|
78
78
|
|
|
79
79
|
/**
|
|
80
80
|
* Creating {@link SourceMapTask} for given file
|
|
@@ -112,7 +112,7 @@ const getTaskForFile = (
|
|
|
112
112
|
const context = /** @type {string} */ (compilation.options.context);
|
|
113
113
|
const root = compilation.compiler.root;
|
|
114
114
|
const cachedAbsolutify = makePathsAbsolute.bindContextCache(context, root);
|
|
115
|
-
const modules = sourceMap.sources.map(source => {
|
|
115
|
+
const modules = sourceMap.sources.map((source) => {
|
|
116
116
|
if (!source.startsWith("webpack://")) return source;
|
|
117
117
|
source = cachedAbsolutify(source.slice(10));
|
|
118
118
|
const module = compilation.findModule(source);
|
|
@@ -179,7 +179,7 @@ class SourceMapDevToolPlugin {
|
|
|
179
179
|
options
|
|
180
180
|
);
|
|
181
181
|
|
|
182
|
-
compiler.hooks.compilation.tap(PLUGIN_NAME, compilation => {
|
|
182
|
+
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
|
|
183
183
|
new SourceMapDevToolModuleOptionsPlugin(options).apply(compilation);
|
|
184
184
|
|
|
185
185
|
compilation.hooks.processAssets.tapAsync(
|
|
@@ -348,7 +348,7 @@ class SourceMapDevToolPlugin {
|
|
|
348
348
|
callback();
|
|
349
349
|
});
|
|
350
350
|
},
|
|
351
|
-
err => {
|
|
351
|
+
(err) => {
|
|
352
352
|
if (err) {
|
|
353
353
|
return callback(err);
|
|
354
354
|
}
|
|
@@ -431,7 +431,7 @@ class SourceMapDevToolPlugin {
|
|
|
431
431
|
"attach SourceMap"
|
|
432
432
|
);
|
|
433
433
|
|
|
434
|
-
const moduleFilenames = modules.map(m =>
|
|
434
|
+
const moduleFilenames = modules.map((m) =>
|
|
435
435
|
moduleToSourceNameMapping.get(m)
|
|
436
436
|
);
|
|
437
437
|
sourceMap.sources = /** @type {string[]} */ (moduleFilenames);
|
|
@@ -454,7 +454,7 @@ class SourceMapDevToolPlugin {
|
|
|
454
454
|
: quoteMeta(contenthash);
|
|
455
455
|
sourceMap.file = sourceMap.file.replace(
|
|
456
456
|
new RegExp(pattern, "g"),
|
|
457
|
-
m => "x".repeat(m.length)
|
|
457
|
+
(m) => "x".repeat(m.length)
|
|
458
458
|
);
|
|
459
459
|
}
|
|
460
460
|
|
|
@@ -584,7 +584,7 @@ class SourceMapDevToolPlugin {
|
|
|
584
584
|
compilation.updateAsset(file, asset);
|
|
585
585
|
}
|
|
586
586
|
|
|
587
|
-
task.cacheItem.store({ assets, assetsInfo }, err => {
|
|
587
|
+
task.cacheItem.store({ assets, assetsInfo }, (err) => {
|
|
588
588
|
reportProgress(
|
|
589
589
|
0.5 + (0.5 * ++taskIndex) / tasks.length,
|
|
590
590
|
task.file,
|
|
@@ -597,7 +597,7 @@ class SourceMapDevToolPlugin {
|
|
|
597
597
|
callback();
|
|
598
598
|
});
|
|
599
599
|
},
|
|
600
|
-
err => {
|
|
600
|
+
(err) => {
|
|
601
601
|
reportProgress(1);
|
|
602
602
|
callback(err);
|
|
603
603
|
}
|
package/lib/Stats.js
CHANGED
|
@@ -36,7 +36,7 @@ class Stats {
|
|
|
36
36
|
hasWarnings() {
|
|
37
37
|
return (
|
|
38
38
|
this.compilation.getWarnings().length > 0 ||
|
|
39
|
-
this.compilation.children.some(child => child.getStats().hasWarnings())
|
|
39
|
+
this.compilation.children.some((child) => child.getStats().hasWarnings())
|
|
40
40
|
);
|
|
41
41
|
}
|
|
42
42
|
|
|
@@ -46,7 +46,7 @@ class Stats {
|
|
|
46
46
|
hasErrors() {
|
|
47
47
|
return (
|
|
48
48
|
this.compilation.errors.length > 0 ||
|
|
49
|
-
this.compilation.children.some(child => child.getStats().hasErrors())
|
|
49
|
+
this.compilation.children.some((child) => child.getStats().hasErrors())
|
|
50
50
|
);
|
|
51
51
|
}
|
|
52
52
|
|
package/lib/Template.js
CHANGED
|
@@ -296,7 +296,7 @@ class Template {
|
|
|
296
296
|
return null;
|
|
297
297
|
}
|
|
298
298
|
/** @type {{id: string|number, source: Source|string}[]} */
|
|
299
|
-
const allModules = modules.map(module => ({
|
|
299
|
+
const allModules = modules.map((module) => ({
|
|
300
300
|
id: /** @type {ModuleId} */ (chunkGraph.getModuleId(module)),
|
|
301
301
|
source: renderModule(module) || "false"
|
|
302
302
|
}));
|
|
@@ -24,7 +24,7 @@ const REGEXP = /\[\\*([\w:]+)\\*\]/gi;
|
|
|
24
24
|
* @param {string | number} id id
|
|
25
25
|
* @returns {string | number} result
|
|
26
26
|
*/
|
|
27
|
-
const prepareId = id => {
|
|
27
|
+
const prepareId = (id) => {
|
|
28
28
|
if (typeof id !== "string") return id;
|
|
29
29
|
|
|
30
30
|
if (/^"\s\+*.*\+\s*"$/.test(id)) {
|
|
@@ -389,7 +389,7 @@ class TemplatedPathPlugin {
|
|
|
389
389
|
* @returns {void}
|
|
390
390
|
*/
|
|
391
391
|
apply(compiler) {
|
|
392
|
-
compiler.hooks.compilation.tap(plugin, compilation => {
|
|
392
|
+
compiler.hooks.compilation.tap(plugin, (compilation) => {
|
|
393
393
|
compilation.hooks.assetPath.tap(plugin, replacePathVariables);
|
|
394
394
|
});
|
|
395
395
|
}
|
package/lib/UseStrictPlugin.js
CHANGED
|
@@ -36,7 +36,7 @@ class UseStrictPlugin {
|
|
|
36
36
|
* @param {JavascriptParserOptions} parserOptions the javascript parser options
|
|
37
37
|
*/
|
|
38
38
|
const handler = (parser, parserOptions) => {
|
|
39
|
-
parser.hooks.program.tap(PLUGIN_NAME, ast => {
|
|
39
|
+
parser.hooks.program.tap(PLUGIN_NAME, (ast) => {
|
|
40
40
|
const firstNode = ast.body[0];
|
|
41
41
|
if (
|
|
42
42
|
firstNode &&
|
|
@@ -20,7 +20,7 @@ class WarnCaseSensitiveModulesPlugin {
|
|
|
20
20
|
* @returns {void}
|
|
21
21
|
*/
|
|
22
22
|
apply(compiler) {
|
|
23
|
-
compiler.hooks.compilation.tap(PLUGIN_NAME, compilation => {
|
|
23
|
+
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
|
|
24
24
|
compilation.hooks.seal.tap(PLUGIN_NAME, () => {
|
|
25
25
|
/** @type {Map<string, Map<string, Module>>} */
|
|
26
26
|
const moduleWithoutCase = new Map();
|
|
@@ -30,7 +30,7 @@ class WarnDeprecatedOptionPlugin {
|
|
|
30
30
|
* @returns {void}
|
|
31
31
|
*/
|
|
32
32
|
apply(compiler) {
|
|
33
|
-
compiler.hooks.thisCompilation.tap(PLUGIN_NAME, compilation => {
|
|
33
|
+
compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation) => {
|
|
34
34
|
compilation.warnings.push(
|
|
35
35
|
new DeprecatedOptionWarning(this.option, this.value, this.suggestion)
|
|
36
36
|
);
|
|
@@ -18,7 +18,7 @@ class WarnNoModeSetPlugin {
|
|
|
18
18
|
* @returns {void}
|
|
19
19
|
*/
|
|
20
20
|
apply(compiler) {
|
|
21
|
-
compiler.hooks.thisCompilation.tap(PLUGIN_NAME, compilation => {
|
|
21
|
+
compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation) => {
|
|
22
22
|
compilation.warnings.push(new NoModeWarning());
|
|
23
23
|
});
|
|
24
24
|
}
|
package/lib/WatchIgnorePlugin.js
CHANGED
|
@@ -45,8 +45,8 @@ class IgnoringWatchFileSystem {
|
|
|
45
45
|
* @param {string} path path to check
|
|
46
46
|
* @returns {boolean} true, if path is ignored
|
|
47
47
|
*/
|
|
48
|
-
const ignored = path =>
|
|
49
|
-
this.paths.some(p =>
|
|
48
|
+
const ignored = (path) =>
|
|
49
|
+
this.paths.some((p) =>
|
|
50
50
|
p instanceof RegExp ? p.test(path) : path.indexOf(p) === 0
|
|
51
51
|
);
|
|
52
52
|
|
package/lib/Watching.js
CHANGED
|
@@ -159,14 +159,14 @@ class Watching {
|
|
|
159
159
|
|
|
160
160
|
const run = () => {
|
|
161
161
|
if (this.compiler.idle) {
|
|
162
|
-
return this.compiler.cache.endIdle(err => {
|
|
162
|
+
return this.compiler.cache.endIdle((err) => {
|
|
163
163
|
if (err) return this._done(err);
|
|
164
164
|
this.compiler.idle = false;
|
|
165
165
|
run();
|
|
166
166
|
});
|
|
167
167
|
}
|
|
168
168
|
if (this._needRecords) {
|
|
169
|
-
return this.compiler.readRecords(err => {
|
|
169
|
+
return this.compiler.readRecords((err) => {
|
|
170
170
|
if (err) return this._done(err);
|
|
171
171
|
|
|
172
172
|
this._needRecords = false;
|
|
@@ -175,7 +175,7 @@ class Watching {
|
|
|
175
175
|
}
|
|
176
176
|
this.invalid = false;
|
|
177
177
|
this._invalidReported = false;
|
|
178
|
-
this.compiler.hooks.watchRun.callAsync(this.compiler, err => {
|
|
178
|
+
this.compiler.hooks.watchRun.callAsync(this.compiler, (err) => {
|
|
179
179
|
if (err) return this._done(err);
|
|
180
180
|
/**
|
|
181
181
|
* @param {Error | null} err error
|
|
@@ -196,13 +196,13 @@ class Watching {
|
|
|
196
196
|
process.nextTick(() => {
|
|
197
197
|
const logger = compilation.getLogger("webpack.Compiler");
|
|
198
198
|
logger.time("emitAssets");
|
|
199
|
-
this.compiler.emitAssets(compilation, err => {
|
|
199
|
+
this.compiler.emitAssets(compilation, (err) => {
|
|
200
200
|
logger.timeEnd("emitAssets");
|
|
201
201
|
if (err) return this._done(err, compilation);
|
|
202
202
|
if (this.invalid) return this._done(null, compilation);
|
|
203
203
|
|
|
204
204
|
logger.time("emitRecords");
|
|
205
|
-
this.compiler.emitRecords(err => {
|
|
205
|
+
this.compiler.emitRecords((err) => {
|
|
206
206
|
logger.timeEnd("emitRecords");
|
|
207
207
|
if (err) return this._done(err, compilation);
|
|
208
208
|
|
|
@@ -215,11 +215,11 @@ class Watching {
|
|
|
215
215
|
compilation.endTime = Date.now();
|
|
216
216
|
logger.time("done hook");
|
|
217
217
|
const stats = new Stats(compilation);
|
|
218
|
-
this.compiler.hooks.done.callAsync(stats, err => {
|
|
218
|
+
this.compiler.hooks.done.callAsync(stats, (err) => {
|
|
219
219
|
logger.timeEnd("done hook");
|
|
220
220
|
if (err) return this._done(err, compilation);
|
|
221
221
|
|
|
222
|
-
this.compiler.hooks.additionalPass.callAsync(err => {
|
|
222
|
+
this.compiler.hooks.additionalPass.callAsync((err) => {
|
|
223
223
|
if (err) return this._done(err, compilation);
|
|
224
224
|
this.compiler.compile(onCompiled);
|
|
225
225
|
});
|
|
@@ -288,7 +288,7 @@ class Watching {
|
|
|
288
288
|
logger.time("storeBuildDependencies");
|
|
289
289
|
this.compiler.cache.storeBuildDependencies(
|
|
290
290
|
compilation.buildDependencies,
|
|
291
|
-
err => {
|
|
291
|
+
(err) => {
|
|
292
292
|
logger.timeEnd("storeBuildDependencies");
|
|
293
293
|
if (err) return handleError(err);
|
|
294
294
|
this._go();
|
|
@@ -311,7 +311,7 @@ class Watching {
|
|
|
311
311
|
const cbs = this.callbacks;
|
|
312
312
|
this.callbacks = [];
|
|
313
313
|
logger.time("done hook");
|
|
314
|
-
this.compiler.hooks.done.callAsync(/** @type {Stats} */ (stats), err => {
|
|
314
|
+
this.compiler.hooks.done.callAsync(/** @type {Stats} */ (stats), (err) => {
|
|
315
315
|
logger.timeEnd("done hook");
|
|
316
316
|
if (err) return handleError(err, cbs);
|
|
317
317
|
this.handler(null, stats);
|
|
@@ -319,7 +319,7 @@ class Watching {
|
|
|
319
319
|
this.compiler.cache.storeBuildDependencies(
|
|
320
320
|
/** @type {Compilation} */
|
|
321
321
|
(compilation).buildDependencies,
|
|
322
|
-
err => {
|
|
322
|
+
(err) => {
|
|
323
323
|
logger.timeEnd("storeBuildDependencies");
|
|
324
324
|
if (err) return handleError(err, cbs);
|
|
325
325
|
logger.time("beginIdle");
|
|
@@ -480,7 +480,7 @@ class Watching {
|
|
|
480
480
|
/**
|
|
481
481
|
* @param {WebpackError | null} err error if any
|
|
482
482
|
*/
|
|
483
|
-
const shutdown = err => {
|
|
483
|
+
const shutdown = (err) => {
|
|
484
484
|
this.compiler.hooks.watchClose.call();
|
|
485
485
|
const closeCallbacks =
|
|
486
486
|
/** @type {Callback<void>[]} */
|
|
@@ -493,7 +493,7 @@ class Watching {
|
|
|
493
493
|
logger.time("storeBuildDependencies");
|
|
494
494
|
this.compiler.cache.storeBuildDependencies(
|
|
495
495
|
compilation.buildDependencies,
|
|
496
|
-
err2 => {
|
|
496
|
+
(err2) => {
|
|
497
497
|
logger.timeEnd("storeBuildDependencies");
|
|
498
498
|
shutdown(err || err2);
|
|
499
499
|
}
|
|
@@ -47,10 +47,10 @@ class WebpackIsIncludedPlugin {
|
|
|
47
47
|
* @param {JavascriptParser} parser the parser
|
|
48
48
|
* @returns {void}
|
|
49
49
|
*/
|
|
50
|
-
const handler = parser => {
|
|
50
|
+
const handler = (parser) => {
|
|
51
51
|
parser.hooks.call
|
|
52
52
|
.for("__webpack_is_included__")
|
|
53
|
-
.tap(PLUGIN_NAME, expr => {
|
|
53
|
+
.tap(PLUGIN_NAME, (expr) => {
|
|
54
54
|
if (
|
|
55
55
|
expr.type !== "CallExpression" ||
|
|
56
56
|
expr.arguments.length !== 1 ||
|
|
@@ -438,6 +438,13 @@ class WebpackOptionsApply extends OptionsApply {
|
|
|
438
438
|
new HttpUriPlugin(httpOptions).apply(compiler);
|
|
439
439
|
}
|
|
440
440
|
|
|
441
|
+
if (options.experiments.deferImport) {
|
|
442
|
+
const JavascriptParser = require("./javascript/JavascriptParser");
|
|
443
|
+
const importPhases = require("acorn-import-phases");
|
|
444
|
+
|
|
445
|
+
JavascriptParser.extend(importPhases({ source: false }));
|
|
446
|
+
}
|
|
447
|
+
|
|
441
448
|
new EntryOptionPlugin().apply(compiler);
|
|
442
449
|
compiler.hooks.entryOption.call(
|
|
443
450
|
/** @type {string} */
|
|
@@ -851,7 +858,7 @@ class WebpackOptionsApply extends OptionsApply {
|
|
|
851
858
|
}
|
|
852
859
|
compiler.resolverFactory.hooks.resolveOptions
|
|
853
860
|
.for("normal")
|
|
854
|
-
.tap(CLASS_NAME, resolveOptions => {
|
|
861
|
+
.tap(CLASS_NAME, (resolveOptions) => {
|
|
855
862
|
resolveOptions = cleverMerge(options.resolve, resolveOptions);
|
|
856
863
|
resolveOptions.fileSystem =
|
|
857
864
|
/** @type {InputFileSystem} */
|
|
@@ -860,7 +867,7 @@ class WebpackOptionsApply extends OptionsApply {
|
|
|
860
867
|
});
|
|
861
868
|
compiler.resolverFactory.hooks.resolveOptions
|
|
862
869
|
.for("context")
|
|
863
|
-
.tap(CLASS_NAME, resolveOptions => {
|
|
870
|
+
.tap(CLASS_NAME, (resolveOptions) => {
|
|
864
871
|
resolveOptions = cleverMerge(options.resolve, resolveOptions);
|
|
865
872
|
resolveOptions.fileSystem =
|
|
866
873
|
/** @type {InputFileSystem} */
|
|
@@ -870,7 +877,7 @@ class WebpackOptionsApply extends OptionsApply {
|
|
|
870
877
|
});
|
|
871
878
|
compiler.resolverFactory.hooks.resolveOptions
|
|
872
879
|
.for("loader")
|
|
873
|
-
.tap(CLASS_NAME, resolveOptions => {
|
|
880
|
+
.tap(CLASS_NAME, (resolveOptions) => {
|
|
874
881
|
resolveOptions = cleverMerge(options.resolveLoader, resolveOptions);
|
|
875
882
|
resolveOptions.fileSystem =
|
|
876
883
|
/** @type {InputFileSystem} */
|
|
@@ -57,8 +57,8 @@ const nonNumericOnlyHash = require("../util/nonNumericOnlyHash");
|
|
|
57
57
|
/**
|
|
58
58
|
* @template T
|
|
59
59
|
* @template U
|
|
60
|
-
* @param {string | Array<T> | Set<T> | undefined} a a
|
|
61
|
-
* @param {string | Array<U> | Set<U> | undefined} b b
|
|
60
|
+
* @param {null | string | Array<T> | Set<T> | undefined} a a
|
|
61
|
+
* @param {null | string | Array<U> | Set<U> | undefined} b b
|
|
62
62
|
* @returns {Array<T> & Array<U>} array
|
|
63
63
|
*/
|
|
64
64
|
const mergeMaybeArrays = (a, b) => {
|
|
@@ -152,7 +152,7 @@ const encodeDataUri = (encoding, source) => {
|
|
|
152
152
|
(encodedContent)
|
|
153
153
|
).replace(
|
|
154
154
|
/[!'()*]/g,
|
|
155
|
-
character =>
|
|
155
|
+
(character) =>
|
|
156
156
|
`%${/** @type {number} */ (character.codePointAt(0)).toString(16)}`
|
|
157
157
|
);
|
|
158
158
|
break;
|
|
@@ -31,7 +31,7 @@ const memoize = require("../util/memoize");
|
|
|
31
31
|
* @param {string} name name of definitions
|
|
32
32
|
* @returns {Schema} definition
|
|
33
33
|
*/
|
|
34
|
-
const getSchema = name => {
|
|
34
|
+
const getSchema = (name) => {
|
|
35
35
|
const { definitions } = require("../../schemas/WebpackOptions.json");
|
|
36
36
|
|
|
37
37
|
return {
|
|
@@ -93,7 +93,7 @@ class AssetModulesPlugin {
|
|
|
93
93
|
(compilation, { normalModuleFactory }) => {
|
|
94
94
|
normalModuleFactory.hooks.createParser
|
|
95
95
|
.for(ASSET_MODULE_TYPE)
|
|
96
|
-
.tap(PLUGIN_NAME, parserOptions => {
|
|
96
|
+
.tap(PLUGIN_NAME, (parserOptions) => {
|
|
97
97
|
validateParserOptions(parserOptions);
|
|
98
98
|
parserOptions = cleverMerge(
|
|
99
99
|
/** @type {AssetParserOptions} */
|
|
@@ -115,21 +115,21 @@ class AssetModulesPlugin {
|
|
|
115
115
|
});
|
|
116
116
|
normalModuleFactory.hooks.createParser
|
|
117
117
|
.for(ASSET_MODULE_TYPE_INLINE)
|
|
118
|
-
.tap(PLUGIN_NAME, _parserOptions => {
|
|
118
|
+
.tap(PLUGIN_NAME, (_parserOptions) => {
|
|
119
119
|
const AssetParser = getAssetParser();
|
|
120
120
|
|
|
121
121
|
return new AssetParser(true);
|
|
122
122
|
});
|
|
123
123
|
normalModuleFactory.hooks.createParser
|
|
124
124
|
.for(ASSET_MODULE_TYPE_RESOURCE)
|
|
125
|
-
.tap(PLUGIN_NAME, _parserOptions => {
|
|
125
|
+
.tap(PLUGIN_NAME, (_parserOptions) => {
|
|
126
126
|
const AssetParser = getAssetParser();
|
|
127
127
|
|
|
128
128
|
return new AssetParser(false);
|
|
129
129
|
});
|
|
130
130
|
normalModuleFactory.hooks.createParser
|
|
131
131
|
.for(ASSET_MODULE_TYPE_SOURCE)
|
|
132
|
-
.tap(PLUGIN_NAME, _parserOptions => {
|
|
132
|
+
.tap(PLUGIN_NAME, (_parserOptions) => {
|
|
133
133
|
const AssetSourceParser = getAssetSourceParser();
|
|
134
134
|
|
|
135
135
|
return new AssetSourceParser();
|
|
@@ -142,7 +142,7 @@ class AssetModulesPlugin {
|
|
|
142
142
|
]) {
|
|
143
143
|
normalModuleFactory.hooks.createGenerator
|
|
144
144
|
.for(type)
|
|
145
|
-
.tap(PLUGIN_NAME, generatorOptions => {
|
|
145
|
+
.tap(PLUGIN_NAME, (generatorOptions) => {
|
|
146
146
|
validateGeneratorOptions[type](generatorOptions);
|
|
147
147
|
|
|
148
148
|
let dataUrl;
|