webpack 5.100.2 → 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 +126 -113
- 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 +9 -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 +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 -12
- 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 +39 -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 +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 +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 +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 +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 +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 +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 +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 +151 -44
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
* @param {Omit<LazyCompilationDefaultBackendOptions, "client"> & { client: NonNullable<LazyCompilationDefaultBackendOptions["client"]>}} options additional options for the backend
|
|
23
23
|
* @returns {BackendHandler} backend
|
|
24
24
|
*/
|
|
25
|
-
module.exports = options => (compiler, callback) => {
|
|
25
|
+
module.exports = (options) => (compiler, callback) => {
|
|
26
26
|
const logger = compiler.getInfrastructureLogger("LazyCompilationBackend");
|
|
27
27
|
const activeModules = new Map();
|
|
28
28
|
const prefix = "/lazy-compilation-using-";
|
|
@@ -47,7 +47,7 @@ module.exports = options => (compiler, callback) => {
|
|
|
47
47
|
const listen =
|
|
48
48
|
typeof options.listen === "function"
|
|
49
49
|
? options.listen
|
|
50
|
-
: server => {
|
|
50
|
+
: (server) => {
|
|
51
51
|
let listen = options.listen;
|
|
52
52
|
if (typeof listen === "object" && !("port" in listen)) {
|
|
53
53
|
listen = { ...listen, port: undefined };
|
|
@@ -100,14 +100,14 @@ module.exports = options => (compiler, callback) => {
|
|
|
100
100
|
let isClosing = false;
|
|
101
101
|
/** @type {Set<import("net").Socket>} */
|
|
102
102
|
const sockets = new Set();
|
|
103
|
-
server.on("connection", socket => {
|
|
103
|
+
server.on("connection", (socket) => {
|
|
104
104
|
sockets.add(socket);
|
|
105
105
|
socket.on("close", () => {
|
|
106
106
|
sockets.delete(socket);
|
|
107
107
|
});
|
|
108
108
|
if (isClosing) socket.destroy();
|
|
109
109
|
});
|
|
110
|
-
server.on("clientError", e => {
|
|
110
|
+
server.on("clientError", (e) => {
|
|
111
111
|
if (e.message !== "Server is disposing") logger.warn(e);
|
|
112
112
|
});
|
|
113
113
|
|
|
@@ -117,7 +117,7 @@ module.exports = options => (compiler, callback) => {
|
|
|
117
117
|
* @param {Error} err error
|
|
118
118
|
* @returns {void}
|
|
119
119
|
*/
|
|
120
|
-
err => {
|
|
120
|
+
(err) => {
|
|
121
121
|
if (err) return callback(err);
|
|
122
122
|
const _addr = server.address();
|
|
123
123
|
if (typeof _addr === "string") {
|
|
@@ -138,7 +138,7 @@ module.exports = options => (compiler, callback) => {
|
|
|
138
138
|
isClosing = true;
|
|
139
139
|
// Removing the listener is a workaround for a memory leak in node.js
|
|
140
140
|
server.off("request", requestListener);
|
|
141
|
-
server.close(err => {
|
|
141
|
+
server.close((err) => {
|
|
142
142
|
callback(err);
|
|
143
143
|
});
|
|
144
144
|
for (const socket of sockets) {
|
|
@@ -39,13 +39,13 @@ class ChunkModuleIdRangePlugin {
|
|
|
39
39
|
*/
|
|
40
40
|
apply(compiler) {
|
|
41
41
|
const options = this.options;
|
|
42
|
-
compiler.hooks.compilation.tap(PLUGIN_NAME, compilation => {
|
|
42
|
+
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
|
|
43
43
|
const moduleGraph = compilation.moduleGraph;
|
|
44
|
-
compilation.hooks.moduleIds.tap(PLUGIN_NAME, modules => {
|
|
44
|
+
compilation.hooks.moduleIds.tap(PLUGIN_NAME, (modules) => {
|
|
45
45
|
const chunkGraph = compilation.chunkGraph;
|
|
46
46
|
const chunk = find(
|
|
47
47
|
compilation.chunks,
|
|
48
|
-
chunk => chunk.name === options.name
|
|
48
|
+
(chunk) => chunk.name === options.name
|
|
49
49
|
);
|
|
50
50
|
if (!chunk) {
|
|
51
51
|
throw new Error(
|
|
@@ -72,7 +72,7 @@ class ChunkModuleIdRangePlugin {
|
|
|
72
72
|
chunkModules = chunkGraph.getOrderedChunkModules(chunk, cmpFn);
|
|
73
73
|
} else {
|
|
74
74
|
chunkModules = [...modules]
|
|
75
|
-
.filter(m => chunkGraph.isModuleInChunk(m, chunk))
|
|
75
|
+
.filter((m) => chunkGraph.isModuleInChunk(m, chunk))
|
|
76
76
|
.sort(compareModulesByPreOrderIndexOrIdentifier(moduleGraph));
|
|
77
77
|
}
|
|
78
78
|
|
|
@@ -37,8 +37,8 @@ class DeterministicChunkIdsPlugin {
|
|
|
37
37
|
* @returns {void}
|
|
38
38
|
*/
|
|
39
39
|
apply(compiler) {
|
|
40
|
-
compiler.hooks.compilation.tap(PLUGIN_NAME, compilation => {
|
|
41
|
-
compilation.hooks.chunkIds.tap(PLUGIN_NAME, chunks => {
|
|
40
|
+
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
|
|
41
|
+
compilation.hooks.chunkIds.tap(PLUGIN_NAME, (chunks) => {
|
|
42
42
|
const chunkGraph = compilation.chunkGraph;
|
|
43
43
|
const context = this.options.context
|
|
44
44
|
? this.options.context
|
|
@@ -49,8 +49,9 @@ class DeterministicChunkIdsPlugin {
|
|
|
49
49
|
|
|
50
50
|
const usedIds = getUsedChunkIds(compilation);
|
|
51
51
|
assignDeterministicIds(
|
|
52
|
-
[...chunks].filter(chunk => chunk.id === null),
|
|
53
|
-
chunk =>
|
|
52
|
+
[...chunks].filter((chunk) => chunk.id === null),
|
|
53
|
+
(chunk) =>
|
|
54
|
+
getFullChunkName(chunk, chunkGraph, context, compiler.root),
|
|
54
55
|
compareNatural,
|
|
55
56
|
(chunk, id) => {
|
|
56
57
|
const size = usedIds.size;
|
|
@@ -43,7 +43,7 @@ class DeterministicModuleIdsPlugin {
|
|
|
43
43
|
* @returns {void}
|
|
44
44
|
*/
|
|
45
45
|
apply(compiler) {
|
|
46
|
-
compiler.hooks.compilation.tap(PLUGIN_NAME, compilation => {
|
|
46
|
+
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
|
|
47
47
|
compilation.hooks.moduleIds.tap(PLUGIN_NAME, () => {
|
|
48
48
|
const chunkGraph = compilation.chunkGraph;
|
|
49
49
|
const context = this.options.context
|
|
@@ -61,7 +61,7 @@ class DeterministicModuleIdsPlugin {
|
|
|
61
61
|
);
|
|
62
62
|
assignDeterministicIds(
|
|
63
63
|
modules,
|
|
64
|
-
module => getFullModuleName(module, context, compiler.root),
|
|
64
|
+
(module) => getFullModuleName(module, context, compiler.root),
|
|
65
65
|
failOnConflict
|
|
66
66
|
? () => 0
|
|
67
67
|
: compareModulesByPreOrderIndexOrIdentifier(
|
|
@@ -54,7 +54,7 @@ class HashedModuleIdsPlugin {
|
|
|
54
54
|
*/
|
|
55
55
|
apply(compiler) {
|
|
56
56
|
const options = this.options;
|
|
57
|
-
compiler.hooks.compilation.tap(PLUGIN_NAME, compilation => {
|
|
57
|
+
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
|
|
58
58
|
compilation.hooks.moduleIds.tap(PLUGIN_NAME, () => {
|
|
59
59
|
const chunkGraph = compilation.chunkGraph;
|
|
60
60
|
const context = this.options.context
|
package/lib/ids/IdHelpers.js
CHANGED
|
@@ -33,7 +33,7 @@ const getHash = (str, len, hashFunction) => {
|
|
|
33
33
|
* @param {string} str the string
|
|
34
34
|
* @returns {string} string prefixed by an underscore if it is a number
|
|
35
35
|
*/
|
|
36
|
-
const avoidNumber = str => {
|
|
36
|
+
const avoidNumber = (str) => {
|
|
37
37
|
// max length of a number is 21 chars, bigger numbers a written as "...e+xx"
|
|
38
38
|
if (str.length > 21) return str;
|
|
39
39
|
const firstChar = str.charCodeAt(0);
|
|
@@ -54,7 +54,7 @@ const avoidNumber = str => {
|
|
|
54
54
|
* @param {string} request the request
|
|
55
55
|
* @returns {string} id representation
|
|
56
56
|
*/
|
|
57
|
-
const requestToId = request =>
|
|
57
|
+
const requestToId = (request) =>
|
|
58
58
|
request.replace(/^(\.\.?\/)+/, "").replace(/(^[.-]|[^a-zA-Z0-9_-])+/g, "_");
|
|
59
59
|
|
|
60
60
|
/**
|
|
@@ -136,7 +136,7 @@ const getShortChunkName = (
|
|
|
136
136
|
associatedObjectForCache
|
|
137
137
|
) => {
|
|
138
138
|
const modules = chunkGraph.getChunkRootModules(chunk);
|
|
139
|
-
const shortModuleNames = modules.map(m =>
|
|
139
|
+
const shortModuleNames = modules.map((m) =>
|
|
140
140
|
requestToId(getShortModuleName(m, context, associatedObjectForCache))
|
|
141
141
|
);
|
|
142
142
|
chunk.idNameHints.sort();
|
|
@@ -164,10 +164,10 @@ const getLongChunkName = (
|
|
|
164
164
|
associatedObjectForCache
|
|
165
165
|
) => {
|
|
166
166
|
const modules = chunkGraph.getChunkRootModules(chunk);
|
|
167
|
-
const shortModuleNames = modules.map(m =>
|
|
167
|
+
const shortModuleNames = modules.map((m) =>
|
|
168
168
|
requestToId(getShortModuleName(m, context, associatedObjectForCache))
|
|
169
169
|
);
|
|
170
|
-
const longModuleNames = modules.map(m =>
|
|
170
|
+
const longModuleNames = modules.map((m) =>
|
|
171
171
|
requestToId(
|
|
172
172
|
getLongModuleName("", m, context, hashFunction, associatedObjectForCache)
|
|
173
173
|
)
|
|
@@ -198,7 +198,7 @@ const getFullChunkName = (
|
|
|
198
198
|
) => {
|
|
199
199
|
if (chunk.name) return chunk.name;
|
|
200
200
|
const modules = chunkGraph.getChunkRootModules(chunk);
|
|
201
|
-
const fullModuleNames = modules.map(m =>
|
|
201
|
+
const fullModuleNames = modules.map((m) =>
|
|
202
202
|
makePathsRelative(context, m.identifier(), associatedObjectForCache)
|
|
203
203
|
);
|
|
204
204
|
return fullModuleNames.join();
|
|
@@ -259,7 +259,7 @@ const getUsedModuleIdsAndModules = (compilation, filter) => {
|
|
|
259
259
|
* @param {Compilation} compilation the compilation
|
|
260
260
|
* @returns {Set<string>} used chunk ids as strings
|
|
261
261
|
*/
|
|
262
|
-
const getUsedChunkIds = compilation => {
|
|
262
|
+
const getUsedChunkIds = (compilation) => {
|
|
263
263
|
/** @type {Set<string>} */
|
|
264
264
|
const usedIds = new Set();
|
|
265
265
|
if (compilation.usedChunkIds) {
|
|
@@ -413,7 +413,7 @@ const assignAscendingModuleIds = (usedIds, modules, compilation) => {
|
|
|
413
413
|
/**
|
|
414
414
|
* @param {Module} module the module
|
|
415
415
|
*/
|
|
416
|
-
assignId = module => {
|
|
416
|
+
assignId = (module) => {
|
|
417
417
|
if (chunkGraph.getModuleId(module) === null) {
|
|
418
418
|
while (usedIds.has(String(nextId))) nextId++;
|
|
419
419
|
chunkGraph.setModuleId(module, nextId++);
|
|
@@ -423,7 +423,7 @@ const assignAscendingModuleIds = (usedIds, modules, compilation) => {
|
|
|
423
423
|
/**
|
|
424
424
|
* @param {Module} module the module
|
|
425
425
|
*/
|
|
426
|
-
assignId = module => {
|
|
426
|
+
assignId = (module) => {
|
|
427
427
|
if (chunkGraph.getModuleId(module) === null) {
|
|
428
428
|
chunkGraph.setModuleId(module, nextId++);
|
|
429
429
|
}
|
|
@@ -42,24 +42,24 @@ class NamedChunkIdsPlugin {
|
|
|
42
42
|
* @returns {void}
|
|
43
43
|
*/
|
|
44
44
|
apply(compiler) {
|
|
45
|
-
compiler.hooks.compilation.tap(PLUGIN_NAME, compilation => {
|
|
45
|
+
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
|
|
46
46
|
const hashFunction =
|
|
47
47
|
/** @type {NonNullable<Output["hashFunction"]>} */
|
|
48
48
|
(compilation.outputOptions.hashFunction);
|
|
49
|
-
compilation.hooks.chunkIds.tap(PLUGIN_NAME, chunks => {
|
|
49
|
+
compilation.hooks.chunkIds.tap(PLUGIN_NAME, (chunks) => {
|
|
50
50
|
const chunkGraph = compilation.chunkGraph;
|
|
51
51
|
const context = this.context ? this.context : compiler.context;
|
|
52
52
|
const delimiter = this.delimiter;
|
|
53
53
|
|
|
54
54
|
const unnamedChunks = assignNames(
|
|
55
|
-
[...chunks].filter(chunk => {
|
|
55
|
+
[...chunks].filter((chunk) => {
|
|
56
56
|
if (chunk.name) {
|
|
57
57
|
chunk.id = chunk.name;
|
|
58
58
|
chunk.ids = [chunk.name];
|
|
59
59
|
}
|
|
60
60
|
return chunk.id === null;
|
|
61
61
|
}),
|
|
62
|
-
chunk =>
|
|
62
|
+
(chunk) =>
|
|
63
63
|
getShortChunkName(
|
|
64
64
|
chunk,
|
|
65
65
|
chunkGraph,
|
|
@@ -68,7 +68,7 @@ class NamedChunkIdsPlugin {
|
|
|
68
68
|
hashFunction,
|
|
69
69
|
compiler.root
|
|
70
70
|
),
|
|
71
|
-
chunk =>
|
|
71
|
+
(chunk) =>
|
|
72
72
|
getLongChunkName(
|
|
73
73
|
chunk,
|
|
74
74
|
chunkGraph,
|
|
@@ -40,7 +40,7 @@ class NamedModuleIdsPlugin {
|
|
|
40
40
|
*/
|
|
41
41
|
apply(compiler) {
|
|
42
42
|
const { root } = compiler;
|
|
43
|
-
compiler.hooks.compilation.tap(PLUGIN_NAME, compilation => {
|
|
43
|
+
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
|
|
44
44
|
const hashFunction =
|
|
45
45
|
/** @type {NonNullable<Output["hashFunction"]>} */
|
|
46
46
|
(compilation.outputOptions.hashFunction);
|
|
@@ -53,7 +53,7 @@ class NamedModuleIdsPlugin {
|
|
|
53
53
|
const [usedIds, modules] = getUsedModuleIdsAndModules(compilation);
|
|
54
54
|
const unnamedModules = assignNames(
|
|
55
55
|
modules,
|
|
56
|
-
m => getShortModuleName(m, context, root),
|
|
56
|
+
(m) => getShortModuleName(m, context, root),
|
|
57
57
|
(m, shortName) =>
|
|
58
58
|
getLongModuleName(shortName, m, context, hashFunction, root),
|
|
59
59
|
compareModulesByIdentifier,
|
|
@@ -21,8 +21,8 @@ class NaturalChunkIdsPlugin {
|
|
|
21
21
|
* @returns {void}
|
|
22
22
|
*/
|
|
23
23
|
apply(compiler) {
|
|
24
|
-
compiler.hooks.compilation.tap(PLUGIN_NAME, compilation => {
|
|
25
|
-
compilation.hooks.chunkIds.tap(PLUGIN_NAME, chunks => {
|
|
24
|
+
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
|
|
25
|
+
compilation.hooks.chunkIds.tap(PLUGIN_NAME, (chunks) => {
|
|
26
26
|
const chunkGraph = compilation.chunkGraph;
|
|
27
27
|
const compareNatural = compareChunksNatural(chunkGraph);
|
|
28
28
|
/** @type {Chunk[]} */
|
|
@@ -25,7 +25,7 @@ class NaturalModuleIdsPlugin {
|
|
|
25
25
|
* @returns {void}
|
|
26
26
|
*/
|
|
27
27
|
apply(compiler) {
|
|
28
|
-
compiler.hooks.compilation.tap(PLUGIN_NAME, compilation => {
|
|
28
|
+
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
|
|
29
29
|
compilation.hooks.moduleIds.tap(PLUGIN_NAME, () => {
|
|
30
30
|
const [usedIds, modulesInNaturalOrder] =
|
|
31
31
|
getUsedModuleIdsAndModules(compilation);
|
|
@@ -41,8 +41,8 @@ class OccurrenceChunkIdsPlugin {
|
|
|
41
41
|
*/
|
|
42
42
|
apply(compiler) {
|
|
43
43
|
const prioritiseInitial = this.options.prioritiseInitial;
|
|
44
|
-
compiler.hooks.compilation.tap(PLUGIN_NAME, compilation => {
|
|
45
|
-
compilation.hooks.chunkIds.tap(PLUGIN_NAME, chunks => {
|
|
44
|
+
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
|
|
45
|
+
compilation.hooks.chunkIds.tap(PLUGIN_NAME, (chunks) => {
|
|
46
46
|
const chunkGraph = compilation.chunkGraph;
|
|
47
47
|
|
|
48
48
|
/** @type {Map<Chunk, number>} */
|
|
@@ -46,7 +46,7 @@ class OccurrenceModuleIdsPlugin {
|
|
|
46
46
|
*/
|
|
47
47
|
apply(compiler) {
|
|
48
48
|
const prioritiseInitial = this.options.prioritiseInitial;
|
|
49
|
-
compiler.hooks.compilation.tap(PLUGIN_NAME, compilation => {
|
|
49
|
+
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
|
|
50
50
|
const moduleGraph = compilation.moduleGraph;
|
|
51
51
|
|
|
52
52
|
compilation.hooks.moduleIds.tap(PLUGIN_NAME, () => {
|
|
@@ -75,14 +75,14 @@ class OccurrenceModuleIdsPlugin {
|
|
|
75
75
|
* @param {Module} module module
|
|
76
76
|
* @returns {number} count of occurs
|
|
77
77
|
*/
|
|
78
|
-
const countOccursInEntry = module => {
|
|
78
|
+
const countOccursInEntry = (module) => {
|
|
79
79
|
let sum = 0;
|
|
80
80
|
for (const [
|
|
81
81
|
originModule,
|
|
82
82
|
connections
|
|
83
83
|
] of moduleGraph.getIncomingConnectionsByOriginModule(module)) {
|
|
84
84
|
if (!originModule) continue;
|
|
85
|
-
if (!connections.some(c => c.isTargetActive(undefined))) continue;
|
|
85
|
+
if (!connections.some((c) => c.isTargetActive(undefined))) continue;
|
|
86
86
|
sum += initialChunkChunkMap.get(originModule) || 0;
|
|
87
87
|
}
|
|
88
88
|
return sum;
|
|
@@ -92,7 +92,7 @@ class OccurrenceModuleIdsPlugin {
|
|
|
92
92
|
* @param {Module} module module
|
|
93
93
|
* @returns {number} count of occurs
|
|
94
94
|
*/
|
|
95
|
-
const countOccurs = module => {
|
|
95
|
+
const countOccurs = (module) => {
|
|
96
96
|
let sum = 0;
|
|
97
97
|
for (const [
|
|
98
98
|
originModule,
|
|
@@ -46,7 +46,7 @@ class SyncModuleIdsPlugin {
|
|
|
46
46
|
let data;
|
|
47
47
|
let dataChanged = false;
|
|
48
48
|
if (this._read) {
|
|
49
|
-
compiler.hooks.readRecords.tapAsync(plugin, callback => {
|
|
49
|
+
compiler.hooks.readRecords.tapAsync(plugin, (callback) => {
|
|
50
50
|
const fs =
|
|
51
51
|
/** @type {IntermediateFileSystem} */
|
|
52
52
|
(compiler.intermediateFileSystem);
|
|
@@ -68,7 +68,7 @@ class SyncModuleIdsPlugin {
|
|
|
68
68
|
});
|
|
69
69
|
}
|
|
70
70
|
if (this._write) {
|
|
71
|
-
compiler.hooks.emitRecords.tapAsync(plugin, callback => {
|
|
71
|
+
compiler.hooks.emitRecords.tapAsync(plugin, (callback) => {
|
|
72
72
|
if (!data || !dataChanged) return callback();
|
|
73
73
|
/** @type {{[key: string]: string | number}} */
|
|
74
74
|
const json = {};
|
|
@@ -82,7 +82,7 @@ class SyncModuleIdsPlugin {
|
|
|
82
82
|
fs.writeFile(this._path, JSON.stringify(json), callback);
|
|
83
83
|
});
|
|
84
84
|
}
|
|
85
|
-
compiler.hooks.thisCompilation.tap(plugin, compilation => {
|
|
85
|
+
compiler.hooks.thisCompilation.tap(plugin, (compilation) => {
|
|
86
86
|
const associatedObjectForCache = compiler.root;
|
|
87
87
|
const context = this._context || compiler.context;
|
|
88
88
|
if (this._read) {
|
|
@@ -114,7 +114,7 @@ class SyncModuleIdsPlugin {
|
|
|
114
114
|
});
|
|
115
115
|
}
|
|
116
116
|
if (this._write) {
|
|
117
|
-
compilation.hooks.recordModules.tap(plugin, modules => {
|
|
117
|
+
compilation.hooks.recordModules.tap(plugin, (modules) => {
|
|
118
118
|
const { chunkGraph } = compilation;
|
|
119
119
|
let oldData = data;
|
|
120
120
|
if (!oldData) {
|
package/lib/index.js
CHANGED
|
@@ -49,7 +49,9 @@ const memoize = require("./util/memoize");
|
|
|
49
49
|
/** @typedef {import("./Compiler").AssetEmittedInfo} AssetEmittedInfo */
|
|
50
50
|
/** @typedef {import("./Entrypoint")} Entrypoint */
|
|
51
51
|
/** @typedef {import("./MultiCompiler").MultiCompilerOptions} MultiCompilerOptions */
|
|
52
|
+
/** @typedef {import("./MultiCompiler").MultiWebpackOptions} MultiConfiguration */
|
|
52
53
|
/** @typedef {import("./MultiStats")} MultiStats */
|
|
54
|
+
/** @typedef {import("./MultiStats").MultiStatsOptions} MultiStatsOptions */
|
|
53
55
|
/** @typedef {import("./NormalModuleFactory").ResolveData} ResolveData */
|
|
54
56
|
/** @typedef {import("./Parser").ParserState} ParserState */
|
|
55
57
|
/** @typedef {import("./ResolverFactory").ResolvePluginInstance} ResolvePluginInstance */
|
|
@@ -57,6 +59,8 @@ const memoize = require("./util/memoize");
|
|
|
57
59
|
/** @typedef {import("./Watching")} Watching */
|
|
58
60
|
/** @typedef {import("./cli").Argument} Argument */
|
|
59
61
|
/** @typedef {import("./cli").Problem} Problem */
|
|
62
|
+
/** @typedef {import("./cli").Colors} Colors */
|
|
63
|
+
/** @typedef {import("./cli").ColorsOptions} ColorsOptions */
|
|
60
64
|
/** @typedef {import("./stats/DefaultStatsFactoryPlugin").StatsAsset} StatsAsset */
|
|
61
65
|
/** @typedef {import("./stats/DefaultStatsFactoryPlugin").StatsChunk} StatsChunk */
|
|
62
66
|
/** @typedef {import("./stats/DefaultStatsFactoryPlugin").StatsChunkGroup} StatsChunkGroup */
|
|
@@ -79,7 +83,7 @@ const memoize = require("./util/memoize");
|
|
|
79
83
|
* @param {() => T} factory factory function
|
|
80
84
|
* @returns {T} function
|
|
81
85
|
*/
|
|
82
|
-
const lazyFunction = factory => {
|
|
86
|
+
const lazyFunction = (factory) => {
|
|
83
87
|
const fac = memoize(factory);
|
|
84
88
|
const f = /** @type {unknown} */ (
|
|
85
89
|
/**
|
|
@@ -132,25 +136,25 @@ module.exports = mergeExports(fn, {
|
|
|
132
136
|
return require("./webpack");
|
|
133
137
|
},
|
|
134
138
|
/**
|
|
135
|
-
* @returns {(configuration: Configuration |
|
|
139
|
+
* @returns {(configuration: Configuration | MultiConfiguration) => void} validate fn
|
|
136
140
|
*/
|
|
137
141
|
get validate() {
|
|
138
142
|
const webpackOptionsSchemaCheck =
|
|
139
|
-
/** @type {(configuration: Configuration |
|
|
143
|
+
/** @type {(configuration: Configuration | MultiConfiguration) => boolean} */
|
|
140
144
|
(require("../schemas/WebpackOptions.check"));
|
|
141
145
|
|
|
142
146
|
const getRealValidate = memoize(
|
|
143
147
|
/**
|
|
144
|
-
* @returns {(configuration: Configuration |
|
|
148
|
+
* @returns {(configuration: Configuration | MultiConfiguration) => void} validate fn
|
|
145
149
|
*/
|
|
146
150
|
() => {
|
|
147
151
|
const validateSchema = require("./validateSchema");
|
|
148
152
|
const webpackOptionsSchema = require("../schemas/WebpackOptions.json");
|
|
149
153
|
|
|
150
|
-
return options => validateSchema(webpackOptionsSchema, options);
|
|
154
|
+
return (options) => validateSchema(webpackOptionsSchema, options);
|
|
151
155
|
}
|
|
152
156
|
);
|
|
153
|
-
return options => {
|
|
157
|
+
return (options) => {
|
|
154
158
|
if (!webpackOptionsSchemaCheck(options)) {
|
|
155
159
|
getRealValidate()(options);
|
|
156
160
|
}
|
|
@@ -27,7 +27,7 @@ class ArrayPushCallbackChunkFormatPlugin {
|
|
|
27
27
|
* @returns {void}
|
|
28
28
|
*/
|
|
29
29
|
apply(compiler) {
|
|
30
|
-
compiler.hooks.thisCompilation.tap(PLUGIN_NAME, compilation => {
|
|
30
|
+
compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation) => {
|
|
31
31
|
compilation.hooks.additionalChunkRuntimeRequirements.tap(
|
|
32
32
|
PLUGIN_NAME,
|
|
33
33
|
(chunk, set, { chunkGraph }) => {
|
|
@@ -463,7 +463,7 @@ class BasicEvaluatedExpression {
|
|
|
463
463
|
setItems(items) {
|
|
464
464
|
this.type = TypeArray;
|
|
465
465
|
this.items = items;
|
|
466
|
-
this.sideEffects = items.some(i => i.couldHaveSideEffects());
|
|
466
|
+
this.sideEffects = items.some((i) => i.couldHaveSideEffects());
|
|
467
467
|
return this;
|
|
468
468
|
}
|
|
469
469
|
|
|
@@ -492,7 +492,7 @@ class BasicEvaluatedExpression {
|
|
|
492
492
|
this.quasis = quasis;
|
|
493
493
|
this.parts = parts;
|
|
494
494
|
this.templateStringKind = kind;
|
|
495
|
-
this.sideEffects = parts.some(p => p.sideEffects);
|
|
495
|
+
this.sideEffects = parts.some((p) => p.sideEffects);
|
|
496
496
|
return this;
|
|
497
497
|
}
|
|
498
498
|
|
|
@@ -557,7 +557,7 @@ class BasicEvaluatedExpression {
|
|
|
557
557
|
* @param {string} flags regexp flags
|
|
558
558
|
* @returns {boolean} is valid flags
|
|
559
559
|
*/
|
|
560
|
-
BasicEvaluatedExpression.isValidRegExpFlags = flags => {
|
|
560
|
+
BasicEvaluatedExpression.isValidRegExpFlags = (flags) => {
|
|
561
561
|
const len = flags.length;
|
|
562
562
|
|
|
563
563
|
if (len === 0) return true;
|
|
@@ -31,7 +31,7 @@ class CommonJsChunkFormatPlugin {
|
|
|
31
31
|
* @returns {void}
|
|
32
32
|
*/
|
|
33
33
|
apply(compiler) {
|
|
34
|
-
compiler.hooks.thisCompilation.tap(PLUGIN_NAME, compilation => {
|
|
34
|
+
compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation) => {
|
|
35
35
|
compilation.hooks.additionalChunkRuntimeRequirements.tap(
|
|
36
36
|
PLUGIN_NAME,
|
|
37
37
|
(chunk, set, { chunkGraph }) => {
|
|
@@ -15,7 +15,7 @@ const enabledTypes = new WeakMap();
|
|
|
15
15
|
* @param {Compiler} compiler compiler
|
|
16
16
|
* @returns {Set<ChunkLoadingType>} enabled types
|
|
17
17
|
*/
|
|
18
|
-
const getEnabledTypes = compiler => {
|
|
18
|
+
const getEnabledTypes = (compiler) => {
|
|
19
19
|
let set = enabledTypes.get(compiler);
|
|
20
20
|
if (set === undefined) {
|
|
21
21
|
set = new Set();
|
|
@@ -88,7 +88,7 @@ class JavascriptGenerator extends Generator {
|
|
|
88
88
|
module.buildMeta.exportsType !== "namespace" ||
|
|
89
89
|
module.presentationalDependencies === undefined ||
|
|
90
90
|
!module.presentationalDependencies.some(
|
|
91
|
-
d => d instanceof HarmonyCompatibilityDependency
|
|
91
|
+
(d) => d instanceof HarmonyCompatibilityDependency
|
|
92
92
|
)
|
|
93
93
|
) {
|
|
94
94
|
return "Module is not an ECMAScript module";
|
|
@@ -186,7 +186,7 @@ const printGeneratedCodeForStack = (module, code) => {
|
|
|
186
186
|
* @property {SyncWaterfallHook<[Source, RenderContext]>} render
|
|
187
187
|
* @property {SyncWaterfallHook<[Source, Module, StartupRenderContext]>} renderStartup
|
|
188
188
|
* @property {SyncWaterfallHook<[string, RenderBootstrapContext]>} renderRequire
|
|
189
|
-
* @property {SyncBailHook<[Module, RenderBootstrapContext], string | void>} inlineInRuntimeBailout
|
|
189
|
+
* @property {SyncBailHook<[Module, Partial<RenderBootstrapContext>], string | void>} inlineInRuntimeBailout
|
|
190
190
|
* @property {SyncBailHook<[Module, RenderContext], string | void>} embedInRuntimeBailout
|
|
191
191
|
* @property {SyncBailHook<[RenderContext], string | void>} strictRuntimeBailout
|
|
192
192
|
* @property {SyncHook<[Chunk, Hash, ChunkHashContext]>} chunkHash
|
|
@@ -274,7 +274,7 @@ class JavascriptModulesPlugin {
|
|
|
274
274
|
]) {
|
|
275
275
|
normalModuleFactory.hooks.createParser
|
|
276
276
|
.for(type)
|
|
277
|
-
.tap(PLUGIN_NAME, _options => {
|
|
277
|
+
.tap(PLUGIN_NAME, (_options) => {
|
|
278
278
|
switch (type) {
|
|
279
279
|
case JAVASCRIPT_MODULE_TYPE_AUTO: {
|
|
280
280
|
return new JavascriptParser("auto");
|
|
@@ -417,7 +417,7 @@ class JavascriptModulesPlugin {
|
|
|
417
417
|
);
|
|
418
418
|
}
|
|
419
419
|
});
|
|
420
|
-
compilation.hooks.contentHash.tap(PLUGIN_NAME, chunk => {
|
|
420
|
+
compilation.hooks.contentHash.tap(PLUGIN_NAME, (chunk) => {
|
|
421
421
|
const {
|
|
422
422
|
chunkGraph,
|
|
423
423
|
codeGenerationResults,
|
|
@@ -713,7 +713,7 @@ class JavascriptModulesPlugin {
|
|
|
713
713
|
let allStrict = renderContext.strictMode;
|
|
714
714
|
if (
|
|
715
715
|
!allStrict &&
|
|
716
|
-
allModules.every(m => /** @type {BuildInfo} */ (m.buildInfo).strict)
|
|
716
|
+
allModules.every((m) => /** @type {BuildInfo} */ (m.buildInfo).strict)
|
|
717
717
|
) {
|
|
718
718
|
const strictBailout = hooks.strictRuntimeBailout.call(renderContext);
|
|
719
719
|
strictHeader = strictBailout
|
|
@@ -728,7 +728,7 @@ class JavascriptModulesPlugin {
|
|
|
728
728
|
strictMode: allStrict
|
|
729
729
|
};
|
|
730
730
|
const moduleSources =
|
|
731
|
-
Template.renderChunkModules(chunkRenderContext, allModules, module =>
|
|
731
|
+
Template.renderChunkModules(chunkRenderContext, allModules, (module) =>
|
|
732
732
|
this.renderModule(module, chunkRenderContext, hooks, true)
|
|
733
733
|
) || new RawSource("{}");
|
|
734
734
|
let source = tryRunOrWebpackError(
|
|
@@ -812,7 +812,7 @@ class JavascriptModulesPlugin {
|
|
|
812
812
|
let allStrict = renderContext.strictMode;
|
|
813
813
|
if (
|
|
814
814
|
!allStrict &&
|
|
815
|
-
allModules.every(m => /** @type {BuildInfo} */ (m.buildInfo).strict)
|
|
815
|
+
allModules.every((m) => /** @type {BuildInfo} */ (m.buildInfo).strict)
|
|
816
816
|
) {
|
|
817
817
|
const strictBailout = hooks.strictRuntimeBailout.call(renderContext);
|
|
818
818
|
if (strictBailout) {
|
|
@@ -838,10 +838,10 @@ class JavascriptModulesPlugin {
|
|
|
838
838
|
chunkRenderContext,
|
|
839
839
|
inlinedModules
|
|
840
840
|
? allModules.filter(
|
|
841
|
-
m => !(/** @type {Set<Module>} */ (inlinedModules).has(m))
|
|
841
|
+
(m) => !(/** @type {Set<Module>} */ (inlinedModules).has(m))
|
|
842
842
|
)
|
|
843
843
|
: allModules,
|
|
844
|
-
module => this.renderModule(module, chunkRenderContext, hooks, true),
|
|
844
|
+
(module) => this.renderModule(module, chunkRenderContext, hooks, true),
|
|
845
845
|
prefix
|
|
846
846
|
);
|
|
847
847
|
if (
|
|
@@ -1011,7 +1011,7 @@ class JavascriptModulesPlugin {
|
|
|
1011
1011
|
const toSource = useSourceMap
|
|
1012
1012
|
? (content, name) =>
|
|
1013
1013
|
new OriginalSource(Template.asString(content), name)
|
|
1014
|
-
: content => new RawSource(Template.asString(content));
|
|
1014
|
+
: (content) => new RawSource(Template.asString(content));
|
|
1015
1015
|
source.add(
|
|
1016
1016
|
new PrefixSource(
|
|
1017
1017
|
prefix,
|
|
@@ -1229,7 +1229,7 @@ class JavascriptModulesPlugin {
|
|
|
1229
1229
|
}
|
|
1230
1230
|
const chunks =
|
|
1231
1231
|
/** @type {Entrypoint} */
|
|
1232
|
-
(entrypoint).chunks.filter(c => c !== chunk);
|
|
1232
|
+
(entrypoint).chunks.filter((c) => c !== chunk);
|
|
1233
1233
|
if (result.allowInlineStartup && chunks.length > 0) {
|
|
1234
1234
|
buf2.push(
|
|
1235
1235
|
"// This entry module depends on other loaded chunks and execution need to be delayed"
|
|
@@ -1242,10 +1242,10 @@ class JavascriptModulesPlugin {
|
|
|
1242
1242
|
moduleGraph.getIncomingConnectionsByOriginModule(entryModule),
|
|
1243
1243
|
([originModule, connections]) =>
|
|
1244
1244
|
originModule &&
|
|
1245
|
-
connections.some(c => c.isTargetActive(chunk.runtime)) &&
|
|
1245
|
+
connections.some((c) => c.isTargetActive(chunk.runtime)) &&
|
|
1246
1246
|
someInIterable(
|
|
1247
1247
|
chunkGraph.getModuleRuntimes(originModule),
|
|
1248
|
-
runtime =>
|
|
1248
|
+
(runtime) =>
|
|
1249
1249
|
intersectRuntime(runtime, chunk.runtime) !== undefined
|
|
1250
1250
|
)
|
|
1251
1251
|
)
|
|
@@ -1309,7 +1309,7 @@ class JavascriptModulesPlugin {
|
|
|
1309
1309
|
`${i === 0 ? `var ${RuntimeGlobals.exports} = ` : ""}${
|
|
1310
1310
|
RuntimeGlobals.onChunksLoaded
|
|
1311
1311
|
}(undefined, ${JSON.stringify(
|
|
1312
|
-
chunks.map(c => c.id)
|
|
1312
|
+
chunks.map((c) => c.id)
|
|
1313
1313
|
)}, ${runtimeTemplate.returningFunction(
|
|
1314
1314
|
`${RuntimeGlobals.require}(${moduleIdExpr})`
|
|
1315
1315
|
)})`
|
|
@@ -1554,7 +1554,7 @@ class JavascriptModulesPlugin {
|
|
|
1554
1554
|
) {
|
|
1555
1555
|
const innerStrict =
|
|
1556
1556
|
!allStrict &&
|
|
1557
|
-
allModules.every(m => /** @type {BuildInfo} */ (m.buildInfo).strict);
|
|
1557
|
+
allModules.every((m) => /** @type {BuildInfo} */ (m.buildInfo).strict);
|
|
1558
1558
|
const isMultipleEntries = inlinedModules.size > 1;
|
|
1559
1559
|
const singleEntryWithModules = inlinedModules.size === 1 && hasChunkModules;
|
|
1560
1560
|
|
|
@@ -1639,7 +1639,7 @@ class JavascriptModulesPlugin {
|
|
|
1639
1639
|
|
|
1640
1640
|
const info = /** @type {Info} */ (inlinedModulesToInfo.get(m));
|
|
1641
1641
|
const allUsedNames = new Set(
|
|
1642
|
-
Array.from(info.through, v => v.identifier.name)
|
|
1642
|
+
Array.from(info.through, (v) => v.identifier.name)
|
|
1643
1643
|
);
|
|
1644
1644
|
|
|
1645
1645
|
for (const variable of usedInNonInlined) {
|
|
@@ -1660,7 +1660,7 @@ class JavascriptModulesPlugin {
|
|
|
1660
1660
|
if (allUsedNames.has(name) || usedNames.has(name)) {
|
|
1661
1661
|
const references = getAllReferences(variable);
|
|
1662
1662
|
const allIdentifiers = new Set([
|
|
1663
|
-
...references.map(r => r.identifier),
|
|
1663
|
+
...references.map((r) => r.identifier),
|
|
1664
1664
|
...variable.identifiers
|
|
1665
1665
|
]);
|
|
1666
1666
|
for (const ref of references) {
|