webpack 5.112.0 → 5.112.2
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/bin/webpack.js +13 -7
- package/lib/Compilation.js +198 -61
- package/lib/Compiler.js +12 -25
- package/lib/asset/AssetBytesGenerator.js +14 -6
- package/lib/asset/AssetBytesParser.js +10 -8
- package/lib/asset/AssetGenerator.js +36 -48
- package/lib/asset/AssetModule.js +11 -0
- package/lib/asset/AssetModulesPlugin.js +5 -4
- package/lib/asset/AssetParser.js +8 -8
- package/lib/asset/AssetSourceGenerator.js +16 -8
- package/lib/asset/AssetSourceParser.js +10 -8
- package/lib/asset/WebManifestGenerator.js +11 -6
- package/lib/asset/WebManifestParser.js +3 -3
- package/lib/async-modules/AsyncModuleHelpers.js +8 -2
- package/lib/async-modules/InferAsyncModulesPlugin.js +7 -2
- package/lib/cache/CacheFacade.js +1 -1
- package/lib/cache/PackFileCacheStrategy.js +6 -10
- package/lib/cache/ResolverCachePlugin.js +58 -8
- package/lib/config/WebpackOptionsApply.js +8 -28
- package/lib/config/cli.js +9 -6
- package/lib/config/defaults.js +24 -13
- package/lib/config/getClaimedAssetTypes.js +2 -2
- package/lib/config/target.js +1 -1
- package/lib/context/ContextModule.js +1 -1
- package/lib/context/ContextModuleFactory.js +1 -1
- package/lib/context/ContextReplacementPlugin.js +3 -9
- package/lib/css/CssGenerator.js +40 -47
- package/lib/css/CssModule.js +10 -0
- package/lib/css/CssModulesPlugin.js +13 -6
- package/lib/css/CssParser.js +33 -32
- package/lib/css/conventions.js +1 -1
- package/lib/css/data.js +224 -219
- package/lib/css/syntax-parser.js +1312 -312
- package/lib/css/syntax-printer.js +1142 -1025
- package/lib/debug/ProfilingPlugin.js +65 -43
- package/lib/define/DefinePlugin.js +10 -15
- package/lib/define/DotenvPlugin.js +10 -6
- package/lib/define/EnvironmentPlugin.js +4 -2
- package/lib/dependencies/amd/AMDDefineDependencyParserPlugin.js +1 -2
- package/lib/dependencies/amd/AMDRequireDependenciesBlockParserPlugin.js +4 -1
- package/lib/dependencies/commonjs/CommonJsExportRequireDependency.js +1 -4
- package/lib/dependencies/commonjs/CommonJsExportsParserPlugin.js +18 -33
- package/lib/dependencies/commonjs/CommonJsImportsParserPlugin.js +1 -3
- package/lib/dependencies/commonjs/CommonJsObjectExportDependency.js +4 -4
- package/lib/dependencies/commonjs/CommonJsPlugin.js +2 -5
- package/lib/dependencies/commonjs/RequireEnsureDependenciesBlockParserPlugin.js +4 -1
- package/lib/dependencies/context/ImportMetaContextDependencyParserPlugin.js +1 -2
- package/lib/dependencies/context/ImportMetaGlobDependencyParserPlugin.js +4 -7
- package/lib/dependencies/context/ImportMetaGlobHelpers.js +8 -10
- package/lib/dependencies/core/CachedConstDependency.js +9 -6
- package/lib/dependencies/css/CssIcssExportDependency.js +6 -7
- package/lib/dependencies/css/CssIcssImportDependency.js +1 -3
- package/lib/dependencies/css/CssUrlDependency.js +2 -6
- package/lib/dependencies/esm/ESMDetectionParserPlugin.js +2 -4
- package/lib/dependencies/esm/ESMExportExpressionDependency.js +2 -2
- package/lib/dependencies/esm/ESMExportImportedSpecifierDependency.js +16 -18
- package/lib/dependencies/esm/ESMExportSpecifierDependency.js +20 -3
- package/lib/dependencies/esm/ESMExports.js +2 -10
- package/lib/dependencies/esm/ESMImportDependency.js +17 -2
- package/lib/dependencies/esm/ESMImportDependencyParserPlugin.js +6 -17
- package/lib/dependencies/esm/ESMImportGuard.js +11 -23
- package/lib/dependencies/esm/ESMImportSideEffectDependency.js +1 -1
- package/lib/dependencies/esm/ESMImportSpecifierDependency.js +4 -1
- package/lib/dependencies/esm/ESMLiveExportDependency.js +311 -0
- package/lib/dependencies/esm/ESMLiveExportParserPlugin.js +862 -0
- package/lib/dependencies/esm/ESMModulesPlugin.js +1 -3
- package/lib/dependencies/esm/TopLevelAwaitDependency.js +1 -8
- package/lib/dependencies/helpers/DynamicExports.js +4 -6
- package/lib/dependencies/html/HtmlEntryDependency.js +5 -14
- package/lib/dependencies/html/HtmlInlineHtmlDependency.js +1 -4
- package/lib/dependencies/html/HtmlInlineScriptDependency.js +2 -6
- package/lib/dependencies/html/HtmlInlineStyleDependency.js +1 -4
- package/lib/dependencies/import/ImportParserPlugin.js +3 -6
- package/lib/dependencies/import-meta/ImportMetaPlugin.js +4 -6
- package/lib/dependencies/url/URLParserPlugin.js +1 -1
- package/lib/dependencies/worker/WorkerAndWorkletPlugin.js +51 -20
- package/lib/devtool/ModuleFilenameHelpers.js +1 -1
- package/lib/devtool/SourceMapDevToolPlugin.js +1 -1
- package/lib/dll/DelegatedModule.js +3 -3
- package/lib/dll/DllModule.js +3 -1
- package/lib/dll/DllReferencePlugin.js +1 -4
- package/lib/errors/AbstractMethodError.js +1 -1
- package/lib/errors/ErrorHelpers.js +2 -1
- package/lib/errors/HookWebpackError.js +2 -1
- package/lib/errors/JSONParseError.js +4 -4
- package/lib/errors/WebpackError.js +3 -2
- package/lib/esm/ModuleChunkFormatPlugin.js +36 -1
- package/lib/externals/ExternalModule.js +12 -9
- package/lib/externals/ExternalModuleFactoryPlugin.js +1 -2
- package/lib/externals/ExternalsPlugin.js +1 -1
- package/lib/fs/FileSystemInfo.js +4 -4
- package/lib/graph/AsyncDependenciesBlock.js +1 -1
- package/lib/graph/ChunkGraph.js +5 -0
- package/lib/graph/Dependency.js +8 -2
- package/lib/graph/ExportsInfo.js +1 -1
- package/lib/graph/ModuleGraph.js +14 -3
- package/lib/graph/buildChunkGraph.js +17 -19
- package/lib/graph/findGraphRoots.js +1 -1
- package/lib/hmr/HotModuleReplacement.runtime.js +10 -9
- package/lib/hmr/HotModuleReplacementPlugin.js +5 -11
- package/lib/hmr/JavascriptHotModuleReplacement.runtime.js +16 -19
- package/lib/hmr/LazyCompilationPlugin.js +1 -7
- package/lib/html/HtmlGenerator.js +25 -17
- package/lib/html/HtmlModule.js +11 -1
- package/lib/html/HtmlModulesPlugin.js +12 -11
- package/lib/html/HtmlParser.js +10 -9
- package/lib/html/builtinEmbeddedRenderer.js +31 -33
- package/lib/html/data.js +42 -21
- package/lib/html/htmlMinify.js +4 -1
- package/lib/html/syntax-parser.js +34 -35
- package/lib/html/syntax-printer.js +2 -3
- package/lib/html/xmlMinify.js +4 -1
- package/lib/ids/HashedModuleIdsPlugin.js +1 -1
- package/lib/index.js +13 -12
- package/lib/javascript/APIPlugin.js +7 -13
- package/lib/javascript/BasicEvaluatedExpression.js +5 -5
- package/lib/javascript/CommonJsChunkFormatPlugin.js +2 -7
- package/lib/javascript/ConstPlugin.js +1 -1
- package/lib/javascript/JavascriptGenerator.js +16 -11
- package/lib/javascript/JavascriptMetaInfoPlugin.js +3 -15
- package/lib/javascript/JavascriptModule.js +10 -0
- package/lib/javascript/JavascriptModulesPlugin.js +2 -4
- package/lib/javascript/JavascriptParser.js +99 -11
- package/lib/javascript/ScopeAnalyzer.js +183 -107
- package/lib/javascript/UseStrictPlugin.js +2 -5
- package/lib/javascript/jsMinify.js +1 -1
- package/lib/javascript/regexp.js +2 -2
- package/lib/javascript/syntax-parser.js +2114 -1506
- package/lib/javascript/syntax-printer-data.js +167 -1
- package/lib/javascript/syntax-printer.js +9554 -2782
- package/lib/json/JsonGenerator.js +15 -7
- package/lib/json/JsonModule.js +11 -0
- package/lib/json/JsonParser.js +7 -6
- package/lib/library/AssignLibraryPlugin.js +1 -1
- package/lib/library/JsonpLibraryPlugin.js +1 -1
- package/lib/library/ModuleLibraryPlugin.js +399 -23
- package/lib/loaders/LoaderRunner.js +76 -38
- package/lib/loaders/loadLoader.js +16 -10
- package/lib/module/Generator.js +17 -9
- package/lib/module/Module.js +2 -2
- package/lib/module/NormalModule.js +7 -5
- package/lib/module/NormalModuleFactory.js +11 -17
- package/lib/module/Parser.js +9 -2
- package/lib/module/extractSourceMap.js +69 -18
- package/lib/module/findCaseMismatch.js +2 -2
- package/lib/node/ExternalModuleInitFragment.js +2 -2
- package/lib/node/ReadFileCompileAsyncWasmPlugin.js +4 -12
- package/lib/node/ReadFileCompileWasmPlugin.js +2 -6
- package/lib/node/nodeConsole.js +4 -3
- package/lib/optimize/CircularModulesPlugin.js +1 -1
- package/lib/optimize/ConcatenatedModule.js +4 -8
- package/lib/optimize/FlagDependencyExportsPlugin.js +6 -11
- package/lib/optimize/FlagDependencyUsagePlugin.js +28 -3
- package/lib/optimize/InlineExports.js +4 -7
- package/lib/optimize/LazyBarrels.js +41 -5
- package/lib/optimize/ModuleConcatenationPlugin.js +8 -10
- package/lib/optimize/RealContentHashPlugin.js +2 -6
- package/lib/optimize/SideEffectsFlagPlugin.js +7 -21
- package/lib/optimize/SplitChunksPlugin.js +11 -24
- package/lib/optimize/TupleQueue.js +1 -1
- package/lib/output/CleanPlugin.js +3 -1
- package/lib/output/CopyPlugin.js +3 -4
- package/lib/performance/EvalUsagePlugin.js +1 -3
- package/lib/performance/HotspotsPlugin.js +33 -9
- package/lib/performance/PureAnnotationsPlugin.js +16 -10
- package/lib/performance/TopLevelThisPlugin.js +17 -9
- package/lib/prefetch/ResourceHintPlugin.js +1 -1
- package/lib/provide/ProvidedDependency.js +36 -4
- package/lib/rules/BasicEffectRulePlugin.js +1 -1
- package/lib/rules/RuleSetCompiler.js +15 -5
- package/lib/rules/UseEffectRulePlugin.js +1 -3
- package/lib/runtime/AsyncModuleRuntimeModule.js +7 -1
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +1 -5
- package/lib/runtime/RuntimeGlobals.js +6 -0
- package/lib/runtime/RuntimePlugin.js +2 -0
- package/lib/schemes/HttpUriPlugin.js +1 -2
- package/lib/schemes/VirtualUrlPlugin.js +3 -1
- package/lib/serialization/AggregateErrorSerializer.js +3 -3
- package/lib/serialization/BinaryMiddleware.js +4 -1
- package/lib/serialization/ErrorObjectSerializer.js +2 -5
- package/lib/serialization/ObjectMiddleware.js +17 -15
- package/lib/serialization/PlainObjectSerializer.js +3 -7
- package/lib/serialization/Serializer.js +21 -11
- package/lib/serialization/SerializerMiddleware.js +8 -6
- package/lib/stats/DefaultStatsFactoryPlugin.js +35 -35
- package/lib/stats/DefaultStatsPresetPlugin.js +2 -6
- package/lib/stats/DefaultStatsPrinterPlugin.js +12 -11
- package/lib/stats/StatsFactory.js +194 -24
- package/lib/stats/StatsPrinter.js +126 -13
- package/lib/template/DependencyTemplate.js +1 -1
- package/lib/template/RuntimeTemplate.js +13 -32
- package/lib/template/Template.js +1 -1
- package/lib/util/SourceProcessor.js +146 -29
- package/lib/util/WeakTupleMap.js +10 -4
- package/lib/util/cleverMerge.js +61 -33
- package/lib/util/comparators.js +9 -5
- package/lib/util/dataURL.js +2 -0
- package/lib/util/deprecation.js +4 -3
- package/lib/util/globUtils.js +1 -4
- package/lib/util/internalSerializables.js +2 -0
- package/lib/util/makeSerializable.js +6 -4
- package/lib/util/memoize.js +1 -1
- package/lib/util/parseJson.js +2 -2
- package/lib/util/serialization.js +31 -27
- package/lib/wasm/AsyncWasmModule.js +12 -2
- package/lib/wasm/AsyncWebAssemblyGenerator.js +12 -4
- package/lib/wasm/AsyncWebAssemblyJavascriptGenerator.js +13 -5
- package/lib/wasm/AsyncWebAssemblyParser.js +7 -5
- package/lib/wasm/UniversalCompileAsyncWasmPlugin.js +2 -6
- package/lib/wasm-sync/SyncWasmModule.js +16 -1
- package/lib/wasm-sync/WebAssemblyGenerator.js +15 -10
- package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +13 -5
- package/lib/wasm-sync/WebAssemblyParser.js +10 -12
- package/lib/web/FetchCompileAsyncWasmPlugin.js +4 -12
- package/lib/web/FetchCompileWasmPlugin.js +2 -6
- package/package.json +18 -19
- package/schemas/WebpackOptions.check.js +3 -3
- package/schemas/WebpackOptions.json +2 -2
- package/schemas/plugins/BannerPlugin.check.js +3 -3
- package/schemas/plugins/HtmlGeneratorOptions.check.js +3 -3
- package/schemas/plugins/HtmlParserOptions.check.js +3 -3
- package/schemas/plugins/IgnorePlugin.check.js +3 -3
- package/schemas/plugins/LoaderOptionsPlugin.check.js +3 -3
- package/schemas/plugins/ManifestPlugin.check.js +3 -3
- package/schemas/plugins/ProgressPlugin.check.js +3 -3
- package/schemas/plugins/SSRManifestPlugin.check.js +3 -3
- package/schemas/plugins/SourceMapDevToolPlugin.check.js +3 -3
- package/schemas/plugins/WatchIgnorePlugin.check.js +3 -3
- package/schemas/plugins/asset/AssetGeneratorOptions.check.js +3 -3
- package/schemas/plugins/asset/AssetInlineGeneratorOptions.check.js +3 -3
- package/schemas/plugins/asset/AssetParserOptions.check.js +3 -3
- package/schemas/plugins/asset/AssetResourceGeneratorOptions.check.js +3 -3
- package/schemas/plugins/container/ContainerPlugin.check.js +3 -3
- package/schemas/plugins/container/ContainerReferencePlugin.check.js +3 -3
- package/schemas/plugins/container/ExternalsType.check.js +3 -3
- package/schemas/plugins/container/ModuleFederationPlugin.check.js +3 -3
- package/schemas/plugins/css/CssAutoOrModuleParserOptions.check.js +3 -3
- package/schemas/plugins/css/CssGeneratorOptions.check.js +3 -3
- package/schemas/plugins/css/CssModuleGeneratorOptions.check.js +3 -3
- package/schemas/plugins/css/CssModuleParserOptions.check.js +3 -3
- package/schemas/plugins/css/CssParserOptions.check.js +3 -3
- package/schemas/plugins/debug/ProfilingPlugin.check.js +3 -3
- package/schemas/plugins/define/DotenvPluginOptions.check.js +7 -0
- package/schemas/plugins/define/DotenvPluginOptions.json +3 -0
- package/schemas/plugins/dll/DllPlugin.check.js +3 -3
- package/schemas/plugins/dll/DllReferencePlugin.check.js +3 -3
- package/schemas/plugins/ids/HashedModuleIdsPlugin.check.js +3 -3
- package/schemas/plugins/ids/OccurrenceChunkIdsPlugin.check.js +3 -3
- package/schemas/plugins/ids/OccurrenceModuleIdsPlugin.check.js +3 -3
- package/schemas/plugins/json/JsonModulesPluginGenerator.check.js +3 -3
- package/schemas/plugins/json/JsonModulesPluginParser.check.js +3 -3
- package/schemas/plugins/optimize/AggressiveSplittingPlugin.check.js +3 -3
- package/schemas/plugins/optimize/LimitChunkCountPlugin.check.js +3 -3
- package/schemas/plugins/optimize/MergeDuplicateChunksPlugin.check.js +3 -3
- package/schemas/plugins/optimize/MinChunkSizePlugin.check.js +3 -3
- package/schemas/plugins/output/CleanOptions.check.js +7 -0
- package/schemas/plugins/output/CleanOptions.json +3 -0
- package/schemas/plugins/schemes/HttpUriPlugin.check.js +3 -3
- package/schemas/plugins/schemes/VirtualUrlPlugin.check.js +3 -3
- package/schemas/plugins/sharing/ConsumeSharedPlugin.check.js +3 -3
- package/schemas/plugins/sharing/ProvideSharedPlugin.check.js +3 -3
- package/schemas/plugins/sharing/SharePlugin.check.js +3 -3
- package/types.d.ts +1482 -358
package/bin/webpack.js
CHANGED
|
@@ -4,11 +4,21 @@
|
|
|
4
4
|
|
|
5
5
|
// Cache compiled module bytecode on disk (available since Node.js 22.8)
|
|
6
6
|
// eslint-disable-next-line n/no-unsupported-features/node-builtins
|
|
7
|
-
const { enableCompileCache } = require("module");
|
|
7
|
+
const { constants, enableCompileCache } = require("module");
|
|
8
8
|
|
|
9
9
|
if (enableCompileCache) {
|
|
10
10
|
try {
|
|
11
|
-
enableCompileCache();
|
|
11
|
+
const { status, directory } = enableCompileCache();
|
|
12
|
+
// Minimizer workers and other child processes start without the cache;
|
|
13
|
+
// the variable Node reads at startup hands them the same directory. Only a
|
|
14
|
+
// fresh start returns the base directory, which children tag by version.
|
|
15
|
+
if (
|
|
16
|
+
// eslint-disable-next-line n/no-unsupported-features/node-builtins
|
|
17
|
+
status === constants.compileCacheStatus.ENABLED &&
|
|
18
|
+
process.env.NODE_COMPILE_CACHE === undefined
|
|
19
|
+
) {
|
|
20
|
+
process.env.NODE_COMPILE_CACHE = directory;
|
|
21
|
+
}
|
|
12
22
|
} catch (_error) {
|
|
13
23
|
// Nothing
|
|
14
24
|
}
|
|
@@ -190,11 +200,7 @@ if (!cli.installed) {
|
|
|
190
200
|
}')...`
|
|
191
201
|
);
|
|
192
202
|
|
|
193
|
-
runCommand(
|
|
194
|
-
/** @type {string} */
|
|
195
|
-
(packageManager),
|
|
196
|
-
[...installOptions, cli.package]
|
|
197
|
-
)
|
|
203
|
+
runCommand(packageManager, [...installOptions, cli.package])
|
|
198
204
|
.then(() => {
|
|
199
205
|
runCli(cli);
|
|
200
206
|
})
|
package/lib/Compilation.js
CHANGED
|
@@ -36,6 +36,7 @@ const { LogType, Logger } = require("./logging/Logger");
|
|
|
36
36
|
const CodeGenerationResults = require("./module/CodeGenerationResults");
|
|
37
37
|
const Module = require("./module/Module");
|
|
38
38
|
const ModuleProfile = require("./module/ModuleProfile");
|
|
39
|
+
const { JAVASCRIPT_TYPE } = require("./module/ModuleSourceTypeConstants");
|
|
39
40
|
const LazyBarrels = require("./optimize/LazyBarrels");
|
|
40
41
|
const RuntimeGlobals = require("./runtime/RuntimeGlobals");
|
|
41
42
|
const Stats = require("./stats/Stats");
|
|
@@ -189,6 +190,7 @@ const { toError } = ErrorHelpers;
|
|
|
189
190
|
* @import {
|
|
190
191
|
* StatsAsset,
|
|
191
192
|
* StatsError,
|
|
193
|
+
* StatsJsonValue,
|
|
192
194
|
* StatsModule
|
|
193
195
|
* } from "./stats/DefaultStatsFactoryPlugin"
|
|
194
196
|
*/
|
|
@@ -247,7 +249,7 @@ const { toError } = ErrorHelpers;
|
|
|
247
249
|
* @returns {void}
|
|
248
250
|
*/
|
|
249
251
|
|
|
250
|
-
/** @typedef {new (...args:
|
|
252
|
+
/** @typedef {abstract new (...args: never[]) => Dependency} DependencyConstructor */
|
|
251
253
|
|
|
252
254
|
/** @typedef {Record<string, Source>} CompilationAssets */
|
|
253
255
|
|
|
@@ -527,7 +529,7 @@ const { toError } = ErrorHelpers;
|
|
|
527
529
|
* @property {false | "none" | "error" | "warn" | "info" | "log" | "verbose"} logging
|
|
528
530
|
* @property {((value: string) => boolean)[]} loggingDebug
|
|
529
531
|
* @property {boolean} loggingTrace
|
|
530
|
-
* @property {
|
|
532
|
+
* @property {StatsJsonValue} _env
|
|
531
533
|
*/
|
|
532
534
|
|
|
533
535
|
/** @typedef {KnownNormalizedStatsOptions & Omit<StatsOptions, keyof KnownNormalizedStatsOptions> & Record<string, EXPECTED_ANY>} NormalizedStatsOptions */
|
|
@@ -633,11 +635,19 @@ const unsafeCacheData = new WeakMap();
|
|
|
633
635
|
const dependencyReportCacheTokens = new WeakMap();
|
|
634
636
|
|
|
635
637
|
/**
|
|
636
|
-
* Modules known to have no dependency errors/warnings, per cache token
|
|
637
|
-
*
|
|
638
|
+
* Modules known to have no dependency errors/warnings, per cache token, with
|
|
639
|
+
* the deferred requests they were checked with (`true` for none).
|
|
640
|
+
* @type {WeakMap<DependencyReportCacheToken, WeakMap<Module, string | true>>}
|
|
638
641
|
*/
|
|
639
642
|
const modulesWithoutProblems = new WeakMap();
|
|
640
643
|
|
|
644
|
+
/**
|
|
645
|
+
* How many connections each stored reference map holds, so a module whose
|
|
646
|
+
* connection is gone or new, not only one pointing elsewhere, counts as affected.
|
|
647
|
+
* @type {WeakMap<WeakReferences, number>}
|
|
648
|
+
*/
|
|
649
|
+
const referenceCounts = new WeakMap();
|
|
650
|
+
|
|
641
651
|
/**
|
|
642
652
|
* Reduce affect type.
|
|
643
653
|
* @param {Readonly<ModuleGraphConnection[]>} connections connections
|
|
@@ -655,9 +665,13 @@ const reduceAffectType = (connections) => {
|
|
|
655
665
|
return affected;
|
|
656
666
|
};
|
|
657
667
|
|
|
658
|
-
/** @typedef {{ id: ModuleId, modules?: Map<Module, string>, blocks?: (ChunkId | null)[], sourceTypes?: SourceTypes }} References */
|
|
668
|
+
/** @typedef {{ id: ModuleId, modules?: Map<Module, string>, blocks?: (ChunkId | null)[], sourceTypes?: SourceTypes, chunkSourceTypes?: string }} References */
|
|
659
669
|
/** @typedef {Map<Module, WeakTupleMap<EXPECTED_ANY[], EXPECTED_ANY>>} ModuleMemCaches */
|
|
660
|
-
/**
|
|
670
|
+
/**
|
|
671
|
+
* A queued lazy runtime module; `create` takes exactly what its own `load`
|
|
672
|
+
* resolves, which differs per entry.
|
|
673
|
+
* @typedef {{ chunk: Chunk, load: () => Promise<EXPECTED_OBJECT>, create: (loaded: never) => RuntimeModule, chunkGraph: ChunkGraph }} PendingRuntimeModule
|
|
674
|
+
*/
|
|
661
675
|
|
|
662
676
|
class Compilation {
|
|
663
677
|
/**
|
|
@@ -908,7 +922,11 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
908
922
|
processAssetsHook.tapAsync(
|
|
909
923
|
getOptions(options),
|
|
910
924
|
(assets, callback) =>
|
|
911
|
-
/** @type {
|
|
925
|
+
/** @type {(...args: [...AsArray<T>, typeof callback]) => void} */ (
|
|
926
|
+
/** @type {typeof fn | ((...args: [...AsArray<T>, typeof callback]) => void)} */ (
|
|
927
|
+
fn
|
|
928
|
+
)
|
|
929
|
+
)(...getArgs(), callback)
|
|
912
930
|
);
|
|
913
931
|
},
|
|
914
932
|
/** @type {AsyncSeriesHook<T>["tapPromise"]} */
|
|
@@ -1847,8 +1865,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
1847
1865
|
this.options,
|
|
1848
1866
|
this,
|
|
1849
1867
|
this.resolverFactory.get("normal", module.resolveOptions),
|
|
1850
|
-
|
|
1851
|
-
(this.inputFileSystem),
|
|
1868
|
+
this.inputFileSystem,
|
|
1852
1869
|
(err) => {
|
|
1853
1870
|
if (currentProfile !== undefined) {
|
|
1854
1871
|
currentProfile.markBuildingEnd();
|
|
@@ -2549,9 +2566,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
2549
2566
|
module.restoreFromUnsafeCache &&
|
|
2550
2567
|
this._unsafeCachePredicate(module)
|
|
2551
2568
|
) {
|
|
2552
|
-
const unsafeCacheableModule =
|
|
2553
|
-
/** @type {ModuleWithRestoreFromUnsafeCache} */
|
|
2554
|
-
(module);
|
|
2569
|
+
const unsafeCacheableModule = module;
|
|
2555
2570
|
for (const dependency of dependencies) {
|
|
2556
2571
|
moduleGraph.setResolvedModule(
|
|
2557
2572
|
connectOrigin ? originModule : null,
|
|
@@ -2969,6 +2984,18 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
2969
2984
|
});
|
|
2970
2985
|
}
|
|
2971
2986
|
|
|
2987
|
+
/**
|
|
2988
|
+
* Returns the requests a lazy barrel still defers, which neither render nor
|
|
2989
|
+
* report what they would once requested, though no connection changes.
|
|
2990
|
+
* @private
|
|
2991
|
+
* @param {Module} module the module
|
|
2992
|
+
* @returns {string | undefined} the deferred requests as one key, if any
|
|
2993
|
+
*/
|
|
2994
|
+
_getLazyRequests(module) {
|
|
2995
|
+
const lazyRequests = this._lazyBarrels.getLazyRequests(module);
|
|
2996
|
+
return lazyRequests && JSON.stringify([...lazyRequests]);
|
|
2997
|
+
}
|
|
2998
|
+
|
|
2972
2999
|
/**
|
|
2973
3000
|
* Compute affected modules.
|
|
2974
3001
|
* @private
|
|
@@ -3000,13 +3027,16 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
3000
3027
|
const computeReferences = (module) => {
|
|
3001
3028
|
/** @type {WeakReferences | undefined} */
|
|
3002
3029
|
let references;
|
|
3030
|
+
let count = 0;
|
|
3003
3031
|
for (const connection of moduleGraph.getOutgoingConnections(module)) {
|
|
3004
3032
|
const d = connection.dependency;
|
|
3005
3033
|
const m = connection.module;
|
|
3006
3034
|
if (!d || !m || unsafeCacheDependencies.has(d)) continue;
|
|
3007
3035
|
if (references === undefined) references = new WeakMap();
|
|
3008
3036
|
references.set(d, m);
|
|
3037
|
+
count++;
|
|
3009
3038
|
}
|
|
3039
|
+
if (references !== undefined) referenceCounts.set(references, count);
|
|
3010
3040
|
return references;
|
|
3011
3041
|
};
|
|
3012
3042
|
|
|
@@ -3017,15 +3047,21 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
3017
3047
|
* @returns {boolean} true, when the references differ
|
|
3018
3048
|
*/
|
|
3019
3049
|
const compareReferences = (module, references) => {
|
|
3020
|
-
|
|
3050
|
+
let count = 0;
|
|
3021
3051
|
for (const connection of moduleGraph.getOutgoingConnections(module)) {
|
|
3022
3052
|
const d = connection.dependency;
|
|
3023
3053
|
if (!d) continue;
|
|
3024
|
-
const entry = references.get(d);
|
|
3025
|
-
if (entry ===
|
|
3026
|
-
|
|
3054
|
+
const entry = references === undefined ? undefined : references.get(d);
|
|
3055
|
+
if (entry === connection.module) {
|
|
3056
|
+
count++;
|
|
3057
|
+
} else if (entry !== undefined || !unsafeCacheDependencies.has(d)) {
|
|
3058
|
+
return false;
|
|
3059
|
+
}
|
|
3027
3060
|
}
|
|
3028
|
-
return
|
|
3061
|
+
return (
|
|
3062
|
+
count ===
|
|
3063
|
+
(references === undefined ? 0 : referenceCounts.get(references))
|
|
3064
|
+
);
|
|
3029
3065
|
};
|
|
3030
3066
|
|
|
3031
3067
|
const modulesWithoutCache = new Set(modules);
|
|
@@ -3033,6 +3069,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
3033
3069
|
if (modulesWithoutCache.has(module)) {
|
|
3034
3070
|
const buildInfo = module.buildInfo;
|
|
3035
3071
|
if (buildInfo) {
|
|
3072
|
+
const lazyRequests = this._getLazyRequests(module);
|
|
3036
3073
|
if (cachedMemCache.buildInfo !== buildInfo) {
|
|
3037
3074
|
// use a new one
|
|
3038
3075
|
/** @type {MemCache} */
|
|
@@ -3041,15 +3078,20 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
3041
3078
|
affectedModules.add(module);
|
|
3042
3079
|
cachedMemCache.buildInfo = buildInfo;
|
|
3043
3080
|
cachedMemCache.references = computeReferences(module);
|
|
3081
|
+
cachedMemCache.lazyRequests = lazyRequests;
|
|
3044
3082
|
cachedMemCache.memCache = memCache;
|
|
3045
3083
|
statChanged++;
|
|
3046
|
-
} else if (
|
|
3084
|
+
} else if (
|
|
3085
|
+
!compareReferences(module, cachedMemCache.references) ||
|
|
3086
|
+
cachedMemCache.lazyRequests !== lazyRequests
|
|
3087
|
+
) {
|
|
3047
3088
|
// use a new one
|
|
3048
3089
|
/** @type {MemCache} */
|
|
3049
3090
|
const memCache = new WeakTupleMap();
|
|
3050
3091
|
moduleMemCaches.set(module, memCache);
|
|
3051
3092
|
affectedModules.add(module);
|
|
3052
3093
|
cachedMemCache.references = computeReferences(module);
|
|
3094
|
+
cachedMemCache.lazyRequests = lazyRequests;
|
|
3053
3095
|
cachedMemCache.memCache = memCache;
|
|
3054
3096
|
statReferencesChanged++;
|
|
3055
3097
|
} else {
|
|
@@ -3076,6 +3118,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
3076
3118
|
moduleMemCacheCache.set(module, {
|
|
3077
3119
|
buildInfo,
|
|
3078
3120
|
references: computeReferences(module),
|
|
3121
|
+
lazyRequests: this._getLazyRequests(module),
|
|
3079
3122
|
memCache
|
|
3080
3123
|
});
|
|
3081
3124
|
moduleMemCaches.set(module, memCache);
|
|
@@ -3168,6 +3211,17 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
3168
3211
|
}
|
|
3169
3212
|
return key;
|
|
3170
3213
|
};
|
|
3214
|
+
/**
|
|
3215
|
+
* Key the source types the chunk graph overrides for the module, which module concatenation narrows for an inner module that keeps other source types.
|
|
3216
|
+
* @param {Module} module module
|
|
3217
|
+
* @returns {string | undefined} key, undefined when the module's own source types stand
|
|
3218
|
+
*/
|
|
3219
|
+
const chunkSourceTypesKey = (module) => {
|
|
3220
|
+
const sourceTypes = chunkGraph.getModuleSourceTypes(module);
|
|
3221
|
+
return sourceTypes === module.getSourceTypes()
|
|
3222
|
+
? undefined
|
|
3223
|
+
: [...sourceTypes].join();
|
|
3224
|
+
};
|
|
3171
3225
|
/**
|
|
3172
3226
|
* Compute references.
|
|
3173
3227
|
* @param {Module} module module
|
|
@@ -3210,7 +3264,8 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
3210
3264
|
id,
|
|
3211
3265
|
modules,
|
|
3212
3266
|
blocks,
|
|
3213
|
-
sourceTypes: module.getReferencedSourceTypes()
|
|
3267
|
+
sourceTypes: module.getReferencedSourceTypes(),
|
|
3268
|
+
chunkSourceTypes: chunkSourceTypesKey(module)
|
|
3214
3269
|
};
|
|
3215
3270
|
};
|
|
3216
3271
|
/**
|
|
@@ -3221,11 +3276,12 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
3221
3276
|
* @param {Map<Module, string>=} references.modules modules
|
|
3222
3277
|
* @param {(string | number | null)[]=} references.blocks blocks
|
|
3223
3278
|
* @param {SourceTypes=} references.sourceTypes connection-dependent source types
|
|
3279
|
+
* @param {string=} references.chunkSourceTypes key of the source types the chunk graph overrides
|
|
3224
3280
|
* @returns {boolean} ok?
|
|
3225
3281
|
*/
|
|
3226
3282
|
const compareReferences = (
|
|
3227
3283
|
module,
|
|
3228
|
-
{ id, modules, blocks, sourceTypes }
|
|
3284
|
+
{ id, modules, blocks, sourceTypes, chunkSourceTypes }
|
|
3229
3285
|
) => {
|
|
3230
3286
|
if (id !== chunkGraph.getModuleId(module)) return false;
|
|
3231
3287
|
if (modules !== undefined) {
|
|
@@ -3264,6 +3320,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
3264
3320
|
) {
|
|
3265
3321
|
return false;
|
|
3266
3322
|
}
|
|
3323
|
+
if (chunkSourceTypesKey(module) !== chunkSourceTypes) return false;
|
|
3267
3324
|
return true;
|
|
3268
3325
|
};
|
|
3269
3326
|
|
|
@@ -3473,20 +3530,24 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
3473
3530
|
if (d === 0 || p === 0) continue;
|
|
3474
3531
|
const t = d / p;
|
|
3475
3532
|
sum += t;
|
|
3476
|
-
|
|
3533
|
+
/* istanbul ignore next -- @preserve: only slow (>10ms) modules are logged, timing-dependent */
|
|
3534
|
+
if (t > 10) {
|
|
3535
|
+
logByValue(
|
|
3536
|
+
t,
|
|
3537
|
+
` | ${Math.round(t)} ms${
|
|
3538
|
+
p >= 1.1 ? ` (parallelism ${Math.round(p * 10) / 10})` : ""
|
|
3539
|
+
} ${category} > ${module.readableIdentifier(this.requestShortener)}`
|
|
3540
|
+
);
|
|
3541
|
+
max = Math.max(max, t);
|
|
3542
|
+
}
|
|
3543
|
+
}
|
|
3544
|
+
/* istanbul ignore next -- @preserve: only slow (>10ms) categories are logged, timing-dependent */
|
|
3545
|
+
if (sum > 10) {
|
|
3477
3546
|
logByValue(
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
p >= 1.1 ? ` (parallelism ${Math.round(p * 10) / 10})` : ""
|
|
3481
|
-
} ${category} > ${module.readableIdentifier(this.requestShortener)}`
|
|
3547
|
+
Math.max(sum / 10, max),
|
|
3548
|
+
`${Math.round(sum)} ms ${category}`
|
|
3482
3549
|
);
|
|
3483
|
-
max = Math.max(max, t);
|
|
3484
3550
|
}
|
|
3485
|
-
if (sum <= 10) return;
|
|
3486
|
-
logByValue(
|
|
3487
|
-
Math.max(sum / 10, max),
|
|
3488
|
-
`${Math.round(sum)} ms ${category}`
|
|
3489
|
-
);
|
|
3490
3551
|
};
|
|
3491
3552
|
/**
|
|
3492
3553
|
* Log by loaders summary.
|
|
@@ -3531,30 +3592,34 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
3531
3592
|
}
|
|
3532
3593
|
}
|
|
3533
3594
|
sum += innerSum;
|
|
3534
|
-
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
|
|
3538
|
-
|
|
3595
|
+
/* istanbul ignore next -- @preserve: only slow (>10ms) loader groups are logged, timing-dependent */
|
|
3596
|
+
if (innerSum > 10) {
|
|
3597
|
+
const idx = key.indexOf("!");
|
|
3598
|
+
const loaders = key.slice(idx + 1);
|
|
3599
|
+
const moduleType = key.slice(0, idx);
|
|
3600
|
+
const t = Math.max(innerSum / 10, innerMax);
|
|
3601
|
+
logByValue(
|
|
3602
|
+
t,
|
|
3603
|
+
` | ${Math.round(innerSum)} ms ${category} > ${
|
|
3604
|
+
loaders
|
|
3605
|
+
? `${
|
|
3606
|
+
modules.length
|
|
3607
|
+
} x ${moduleType} with ${this.requestShortener.shorten(
|
|
3608
|
+
loaders
|
|
3609
|
+
)}`
|
|
3610
|
+
: `${modules.length} x ${moduleType}`
|
|
3611
|
+
}`
|
|
3612
|
+
);
|
|
3613
|
+
max = Math.max(max, t);
|
|
3614
|
+
}
|
|
3615
|
+
}
|
|
3616
|
+
/* istanbul ignore next -- @preserve: only slow (>10ms) categories are logged, timing-dependent */
|
|
3617
|
+
if (sum > 10) {
|
|
3539
3618
|
logByValue(
|
|
3540
|
-
|
|
3541
|
-
|
|
3542
|
-
loaders
|
|
3543
|
-
? `${
|
|
3544
|
-
modules.length
|
|
3545
|
-
} x ${moduleType} with ${this.requestShortener.shorten(
|
|
3546
|
-
loaders
|
|
3547
|
-
)}`
|
|
3548
|
-
: `${modules.length} x ${moduleType}`
|
|
3549
|
-
}`
|
|
3619
|
+
Math.max(sum / 10, max),
|
|
3620
|
+
`${Math.round(sum)} ms ${category}`
|
|
3550
3621
|
);
|
|
3551
|
-
max = Math.max(max, t);
|
|
3552
3622
|
}
|
|
3553
|
-
if (sum <= 10) return;
|
|
3554
|
-
logByValue(
|
|
3555
|
-
Math.max(sum / 10, max),
|
|
3556
|
-
`${Math.round(sum)} ms ${category}`
|
|
3557
|
-
);
|
|
3558
3623
|
};
|
|
3559
3624
|
logNormalSummary(
|
|
3560
3625
|
"resolve to new modules",
|
|
@@ -3614,7 +3679,12 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
3614
3679
|
continue;
|
|
3615
3680
|
}
|
|
3616
3681
|
let token;
|
|
3682
|
+
/** @type {string | true} */
|
|
3683
|
+
let clean = true;
|
|
3617
3684
|
if (useReportCacheTokens) {
|
|
3685
|
+
// a request leaving a lazy barrel reports without any rebuild
|
|
3686
|
+
const lazyRequests = this._getLazyRequests(module);
|
|
3687
|
+
if (lazyRequests !== undefined) clean = lazyRequests;
|
|
3618
3688
|
token = dependencyReportCacheTokens.get(module);
|
|
3619
3689
|
const cleanModules = modulesWithoutProblems.get(
|
|
3620
3690
|
/** @type {DependencyReportCacheToken} */ (token)
|
|
@@ -3622,7 +3692,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
3622
3692
|
if (
|
|
3623
3693
|
!unresolved &&
|
|
3624
3694
|
cleanModules !== undefined &&
|
|
3625
|
-
cleanModules.
|
|
3695
|
+
cleanModules.get(module) === clean
|
|
3626
3696
|
) {
|
|
3627
3697
|
continue;
|
|
3628
3698
|
}
|
|
@@ -3659,10 +3729,10 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
3659
3729
|
if (cleanModules === undefined) {
|
|
3660
3730
|
modulesWithoutProblems.set(
|
|
3661
3731
|
/** @type {DependencyReportCacheToken} */ (token),
|
|
3662
|
-
(cleanModules = new
|
|
3732
|
+
(cleanModules = new WeakMap())
|
|
3663
3733
|
);
|
|
3664
3734
|
}
|
|
3665
|
-
cleanModules.
|
|
3735
|
+
cleanModules.set(module, clean);
|
|
3666
3736
|
}
|
|
3667
3737
|
}
|
|
3668
3738
|
}
|
|
@@ -4364,8 +4434,7 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
|
|
4364
4434
|
if (!referencedModule) return false;
|
|
4365
4435
|
return (
|
|
4366
4436
|
notCodeGeneratedModules === undefined ||
|
|
4367
|
-
|
|
4368
|
-
(notCodeGeneratedModules).has(referencedModule)
|
|
4437
|
+
notCodeGeneratedModules.has(referencedModule)
|
|
4369
4438
|
);
|
|
4370
4439
|
})
|
|
4371
4440
|
) {
|
|
@@ -4734,7 +4803,7 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
|
|
4734
4803
|
* is over. `runtimeRequirementInTree` is a sync hook, so a tap cannot await
|
|
4735
4804
|
* the load itself; anything the tap reads off the requirement set must be
|
|
4736
4805
|
* captured before queueing, since `create` runs later.
|
|
4737
|
-
* @template T
|
|
4806
|
+
* @template {object} T
|
|
4738
4807
|
* @param {Chunk} chunk target chunk
|
|
4739
4808
|
* @param {() => Promise<T>} load resolves the runtime module implementation
|
|
4740
4809
|
* @param {(loaded: T) => RuntimeModule} create builds the runtime module from it
|
|
@@ -4762,7 +4831,11 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
|
|
4762
4831
|
.then((loaded) => {
|
|
4763
4832
|
for (let i = 0; i < pending.length; i++) {
|
|
4764
4833
|
const { chunk, create, chunkGraph } = pending[i];
|
|
4765
|
-
this.addRuntimeModule(
|
|
4834
|
+
this.addRuntimeModule(
|
|
4835
|
+
chunk,
|
|
4836
|
+
create(/** @type {never} */ (loaded[i])),
|
|
4837
|
+
chunkGraph
|
|
4838
|
+
);
|
|
4766
4839
|
}
|
|
4767
4840
|
})
|
|
4768
4841
|
// a `runtimeModule` tap may have queued more
|
|
@@ -5288,7 +5361,7 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
|
|
5288
5361
|
|
|
5289
5362
|
createHash() {
|
|
5290
5363
|
this.logger.time("hashing: initialize hash");
|
|
5291
|
-
const chunkGraph =
|
|
5364
|
+
const chunkGraph = this.chunkGraph;
|
|
5292
5365
|
const runtimeTemplate = this.runtimeTemplate;
|
|
5293
5366
|
const outputOptions = this.outputOptions;
|
|
5294
5367
|
const hashFunction = outputOptions.hashFunction;
|
|
@@ -5431,6 +5504,26 @@ This prevents using hashes of each other and should be avoided.`);
|
|
|
5431
5504
|
this.warnings.push(err);
|
|
5432
5505
|
for (const i of circularRuntimeChunkInfo) runtimeChunks.push(i.chunk);
|
|
5433
5506
|
}
|
|
5507
|
+
// An ESM entry chunk imports the chunks of the entrypoints it depends on
|
|
5508
|
+
// (`dependOn`) by hashed filename, so their entry chunks are hashed first.
|
|
5509
|
+
/** @type {Set<Chunk>} */
|
|
5510
|
+
const unorderedEntryChunks = new Set(entryChunks);
|
|
5511
|
+
entryChunks.length = 0;
|
|
5512
|
+
/**
|
|
5513
|
+
* Adds an entry chunk after the entry chunks of its parent entrypoints.
|
|
5514
|
+
* @param {Chunk} chunk the entry chunk
|
|
5515
|
+
* @returns {void}
|
|
5516
|
+
*/
|
|
5517
|
+
const addEntryChunk = (chunk) => {
|
|
5518
|
+
if (!unorderedEntryChunks.delete(chunk)) return;
|
|
5519
|
+
for (const group of chunk.groupsIterable) {
|
|
5520
|
+
for (const parent of group.parentsIterable) {
|
|
5521
|
+
for (const c of parent.chunks) addEntryChunk(c);
|
|
5522
|
+
}
|
|
5523
|
+
}
|
|
5524
|
+
entryChunks.push(chunk);
|
|
5525
|
+
};
|
|
5526
|
+
for (const chunk of unorderedEntryChunks) addEntryChunk(chunk);
|
|
5434
5527
|
this.logger.timeEnd("hashing: sort chunks");
|
|
5435
5528
|
|
|
5436
5529
|
/** @type {Set<Chunk>} */
|
|
@@ -6323,6 +6416,16 @@ This prevents using hashes of each other and should be avoided.`);
|
|
|
6323
6416
|
chunkGraph.connectChunkAndModule(chunk, module);
|
|
6324
6417
|
}
|
|
6325
6418
|
|
|
6419
|
+
// The loader reads `module` as JavaScript, a consumer only this chunk graph has.
|
|
6420
|
+
const sourceTypes = module.getSourceTypes();
|
|
6421
|
+
if (!sourceTypes.has(JAVASCRIPT_TYPE)) {
|
|
6422
|
+
chunkGraph.setChunkModuleSourceTypes(
|
|
6423
|
+
chunk,
|
|
6424
|
+
module,
|
|
6425
|
+
new Set([...sourceTypes, JAVASCRIPT_TYPE])
|
|
6426
|
+
);
|
|
6427
|
+
}
|
|
6428
|
+
|
|
6326
6429
|
/** @type {WebpackError[]} */
|
|
6327
6430
|
const errors = [];
|
|
6328
6431
|
|
|
@@ -6379,8 +6482,42 @@ This prevents using hashes of each other and should be avoided.`);
|
|
|
6379
6482
|
}
|
|
6380
6483
|
};
|
|
6381
6484
|
|
|
6485
|
+
/**
|
|
6486
|
+
* Generates code for modules, each after the ones its `codeGenerationDependencies` read.
|
|
6487
|
+
* @param {Module[]} pending modules whose code is not generated yet
|
|
6488
|
+
* @param {Callback} callback callback
|
|
6489
|
+
* @returns {void}
|
|
6490
|
+
*/
|
|
6491
|
+
const codeGenInOrder = (pending, callback) => {
|
|
6492
|
+
const pendingSet = new Set(pending);
|
|
6493
|
+
/** @type {Module[]} */
|
|
6494
|
+
const ready = [];
|
|
6495
|
+
/** @type {Module[]} */
|
|
6496
|
+
const delayed = [];
|
|
6497
|
+
for (const module of pending) {
|
|
6498
|
+
const { codeGenerationDependencies } = module;
|
|
6499
|
+
const waits =
|
|
6500
|
+
codeGenerationDependencies !== undefined &&
|
|
6501
|
+
codeGenerationDependencies.some((dep) => {
|
|
6502
|
+
const referencedModule = this.moduleGraph.getModule(dep);
|
|
6503
|
+
return (
|
|
6504
|
+
referencedModule !== null && pendingSet.has(referencedModule)
|
|
6505
|
+
);
|
|
6506
|
+
});
|
|
6507
|
+
(waits ? delayed : ready).push(module);
|
|
6508
|
+
}
|
|
6509
|
+
// A cycle never frees a module, so generate them all and let templates report.
|
|
6510
|
+
if (ready.length === 0) {
|
|
6511
|
+
return asyncLib.eachLimit(pending, 10, codeGen, callback);
|
|
6512
|
+
}
|
|
6513
|
+
asyncLib.eachLimit(ready, 10, codeGen, (err) => {
|
|
6514
|
+
if (err || delayed.length === 0) return callback(err);
|
|
6515
|
+
codeGenInOrder(delayed, callback);
|
|
6516
|
+
});
|
|
6517
|
+
};
|
|
6518
|
+
|
|
6382
6519
|
// Generate code for all aggregated modules
|
|
6383
|
-
|
|
6520
|
+
codeGenInOrder([...modules], (err) => {
|
|
6384
6521
|
if (err) return callback(err);
|
|
6385
6522
|
reportErrors();
|
|
6386
6523
|
|
package/lib/Compiler.js
CHANGED
|
@@ -140,7 +140,7 @@ const getConcurrentCompilationError = memoize(() =>
|
|
|
140
140
|
|
|
141
141
|
/** @typedef {WeakMap<Dependency, Module>} WeakReferences */
|
|
142
142
|
/** @typedef {import("./util/WeakTupleMap")<EXPECTED_ANY[], EXPECTED_ANY>} MemCache */
|
|
143
|
-
/** @typedef {{ buildInfo: BuildInfo, references: WeakReferences | undefined, memCache: MemCache }} ModuleMemCachesItem */
|
|
143
|
+
/** @typedef {{ buildInfo: BuildInfo, references: WeakReferences | undefined, lazyRequests: string | undefined, memCache: MemCache }} ModuleMemCachesItem */
|
|
144
144
|
|
|
145
145
|
/**
|
|
146
146
|
* Checks whether this object is sorted.
|
|
@@ -925,11 +925,9 @@ ${other}`);
|
|
|
925
925
|
if (targetFileGeneration === undefined) {
|
|
926
926
|
const newGeneration = 1;
|
|
927
927
|
this._assetEmittingWrittenFiles.set(targetPath, newGeneration);
|
|
928
|
-
|
|
929
|
-
(cacheEntry).writtenTo.set(targetPath, newGeneration);
|
|
928
|
+
cacheEntry.writtenTo.set(targetPath, newGeneration);
|
|
930
929
|
} else {
|
|
931
|
-
|
|
932
|
-
(cacheEntry).writtenTo.set(targetPath, targetFileGeneration);
|
|
930
|
+
cacheEntry.writtenTo.set(targetPath, targetFileGeneration);
|
|
933
931
|
}
|
|
934
932
|
callback();
|
|
935
933
|
};
|
|
@@ -957,8 +955,7 @@ ${other}`);
|
|
|
957
955
|
targetFileGeneration === undefined
|
|
958
956
|
? 1
|
|
959
957
|
: targetFileGeneration + 1;
|
|
960
|
-
|
|
961
|
-
(cacheEntry).writtenTo.set(targetPath, newGeneration);
|
|
958
|
+
cacheEntry.writtenTo.set(targetPath, newGeneration);
|
|
962
959
|
this._assetEmittingWrittenFiles.set(
|
|
963
960
|
targetPath,
|
|
964
961
|
newGeneration
|
|
@@ -983,11 +980,7 @@ ${other}`);
|
|
|
983
980
|
* @param {number} size size
|
|
984
981
|
*/
|
|
985
982
|
const updateWithReplacementSource = (size) => {
|
|
986
|
-
updateFileWithReplacementSource(
|
|
987
|
-
file,
|
|
988
|
-
/** @type {CacheEntry} */ (cacheEntry),
|
|
989
|
-
size
|
|
990
|
-
);
|
|
983
|
+
updateFileWithReplacementSource(file, cacheEntry, size);
|
|
991
984
|
/** @type {SimilarEntry} */
|
|
992
985
|
(similarEntry).size = size;
|
|
993
986
|
if (
|
|
@@ -1055,7 +1048,7 @@ ${other}`);
|
|
|
1055
1048
|
const processExistingFile = (stats) => {
|
|
1056
1049
|
// skip emitting if it's already there and an immutable file
|
|
1057
1050
|
if (immutable) {
|
|
1058
|
-
updateWithReplacementSource(
|
|
1051
|
+
updateWithReplacementSource(stats.size);
|
|
1059
1052
|
return keepExistingFile(stats);
|
|
1060
1053
|
}
|
|
1061
1054
|
|
|
@@ -1095,9 +1088,7 @@ ${other}`);
|
|
|
1095
1088
|
// if the target file has already been written
|
|
1096
1089
|
if (targetFileGeneration !== undefined) {
|
|
1097
1090
|
// check if the Source has been written to this target file
|
|
1098
|
-
const writtenGeneration =
|
|
1099
|
-
cacheEntry
|
|
1100
|
-
).writtenTo.get(targetPath);
|
|
1091
|
+
const writtenGeneration = cacheEntry.writtenTo.get(targetPath);
|
|
1101
1092
|
if (writtenGeneration === targetFileGeneration) {
|
|
1102
1093
|
// if yes, we may skip writing the file
|
|
1103
1094
|
// if it's already there
|
|
@@ -1105,7 +1096,7 @@ ${other}`);
|
|
|
1105
1096
|
|
|
1106
1097
|
if (this._assetEmittingPreviousFiles.has(targetPath)) {
|
|
1107
1098
|
const sizeOnlySource = /** @type {SizeOnlySource} */ (
|
|
1108
|
-
|
|
1099
|
+
cacheEntry.sizeOnlySource
|
|
1109
1100
|
);
|
|
1110
1101
|
|
|
1111
1102
|
// We assume that assets from the last compilation say intact on disk (they are not removed)
|
|
@@ -1209,8 +1200,7 @@ ${other}`);
|
|
|
1209
1200
|
)
|
|
1210
1201
|
);
|
|
1211
1202
|
}
|
|
1212
|
-
|
|
1213
|
-
(fs.utimes)(
|
|
1203
|
+
fs.utimes(
|
|
1214
1204
|
targetPath,
|
|
1215
1205
|
new Date(timestamps.atime),
|
|
1216
1206
|
new Date(timestamps.mtime),
|
|
@@ -1226,8 +1216,7 @@ ${other}`);
|
|
|
1226
1216
|
)
|
|
1227
1217
|
);
|
|
1228
1218
|
}
|
|
1229
|
-
|
|
1230
|
-
(fs.chmod)(targetPath, mode, setTimestamps);
|
|
1219
|
+
fs.chmod(targetPath, mode, setTimestamps);
|
|
1231
1220
|
}
|
|
1232
1221
|
|
|
1233
1222
|
/**
|
|
@@ -1282,13 +1271,11 @@ ${other}`);
|
|
|
1282
1271
|
|
|
1283
1272
|
const replace = () => {
|
|
1284
1273
|
if (!fs.unlink) return create();
|
|
1285
|
-
|
|
1286
|
-
(fs.unlink)(targetPath, () => create());
|
|
1274
|
+
fs.unlink(targetPath, () => create());
|
|
1287
1275
|
};
|
|
1288
1276
|
|
|
1289
1277
|
if (!fs.readlink) return replace();
|
|
1290
|
-
|
|
1291
|
-
(fs.readlink)(targetPath, (err, existingTarget) => {
|
|
1278
|
+
fs.readlink(targetPath, (err, existingTarget) => {
|
|
1292
1279
|
if (!err && existingTarget === target) return callback(null);
|
|
1293
1280
|
replace();
|
|
1294
1281
|
});
|