@depup/webpack 5.110.3-depup.0 → 5.111.1-depup.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 +7 -8
- package/changes.json +7 -11
- package/lib/APIPlugin.js +26 -11
- package/lib/AutomaticPrefetchPlugin.js +1 -1
- package/lib/Cache.js +8 -3
- package/lib/CacheFacade.js +1 -1
- package/lib/CircularModulesPlugin.js +157 -55
- package/lib/CleanPlugin.js +2 -2
- package/lib/CompatibilityPlugin.js +3 -4
- package/lib/Compilation.js +336 -337
- package/lib/Compiler.js +213 -51
- package/lib/ConstPlugin.js +16 -132
- package/lib/CopyPlugin.js +1054 -0
- package/lib/DefinePlugin.js +24 -8
- package/lib/DependencyTemplate.js +2 -1
- package/lib/DotenvPlugin.js +24 -28
- package/lib/ErrorHelpers.js +113 -0
- package/lib/ExportsInfo.js +20 -16
- package/lib/ExternalModule.js +47 -22
- package/lib/FileSystemInfo.js +17 -14
- package/lib/FlagDependencyExportsPlugin.js +53 -34
- package/lib/FlagDependencyUsagePlugin.js +9 -13
- package/lib/Generator.js +24 -2
- package/lib/HotModuleReplacementPlugin.js +55 -7
- package/lib/IgnorePlugin.js +1 -1
- package/lib/JavascriptMetaInfoPlugin.js +5 -3
- package/lib/LoaderOptionsPlugin.js +1 -1
- package/lib/MainTemplate.js +5 -1
- package/lib/Module.js +19 -10
- package/lib/ModuleGraph.js +6 -9
- package/lib/MultiCompiler.js +7 -17
- package/lib/MultiWatching.js +1 -1
- package/lib/NormalModule.js +135 -50
- package/lib/NormalModuleFactory.js +1 -1
- package/lib/RuntimeGlobals.js +21 -7
- package/lib/RuntimeModule.js +28 -12
- package/lib/RuntimePlugin.js +30 -3
- package/lib/RuntimeTemplate.js +813 -518
- package/lib/SourceMapDevToolPlugin.js +54 -104
- package/lib/TemplatedPathPlugin.js +16 -59
- package/lib/Watching.js +9 -0
- package/lib/WebpackOptionsApply.js +84 -91
- package/lib/asset/AssetBytesGenerator.js +7 -1
- package/lib/asset/AssetGenerator.js +50 -24
- package/lib/asset/AssetModule.js +3 -0
- package/lib/asset/AssetSourceGenerator.js +7 -1
- package/lib/asset/WebManifestParser.js +7 -5
- package/lib/buildChunkGraph.js +11 -15
- package/lib/cache/AddBuildDependenciesPlugin.js +33 -4
- package/lib/cache/IdleFileCachePlugin.js +2 -2
- package/lib/cache/MemoryCachePlugin.js +4 -4
- package/lib/cache/MemoryWithGcCachePlugin.js +7 -8
- package/lib/cache/PackFileCacheStrategy.js +17 -19
- package/lib/cache/getLazyHashedEtag.js +3 -5
- package/lib/config/browserslistTargetHandler.js +17 -4
- package/lib/config/defaults.js +138 -128
- package/lib/config/getClaimedAssetTypes.js +10 -11
- package/lib/config/normalization.js +82 -12
- package/lib/config/target.js +13 -4
- package/lib/container/ContainerReferencePlugin.js +6 -0
- package/lib/container/RemoteRuntimeModule.js +9 -0
- package/lib/container/declaredRemotes.js +39 -0
- package/lib/{ContextExclusionPlugin.js → context/ContextExclusionPlugin.js} +1 -1
- package/lib/{ContextModule.js → context/ContextModule.js} +54 -115
- package/lib/{ContextModuleFactory.js → context/ContextModuleFactory.js} +19 -21
- package/lib/{ContextReplacementPlugin.js → context/ContextReplacementPlugin.js} +4 -4
- package/lib/css/CssGenerator.js +27 -11
- package/lib/css/CssInjectStyleRuntimeModule.js +9 -0
- package/lib/css/CssLoadingRuntimeModule.js +94 -36
- package/lib/css/CssModule.js +1 -1
- package/lib/css/CssModulesPlugin.js +7 -6
- package/lib/css/CssParser.js +162 -31
- package/lib/css/CssServerStylesRuntimeModule.js +9 -0
- package/lib/css/cssMinify.js +43 -32
- package/lib/css/data.js +3514 -869
- package/lib/css/syntax.js +6370 -1220
- package/lib/debug/ProfilingPlugin.js +7 -4
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +6 -3
- package/lib/dependencies/AMDRuntimeModules.js +18 -0
- package/lib/dependencies/CommonJsExportRequireDependency.js +13 -12
- package/lib/dependencies/CommonJsExportsParserPlugin.js +12 -13
- package/lib/dependencies/CommonJsImportsParserPlugin.js +5 -5
- package/lib/dependencies/CommonJsPlugin.js +19 -3
- package/lib/dependencies/CommonJsRequireDependency.js +14 -5
- package/lib/dependencies/CommonJsSelfReferenceDependency.js +2 -4
- package/lib/dependencies/ContextDependency.js +1 -1
- package/lib/dependencies/ContextDependencyHelpers.js +3 -9
- package/lib/dependencies/ContextElementDependency.js +1 -1
- package/lib/dependencies/CssIcssExportDependency.js +13 -9
- package/lib/dependencies/CssIcssImportDependency.js +3 -6
- package/lib/dependencies/CssUrlDependency.js +3 -5
- package/lib/dependencies/HarmonyCompatibilityDependency.js +67 -22
- package/lib/dependencies/HarmonyDetectionParserPlugin.js +3 -4
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +10 -7
- package/lib/dependencies/HarmonyExportExpressionDependency.js +47 -33
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +74 -17
- package/lib/dependencies/HarmonyExportInitFragment.js +110 -23
- package/lib/dependencies/HarmonyExportSpecifierDependency.js +25 -58
- package/lib/dependencies/HarmonyImportBareSideEffectDependency.js +59 -0
- package/lib/dependencies/HarmonyImportDependency.js +6 -1
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +111 -17
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +3 -4
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +40 -3
- package/lib/dependencies/HarmonyModulesPlugin.js +20 -0
- package/lib/dependencies/HtmlEntryDependency.js +124 -102
- package/lib/dependencies/HtmlInlineScriptDependency.js +3 -4
- package/lib/dependencies/HtmlInlineStyleDependency.js +3 -4
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +1 -1
- package/lib/dependencies/ImportMetaGlobHelpers.js +1 -1
- package/lib/dependencies/ImportMetaMainDependency.js +104 -0
- package/lib/dependencies/ImportMetaPlugin.js +67 -25
- package/lib/dependencies/ImportParserPlugin.js +1 -1
- package/lib/dependencies/LoaderPlugin.js +26 -1
- package/lib/dependencies/RequireContextDependencyParserPlugin.js +1 -1
- package/lib/dependencies/SystemRuntimeModule.js +9 -0
- package/lib/dependencies/URLContextDependency.js +1 -1
- package/lib/dependencies/URLDependency.js +6 -5
- package/lib/dependencies/WorkerAndWorkletPlugin.js +15 -21
- package/lib/dependencies/WorkerDependency.js +7 -7
- package/lib/dependencies/WorkletDependency.js +7 -11
- package/lib/dll/DelegatedModule.js +18 -1
- package/lib/dll/DllReferencePlugin.js +11 -8
- package/lib/dll/LibManifestPlugin.js +1 -1
- package/lib/errors/AnalyzableBailoutsWarning.js +41 -0
- package/lib/errors/DuplicateModulesWarning.js +12 -7
- package/lib/errors/EmptyCopyPatternWarning.js +26 -0
- package/lib/errors/ExternalStarReexportError.js +44 -0
- package/lib/errors/HookWebpackError.js +3 -2
- package/lib/errors/MissingSourceMapsWarning.js +36 -0
- package/lib/errors/ModuleParseError.js +2 -1
- package/lib/errors/UnusedAssetsWarning.js +36 -0
- package/lib/errors/UnusedFederationWarning.js +35 -0
- package/lib/errors/UnusedModulesWarning.js +38 -0
- package/lib/esm/ExportWebpackRequireRuntimeModule.js +9 -0
- package/lib/esm/ModuleChunkFormatPlugin.js +28 -3
- package/lib/esm/ModuleChunkLoadingPlugin.js +30 -11
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +92 -60
- package/lib/hmr/HotModuleReplacement.runtime.js +8 -2
- package/lib/hmr/HotModuleReplacementRuntimeModule.js +9 -0
- package/lib/hmr/LazyCompilationPlugin.js +3 -5
- package/lib/html/HtmlGenerator.js +72 -87
- package/lib/html/HtmlModulesPlugin.js +418 -200
- package/lib/html/HtmlParser.js +110 -147
- package/lib/html/builtinEmbeddedRenderer.js +107 -0
- package/lib/html/data.js +142 -7
- package/lib/html/htmlMinify.js +92 -122
- package/lib/html/syntax.js +1618 -1391
- package/lib/ids/HashedModuleIdsPlugin.js +2 -1
- package/lib/index.js +49 -3
- package/lib/javascript/ChunkFormatHelpers.js +4 -3
- package/lib/javascript/JavascriptGenerator.js +8 -1
- package/lib/javascript/JavascriptModule.js +1 -0
- package/lib/javascript/JavascriptModulesPlugin.js +73 -72
- package/lib/javascript/JavascriptParser.js +1970 -900
- package/lib/javascript/StartupHelpers.js +27 -3
- package/lib/javascript/data.js +172 -0
- package/lib/javascript/grammar.js +5546 -0
- package/lib/javascript/parser.js +1500 -0
- package/lib/javascript/regexp.js +1762 -0
- package/lib/javascript/regexpData.js +51 -0
- package/lib/javascript/syntax.js +9061 -5262
- package/lib/json/JsonGenerator.js +7 -1
- package/lib/library/ModuleLibraryPlugin.js +171 -132
- package/lib/loaders/LoaderRunner.js +137 -9
- package/lib/node/NodeWatchFileSystem.js +3 -9
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +22 -0
- package/lib/node/RequireChunkLoadingRuntimeModule.js +22 -0
- package/lib/optimize/AggressiveMergingPlugin.js +3 -5
- package/lib/optimize/ConcatenatedModule.js +178 -120
- package/lib/optimize/ConstExportsPlugin.js +50 -39
- package/lib/optimize/FlagIncludedChunksPlugin.js +3 -11
- package/lib/optimize/InlineExports.js +20 -123
- package/lib/optimize/InnerGraphPlugin.js +7 -13
- package/lib/optimize/LimitChunkCountPlugin.js +5 -8
- package/lib/optimize/MangleExportsPlugin.js +13 -4
- package/lib/optimize/ModuleConcatenationPlugin.js +27 -5
- package/lib/optimize/RealContentHashPlugin.js +68 -9
- package/lib/optimize/SideEffectsFlagPlugin.js +24 -28
- package/lib/optimize/SplitChunksPlugin.js +2 -4
- package/lib/performance/AnalyzableBailoutsPlugin.js +115 -0
- package/lib/performance/BroadContextsPlugin.js +1 -1
- package/lib/performance/CacheEffectivenessPlugin.js +7 -7
- package/lib/performance/DuplicateModulesPlugin.js +57 -13
- package/lib/performance/EvalUsagePlugin.js +5 -2
- package/lib/performance/MissingSourceMapsPlugin.js +115 -0
- package/lib/performance/PureAnnotationsPlugin.js +6 -3
- package/lib/performance/SizeLimitsPlugin.js +2 -4
- package/lib/performance/TopLevelThisPlugin.js +5 -4
- package/lib/performance/UnusedAssetsPlugin.js +109 -0
- package/lib/performance/UnusedFederationPlugin.js +147 -0
- package/lib/performance/UnusedModulesPlugin.js +141 -0
- package/lib/performance/UnusedReexportsPlugin.js +1 -55
- package/lib/performance/isOnlyReexported.js +65 -0
- package/lib/prefetch/ChunkPrefetchFunctionRuntimeModule.js +25 -5
- package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +8 -8
- package/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js +9 -0
- package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +9 -0
- package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +9 -0
- package/lib/prefetch/ResourceHintPlugin.js +18 -23
- package/lib/prefetch/ResourceHintRuntimeModule.js +9 -0
- package/lib/prefetch/StartupAssetHintRuntimeModule.js +16 -10
- package/lib/rules/RuleSetCompiler.js +211 -4
- package/lib/runtime/AsyncModuleRuntimeModule.js +98 -66
- package/lib/runtime/AutoPublicPathRuntimeModule.js +9 -0
- package/lib/runtime/BaseUriRuntimeModule.js +9 -0
- package/lib/runtime/ChunkNameRuntimeModule.js +9 -0
- package/lib/runtime/EnsureChunkRuntimeModule.js +35 -16
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +12 -4
- package/lib/runtime/GetFullHashRuntimeModule.js +9 -0
- package/lib/runtime/GetMainFilenameRuntimeModule.js +9 -0
- package/lib/runtime/GetWorkletBootstrapRuntimeModule.js +9 -0
- package/lib/runtime/GlobalRuntimeModule.js +11 -4
- package/lib/runtime/HasOwnPropertyRuntimeModule.js +9 -0
- package/lib/runtime/HelperRuntimeModule.js +10 -0
- package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +305 -224
- package/lib/runtime/NonceRuntimeModule.js +9 -0
- package/lib/runtime/OnChunksLoadedRuntimeModule.js +67 -20
- package/lib/runtime/PublicPathRuntimeModule.js +9 -0
- package/lib/runtime/RuntimeIdRuntimeModule.js +9 -0
- package/lib/runtime/SpecNamespaceObjectRuntimeModule.js +90 -0
- package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +9 -0
- package/lib/runtime/StartupEntrypointRuntimeModule.js +9 -0
- package/lib/runtime/SystemContextRuntimeModule.js +9 -0
- package/lib/runtime/ToBinaryRuntimeModule.js +9 -0
- package/lib/schemes/DataUriPlugin.js +3 -6
- package/lib/schemes/VirtualUrlPlugin.js +1 -1
- package/lib/serialization/BinaryMiddleware.js +9 -9
- package/lib/serialization/FileMiddleware.js +16 -16
- package/lib/serialization/ObjectMiddleware.js +168 -139
- package/lib/sharing/ConsumeSharedPlugin.js +12 -0
- package/lib/sharing/ConsumeSharedRuntimeModule.js +11 -0
- package/lib/sharing/ShareRuntimeModule.js +9 -0
- package/lib/sharing/declaredShared.js +47 -0
- package/lib/stats/DefaultStatsFactoryPlugin.js +6 -5
- package/lib/stats/DefaultStatsPrinterPlugin.js +3 -0
- package/lib/typescript/TypeScriptPlugin.js +2 -3
- package/lib/url/URLParserPlugin.js +6 -8
- package/lib/util/LocConverter.js +4 -7
- package/lib/util/SourceProcessor.js +91 -91
- package/lib/util/async.js +292 -0
- package/lib/util/buildDiagnostics.js +69 -0
- package/lib/util/chainedImports.js +3 -4
- package/lib/util/concatenate.js +4 -4
- package/lib/util/createHooksRegistry.js +1 -2
- package/lib/util/dataURL.js +2 -3
- package/lib/util/deterministicGrouping.js +8 -13
- package/lib/util/findGraphRoots.js +6 -13
- package/lib/util/fs.js +27 -1
- package/lib/util/globUtils.js +1 -1
- package/lib/util/handlerKeys.js +40 -0
- package/lib/util/hash/wasm-hash.js +3 -4
- package/lib/util/identifier.js +20 -0
- package/lib/util/internalSerializables.js +5 -1
- package/lib/util/registerExternalSerializer.js +6 -45
- package/lib/util/semver.js +5 -3
- package/lib/wasm-async/AsyncWasmCompileRuntimeModule.js +9 -0
- package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +9 -0
- package/lib/wasm-async/AsyncWebAssemblyGenerator.js +6 -1
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +5 -1
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +12 -4
- package/lib/wasm-sync/WebAssemblyGenerator.js +6 -1
- package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +5 -1
- package/lib/wasm-sync/WebAssemblyUtils.js +2 -4
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +36 -0
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +19 -0
- package/package.json +55 -46
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +379 -66
- package/schemas/plugins/LoaderOptionsPlugin.check.js +1 -1
- package/schemas/plugins/ManifestPlugin.check.js +1 -1
- package/schemas/plugins/SourceMapDevToolPlugin.check.js +1 -1
- package/schemas/plugins/asset/AssetGeneratorOptions.check.js +1 -1
- package/schemas/plugins/asset/AssetResourceGeneratorOptions.check.js +1 -1
- package/schemas/plugins/container/ContainerPlugin.check.js +1 -1
- package/schemas/plugins/container/ModuleFederationPlugin.check.js +1 -1
- package/schemas/plugins/debug/ProfilingPlugin.check.js +1 -1
- package/schemas/plugins/dll/DllReferencePlugin.check.js +1 -1
- package/schemas/plugins/ids/HashedModuleIdsPlugin.check.js +1 -1
- package/schemas/plugins/schemes/HttpUriPlugin.check.js +1 -1
- package/types.d.ts +1723 -604
- package/lib/dependencies/ExportBindingInitFragment.js +0 -191
- package/lib/errors/EntrypointOverlapWarning.js +0 -45
- package/lib/performance/EntrypointOverlapPlugin.js +0 -122
|
@@ -12,6 +12,7 @@ const {
|
|
|
12
12
|
WEBASSEMBLY_MODULES
|
|
13
13
|
} = require("../ModuleTypeConstants");
|
|
14
14
|
const { dirname, mkdirpSync } = require("../util/fs");
|
|
15
|
+
const { fileUrlToPath } = require("../util/identifier");
|
|
15
16
|
|
|
16
17
|
/** @import { Session } from "inspector" */
|
|
17
18
|
/** @import { FullTap } from "tapable" */
|
|
@@ -149,10 +150,9 @@ class Profiler {
|
|
|
149
150
|
// Avoid coverage problems due indirect changes
|
|
150
151
|
/* istanbul ignore next */
|
|
151
152
|
if (profile.startTime < this._startTime || profile.endTime > endTime) {
|
|
152
|
-
//
|
|
153
|
-
//
|
|
154
|
-
//
|
|
155
|
-
// same point in time.
|
|
153
|
+
// `process.hrtime` and the inspector timestamps are each relative to an
|
|
154
|
+
// unknown point in time, with no guarantee it is the same point, so the
|
|
155
|
+
// two are rescaled onto one another here.
|
|
156
156
|
const duration = profile.endTime - profile.startTime;
|
|
157
157
|
const ownDuration = endTime - this._startTime;
|
|
158
158
|
const untracked = Math.max(0, ownDuration - duration);
|
|
@@ -258,6 +258,9 @@ class ProfilingPlugin {
|
|
|
258
258
|
* @param {ProfilingPluginOptions=} options options object
|
|
259
259
|
*/
|
|
260
260
|
constructor(options = {}) {
|
|
261
|
+
if (typeof options.outputPath === "string") {
|
|
262
|
+
options.outputPath = fileUrlToPath(options.outputPath);
|
|
263
|
+
}
|
|
261
264
|
/** @type {ProfilingPluginOptions} */
|
|
262
265
|
this.options = options;
|
|
263
266
|
}
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
"use strict";
|
|
7
7
|
|
|
8
8
|
const RuntimeGlobals = require("../RuntimeGlobals");
|
|
9
|
+
const { recordOptimizationBailout } = require("../util/buildDiagnostics");
|
|
9
10
|
const AMDDefineDependency = require("./AMDDefineDependency");
|
|
10
11
|
const AMDRequireArrayDependency = require("./AMDRequireArrayDependency");
|
|
11
12
|
const AMDRequireContextDependency = require("./AMDRequireContextDependency");
|
|
@@ -35,6 +36,7 @@ const { addLocalModule, getLocalModule } = require("./LocalModulesHelpers");
|
|
|
35
36
|
* } from "../../declarations/WebpackOptions"
|
|
36
37
|
*/
|
|
37
38
|
/** @import Dependency from "../Dependency" */
|
|
39
|
+
/** @import { BuildInfo } from "../Module" */
|
|
38
40
|
/** @import BasicEvaluatedExpression from "../javascript/BasicEvaluatedExpression" */
|
|
39
41
|
/**
|
|
40
42
|
* @import JavascriptParser, {
|
|
@@ -353,9 +355,10 @@ class AMDDefineDependencyParserPlugin {
|
|
|
353
355
|
return;
|
|
354
356
|
}
|
|
355
357
|
DynamicExports.bailout(parser.state);
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
358
|
+
recordOptimizationBailout(
|
|
359
|
+
/** @type {BuildInfo} */ (parser.state.module.buildInfo),
|
|
360
|
+
"AMD bailout: define() prevents static exports analysis"
|
|
361
|
+
);
|
|
359
362
|
/** @type {Identifier[] | null} */
|
|
360
363
|
let fnParams = null;
|
|
361
364
|
let fnParamsOffset = 0;
|
|
@@ -25,6 +25,15 @@ class AMDDefineRuntimeModule extends RuntimeModule {
|
|
|
25
25
|
return false;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
/**
|
|
29
|
+
* The `[handlerMap, key]` pairs this module installs onto a chunk handler map
|
|
30
|
+
* such as `__webpack_require__.f`, or `null` where it cannot name them.
|
|
31
|
+
* @returns {[string, string][] | null} installed chunk handlers (do not mutate)
|
|
32
|
+
*/
|
|
33
|
+
getInstalledChunkHandlers() {
|
|
34
|
+
return RuntimeModule.NO_CHUNK_HANDLERS;
|
|
35
|
+
}
|
|
36
|
+
|
|
28
37
|
/**
|
|
29
38
|
* Generates runtime code for this runtime module.
|
|
30
39
|
* @returns {string | null} runtime code
|
|
@@ -58,6 +67,15 @@ class AMDOptionsRuntimeModule extends RuntimeModule {
|
|
|
58
67
|
this.options = options;
|
|
59
68
|
}
|
|
60
69
|
|
|
70
|
+
/**
|
|
71
|
+
* The `[handlerMap, key]` pairs this module installs onto a chunk handler map
|
|
72
|
+
* such as `__webpack_require__.f`, or `null` where it cannot name them.
|
|
73
|
+
* @returns {[string, string][] | null} installed chunk handlers (do not mutate)
|
|
74
|
+
*/
|
|
75
|
+
getInstalledChunkHandlers() {
|
|
76
|
+
return RuntimeModule.NO_CHUNK_HANDLERS;
|
|
77
|
+
}
|
|
78
|
+
|
|
61
79
|
/**
|
|
62
80
|
* Generates runtime code for this runtime module.
|
|
63
81
|
* @returns {string | null} runtime code
|
|
@@ -273,23 +273,22 @@ class CommonJsExportRequireDependency extends ModuleDependency {
|
|
|
273
273
|
const from = moduleGraph.getConnection(this);
|
|
274
274
|
if (!from) return;
|
|
275
275
|
if (esmUnwrap) {
|
|
276
|
-
//
|
|
277
|
-
//
|
|
278
|
-
//
|
|
279
|
-
// properties webpack cannot enumerate statically.
|
|
276
|
+
// In `module.exports = require("./esm")` of a module carrying a
|
|
277
|
+
// `"module.exports"` export, this module's own exports become the
|
|
278
|
+
// unwrapped value, whose properties cannot be enumerated statically.
|
|
280
279
|
return {
|
|
281
280
|
exports: true,
|
|
282
281
|
canMangle: false,
|
|
283
282
|
dependencies: [from.module]
|
|
284
283
|
};
|
|
285
284
|
}
|
|
286
|
-
//
|
|
287
|
-
// FlagDependencyExportsPlugin yet
|
|
288
|
-
//
|
|
289
|
-
//
|
|
290
|
-
//
|
|
291
|
-
//
|
|
292
|
-
//
|
|
285
|
+
// WHY: the imported namespace ESM has not been flagged by
|
|
286
|
+
// FlagDependencyExportsPlugin yet, so its `"module.exports"` unwrap
|
|
287
|
+
// eligibility is still unknown. Star-reexporting now would add `__esModule`,
|
|
288
|
+
// and names, that the monotonic merge cannot retract once the module turns
|
|
289
|
+
// out to unwrap, making the result order-dependent across runtimes. Deferring
|
|
290
|
+
// is safe: the `from.module` dependency re-queues this once its exports —
|
|
291
|
+
// owned names, or a dynamic `other` — become known.
|
|
293
292
|
if (
|
|
294
293
|
importedModule &&
|
|
295
294
|
importedModule.getExportsType(moduleGraph, false) === "namespace"
|
|
@@ -528,7 +527,9 @@ CommonJsExportRequireDependency.Template = class CommonJsExportRequireDependency
|
|
|
528
527
|
: ids;
|
|
529
528
|
requireExpr = concatenationScope.createModuleReference(importedModule, {
|
|
530
529
|
ids: requestedIds.length > 0 ? requestedIds : undefined,
|
|
531
|
-
|
|
530
|
+
// a used reexport keeps its assignment, so only an unused one is
|
|
531
|
+
// left standing where the original statement began
|
|
532
|
+
asiSafe: used ? true : dep.asiSafe,
|
|
532
533
|
moduleExportsAccess: true
|
|
533
534
|
});
|
|
534
535
|
} else {
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
const RuntimeGlobals = require("../RuntimeGlobals");
|
|
9
9
|
const { evaluateToString } = require("../javascript/JavascriptParserHelpers");
|
|
10
|
+
const { recordOptimizationBailout } = require("../util/buildDiagnostics");
|
|
10
11
|
const formatLocation = require("../util/formatLocation");
|
|
11
12
|
const { propertyAccess } = require("../util/property");
|
|
12
13
|
const CommonJsExportRequireDependency = require("./CommonJsExportRequireDependency");
|
|
@@ -38,7 +39,7 @@ const FUNCTION_PROPERTY_DROP_HEAD =
|
|
|
38
39
|
* } from "estree"
|
|
39
40
|
*/
|
|
40
41
|
/** @import { ExportInfoName } from "../Dependency" */
|
|
41
|
-
/** @import
|
|
42
|
+
/** @import { BuildInfo } from "../Module" */
|
|
42
43
|
/** @import BasicEvaluatedExpression from "../javascript/BasicEvaluatedExpression" */
|
|
43
44
|
/**
|
|
44
45
|
* @import JavascriptParser, {
|
|
@@ -357,15 +358,6 @@ const getObjectExportKind = (property) => {
|
|
|
357
358
|
const PLUGIN_NAME = "CommonJsExportsParserPlugin";
|
|
358
359
|
|
|
359
360
|
class CommonJsExportsParserPlugin {
|
|
360
|
-
/**
|
|
361
|
-
* Creates an instance of CommonJsExportsParserPlugin.
|
|
362
|
-
* @param {ModuleGraph} moduleGraph module graph
|
|
363
|
-
*/
|
|
364
|
-
constructor(moduleGraph) {
|
|
365
|
-
/** @type {ModuleGraph} */
|
|
366
|
-
this.moduleGraph = moduleGraph;
|
|
367
|
-
}
|
|
368
|
-
|
|
369
361
|
/**
|
|
370
362
|
* Applies the plugin by registering its hooks on the compiler.
|
|
371
363
|
* @param {JavascriptParser} parser the parser
|
|
@@ -406,9 +398,10 @@ class CommonJsExportsParserPlugin {
|
|
|
406
398
|
* @param {string} reason reason
|
|
407
399
|
*/
|
|
408
400
|
const bailoutHint = (reason) => {
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
401
|
+
recordOptimizationBailout(
|
|
402
|
+
/** @type {BuildInfo} */ (parser.state.module.buildInfo),
|
|
403
|
+
`CommonJS bailout: ${reason}`
|
|
404
|
+
);
|
|
412
405
|
};
|
|
413
406
|
/** @type {unknown} */
|
|
414
407
|
let keptAllExportsForState;
|
|
@@ -479,6 +472,9 @@ class CommonJsExportsParserPlugin {
|
|
|
479
472
|
requireCall.ids,
|
|
480
473
|
!parser.isStatementLevelExpression(expr)
|
|
481
474
|
);
|
|
475
|
+
dep.asiSafe = !parser.isAsiPosition(
|
|
476
|
+
/** @type {Range} */ (expr.range)[0]
|
|
477
|
+
);
|
|
482
478
|
dep.loc = parser.getLocation(expr);
|
|
483
479
|
dep.optional = Boolean(parser.scope.inTry);
|
|
484
480
|
parser.state.module.addDependency(dep);
|
|
@@ -670,6 +666,9 @@ class CommonJsExportsParserPlugin {
|
|
|
670
666
|
false
|
|
671
667
|
);
|
|
672
668
|
dep.getter = reexport.getter;
|
|
669
|
+
dep.asiSafe = !parser.isAsiPosition(
|
|
670
|
+
/** @type {Range} */ (expr.range)[0]
|
|
671
|
+
);
|
|
673
672
|
dep.loc = parser.getLocation(expr);
|
|
674
673
|
dep.optional = Boolean(parser.scope.inTry);
|
|
675
674
|
parser.state.module.addDependency(dep);
|
|
@@ -212,6 +212,7 @@ const createRequireCallHandler = (
|
|
|
212
212
|
/** @type {Range} */ (expr.range)
|
|
213
213
|
);
|
|
214
214
|
if (binding) binding.dep = dep;
|
|
215
|
+
dep.asiSafe = !parser.isAsiPosition(/** @type {Range} */ (expr.range)[0]);
|
|
215
216
|
dep.loc = parser.getLocation(expr);
|
|
216
217
|
dep.optional = Boolean(parser.scope.inTry);
|
|
217
218
|
parser.state.current.addDependency(dep);
|
|
@@ -737,11 +738,10 @@ class CommonJsImportsParserPlugin {
|
|
|
737
738
|
// #endregion
|
|
738
739
|
|
|
739
740
|
// #region Require bound to a const variable
|
|
740
|
-
|
|
741
|
-
// `NAME
|
|
742
|
-
//
|
|
743
|
-
//
|
|
744
|
-
// rather than destructured.
|
|
741
|
+
|
|
742
|
+
// Track `const NAME = require(LITERAL)`, so a static member access on `NAME`
|
|
743
|
+
// forwards to the same dependency as a referenced export and a CommonJS
|
|
744
|
+
// module bound to a name still tree-shakes.
|
|
745
745
|
parser.hooks.preDeclarator.tap(PLUGIN_NAME, (declarator, statement) => {
|
|
746
746
|
if (statement.kind !== "const") return;
|
|
747
747
|
if (declarator.id.type !== "Identifier") return;
|
|
@@ -254,9 +254,7 @@ class CommonJsPlugin {
|
|
|
254
254
|
);
|
|
255
255
|
|
|
256
256
|
new CommonJsImportsParserPlugin(parserOptions).apply(parser);
|
|
257
|
-
new CommonJsExportsParserPlugin(
|
|
258
|
-
parser
|
|
259
|
-
);
|
|
257
|
+
new CommonJsExportsParserPlugin().apply(parser);
|
|
260
258
|
};
|
|
261
259
|
|
|
262
260
|
normalModuleFactory.hooks.parser
|
|
@@ -285,6 +283,15 @@ class HarmonyModuleDecoratorRuntimeModule extends RuntimeModule {
|
|
|
285
283
|
return false;
|
|
286
284
|
}
|
|
287
285
|
|
|
286
|
+
/**
|
|
287
|
+
* The `[handlerMap, key]` pairs this module installs onto a chunk handler map
|
|
288
|
+
* such as `__webpack_require__.f`, or `null` where it cannot name them.
|
|
289
|
+
* @returns {[string, string][] | null} installed chunk handlers (do not mutate)
|
|
290
|
+
*/
|
|
291
|
+
getInstalledChunkHandlers() {
|
|
292
|
+
return RuntimeModule.NO_CHUNK_HANDLERS;
|
|
293
|
+
}
|
|
294
|
+
|
|
288
295
|
/**
|
|
289
296
|
* Generates runtime code for this runtime module.
|
|
290
297
|
* @returns {string | null} runtime code
|
|
@@ -326,6 +333,15 @@ class NodeModuleDecoratorRuntimeModule extends RuntimeModule {
|
|
|
326
333
|
return false;
|
|
327
334
|
}
|
|
328
335
|
|
|
336
|
+
/**
|
|
337
|
+
* The `[handlerMap, key]` pairs this module installs onto a chunk handler map
|
|
338
|
+
* such as `__webpack_require__.f`, or `null` where it cannot name them.
|
|
339
|
+
* @returns {[string, string][] | null} installed chunk handlers (do not mutate)
|
|
340
|
+
*/
|
|
341
|
+
getInstalledChunkHandlers() {
|
|
342
|
+
return RuntimeModule.NO_CHUNK_HANDLERS;
|
|
343
|
+
}
|
|
344
|
+
|
|
329
345
|
/**
|
|
330
346
|
* Generates runtime code for this runtime module.
|
|
331
347
|
* @returns {string | null} runtime code
|
|
@@ -36,8 +36,8 @@ const ModuleDependency = require("./ModuleDependency");
|
|
|
36
36
|
/** @import { UsedByExports } from "../optimize/InnerGraph" */
|
|
37
37
|
/** @import { RuntimeSpec } from "../util/runtime" */
|
|
38
38
|
/** @import { DependencyGuard } from "./HarmonyImportGuard" */
|
|
39
|
-
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext<[RawReferencedExports | null, Range | undefined, DependencyGuard[] | undefined, boolean, boolean, UsedByExports | undefined]>} ObjectDeserializerContext */
|
|
40
|
-
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext<[RawReferencedExports | null, Range | undefined, DependencyGuard[] | undefined, boolean, boolean, UsedByExports | undefined]>} ObjectSerializerContext */
|
|
39
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext<[RawReferencedExports | null, Range | undefined, DependencyGuard[] | undefined, boolean, boolean, UsedByExports | undefined, boolean | undefined]>} ObjectDeserializerContext */
|
|
40
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext<[RawReferencedExports | null, Range | undefined, DependencyGuard[] | undefined, boolean, boolean, UsedByExports | undefined, boolean | undefined]>} ObjectSerializerContext */
|
|
41
41
|
|
|
42
42
|
/**
|
|
43
43
|
* Trims a member-access path at the first segment that is definitively not a
|
|
@@ -93,6 +93,10 @@ class CommonJsRequireDependency extends ModuleDependency {
|
|
|
93
93
|
// `new require(...)`; see the template for the return-value rule
|
|
94
94
|
/** @type {boolean} */
|
|
95
95
|
this.callNew = false;
|
|
96
|
+
// whether the position the call sits at cannot be joined to what precedes
|
|
97
|
+
// it by ASI; only meaningful once the call renders as a module reference
|
|
98
|
+
/** @type {boolean | undefined} */
|
|
99
|
+
this.asiSafe = undefined;
|
|
96
100
|
}
|
|
97
101
|
|
|
98
102
|
get type() {
|
|
@@ -226,7 +230,8 @@ class CommonJsRequireDependency extends ModuleDependency {
|
|
|
226
230
|
.write(this.branchGuards)
|
|
227
231
|
.write(this._canConcatenate)
|
|
228
232
|
.write(this.callNew)
|
|
229
|
-
.write(this.usedByExports)
|
|
233
|
+
.write(this.usedByExports)
|
|
234
|
+
.write(this.asiSafe);
|
|
230
235
|
super.serialize(context);
|
|
231
236
|
}
|
|
232
237
|
|
|
@@ -246,7 +251,9 @@ class CommonJsRequireDependency extends ModuleDependency {
|
|
|
246
251
|
this.callNew = c4.read();
|
|
247
252
|
const c5 = c4.rest;
|
|
248
253
|
this.usedByExports = c5.read();
|
|
249
|
-
|
|
254
|
+
const c6 = c5.rest;
|
|
255
|
+
this.asiSafe = c6.read();
|
|
256
|
+
super.deserialize(c6.rest);
|
|
250
257
|
}
|
|
251
258
|
}
|
|
252
259
|
|
|
@@ -303,7 +310,9 @@ CommonJsRequireDependency.Template = class CommonJsRequireDependencyTemplate ext
|
|
|
303
310
|
ids: isRequireEsmModuleExportsModule(connection.module, moduleGraph)
|
|
304
311
|
? [ESM_MODULE_EXPORTS_NAME]
|
|
305
312
|
: undefined,
|
|
306
|
-
|
|
313
|
+
// `new` wraps the reference in a call, so only a plain
|
|
314
|
+
// replacement inherits the original call's position
|
|
315
|
+
asiSafe: dep.callNew ? true : dep.asiSafe,
|
|
307
316
|
moduleExportsAccess: true
|
|
308
317
|
}
|
|
309
318
|
);
|
|
@@ -207,10 +207,8 @@ CommonJsSelfReferenceDependency.Template = class CommonJsSelfReferenceDependency
|
|
|
207
207
|
}
|
|
208
208
|
|
|
209
209
|
if (base === dep.base && equals(used, dep.names)) {
|
|
210
|
-
// Nothing has to
|
|
211
|
-
//
|
|
212
|
-
// for plugins that update `module._source` which they
|
|
213
|
-
// shouldn't do!
|
|
210
|
+
// Nothing has to change, and no replacement is emitted: plugins that
|
|
211
|
+
// update `module._source`, which they should not, depend on that.
|
|
214
212
|
return;
|
|
215
213
|
}
|
|
216
214
|
|
|
@@ -15,7 +15,7 @@ const getCriticalDependencyWarning = memoize(() =>
|
|
|
15
15
|
);
|
|
16
16
|
|
|
17
17
|
/** @import { Range } from "../javascript/JavascriptParser" */
|
|
18
|
-
/** @import { ContextOptions } from "../ContextModule" */
|
|
18
|
+
/** @import { ContextOptions } from "../context/ContextModule" */
|
|
19
19
|
/** @import { TRANSITIVE } from "../Dependency" */
|
|
20
20
|
/** @import ModuleGraph from "../ModuleGraph" */
|
|
21
21
|
/** @import WebpackError from "../errors/WebpackError" */
|
|
@@ -107,15 +107,9 @@ module.exports.create = (
|
|
|
107
107
|
)
|
|
108
108
|
.join("");
|
|
109
109
|
|
|
110
|
-
//
|
|
111
|
-
//
|
|
112
|
-
//
|
|
113
|
-
// innerQuasis: [BEE("inner"), BEE("inner2")]
|
|
114
|
-
// (BEE = BasicEvaluatedExpression)
|
|
115
|
-
// postfix: "post"
|
|
116
|
-
// query: "?query"
|
|
117
|
-
// fragment: "#frag"
|
|
118
|
-
// regExp: /^\.\/pre.*inner.*inner2.*post$/
|
|
110
|
+
// The template's quasis become the literal anchors of the regexp and its
|
|
111
|
+
// expressions the gaps between them, so `./context/pre${e}inner${e}post`
|
|
112
|
+
// matches `/^\.\/pre.*inner.*post$/` under the context `./context`.
|
|
119
113
|
const regExp = new RegExp(
|
|
120
114
|
`^${quoteMeta(prefix)}${innerRegExp}${quoteMeta(postfix)}$`
|
|
121
115
|
);
|
|
@@ -9,7 +9,7 @@ const Dependency = require("../Dependency");
|
|
|
9
9
|
const makeSerializable = require("../util/makeSerializable");
|
|
10
10
|
const ModuleDependency = require("./ModuleDependency");
|
|
11
11
|
|
|
12
|
-
/** @import ContextModule from "../ContextModule" */
|
|
12
|
+
/** @import ContextModule from "../context/ContextModule" */
|
|
13
13
|
/** @import { RawReferencedExports, ReferencedExports } from "../Dependency" */
|
|
14
14
|
/** @import Module from "../Module" */
|
|
15
15
|
/** @import ModuleGraph from "../ModuleGraph" */
|
|
@@ -370,10 +370,9 @@ class CssIcssExportDependency extends NullDependency {
|
|
|
370
370
|
* @returns {ReferencedExports} referenced exports
|
|
371
371
|
*/
|
|
372
372
|
getReferencedExports(moduleGraph, runtime) {
|
|
373
|
-
// `composes: foo;`
|
|
374
|
-
//
|
|
375
|
-
//
|
|
376
|
-
// presence of any such entry subsumes the self-reference names.
|
|
373
|
+
// `composes: foo;` references the composed class, not the composing one.
|
|
374
|
+
// Every other entry mode references the whole exports object, so one such
|
|
375
|
+
// entry subsumes the self-reference names.
|
|
377
376
|
let hasNonSelfReference = false;
|
|
378
377
|
/** @type {ReferencedExports} */
|
|
379
378
|
const referenced = [];
|
|
@@ -850,10 +849,9 @@ CssIcssExportDependency.Template = class CssIcssExportDependencyTemplate extends
|
|
|
850
849
|
if (!entry.interpolate) return value;
|
|
851
850
|
const { moduleGraph, module, chunkGraph, runtimeTemplate } =
|
|
852
851
|
templateContext;
|
|
853
|
-
//
|
|
854
|
-
//
|
|
855
|
-
//
|
|
856
|
-
// three elements below it, which are constant for the whole compilation.
|
|
852
|
+
// Keys are ordered by rising cardinality, since `moduleGraph.cached` is a
|
|
853
|
+
// trie allocating a node per level per prefix: the per-export `value` last,
|
|
854
|
+
// or every name forks the trie above the parts constant for the build.
|
|
857
855
|
return moduleGraph.cached(
|
|
858
856
|
computeInterpolatedIdentifier,
|
|
859
857
|
/** @type {CssModule} */ (module),
|
|
@@ -916,7 +914,13 @@ CssIcssExportDependency.Template = class CssIcssExportDependencyTemplate extends
|
|
|
916
914
|
}
|
|
917
915
|
|
|
918
916
|
if (entry.exportType === EXPORT_TYPE.GRID_CUSTOM_IDENTIFIER) {
|
|
919
|
-
|
|
917
|
+
// The suffix names what the identifier was built from, so it follows a
|
|
918
|
+
// `@value` to its resolved name — both spellings select the same line.
|
|
919
|
+
value += `-${
|
|
920
|
+
isReference
|
|
921
|
+
? /** @type {string[]} */ (entry.value)[0]
|
|
922
|
+
: /** @type {string} */ (entry.value)
|
|
923
|
+
}`;
|
|
920
924
|
}
|
|
921
925
|
|
|
922
926
|
if (isJs && entry.exportMode !== EXPORT_MODE.NONE) {
|
|
@@ -100,12 +100,9 @@ class CssIcssImportDependency extends CssImportDependency {
|
|
|
100
100
|
|
|
101
101
|
if (!module) return null;
|
|
102
102
|
|
|
103
|
-
// The target
|
|
104
|
-
//
|
|
105
|
-
//
|
|
106
|
-
// any custom function that drops the original spelling). Expand
|
|
107
|
-
// `importName` through the *target* module's convention and accept
|
|
108
|
-
// if any alias is provided.
|
|
103
|
+
// The target stores exports under its own `exportsConvention`, so asking for
|
|
104
|
+
// the raw name misses under `camel-case-only` or any convention dropping the
|
|
105
|
+
// original spelling. Expand through that convention and accept any alias.
|
|
109
106
|
const generator =
|
|
110
107
|
/** @type {CssGenerator | undefined} */
|
|
111
108
|
(module.generator);
|
|
@@ -84,11 +84,9 @@ class CssUrlDependency extends ModuleDependency {
|
|
|
84
84
|
* @returns {void}
|
|
85
85
|
*/
|
|
86
86
|
updateHash(hash, context) {
|
|
87
|
-
// The
|
|
88
|
-
//
|
|
89
|
-
//
|
|
90
|
-
// CSS module's hash invalidates — and the CSS chunk's contenthash
|
|
91
|
-
// updates — whenever the referenced asset's content changes.
|
|
87
|
+
// The template substitutes the asset's hashed filename into the rendered CSS,
|
|
88
|
+
// so folding that asset's content hash in here is what makes the CSS module's
|
|
89
|
+
// hash, and the chunk's contenthash, follow the asset.
|
|
92
90
|
const { chunkGraph } = context;
|
|
93
91
|
const module = chunkGraph.moduleGraph.getModule(this);
|
|
94
92
|
if (!module) return;
|
|
@@ -13,15 +13,18 @@ const makeSerializable = require("../util/makeSerializable");
|
|
|
13
13
|
const memoize = require("../util/memoize");
|
|
14
14
|
const NullDependency = require("./NullDependency");
|
|
15
15
|
|
|
16
|
-
// Required here rather than at the top: the
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
// Required here rather than at the top: the deferred-namespace runtime imports
|
|
17
|
+
// dependencies from here.
|
|
18
|
+
const getDeferredCycleHelpers = memoize(() =>
|
|
19
|
+
require("../runtime/MakeDeferredNamespaceObjectRuntime")
|
|
19
20
|
);
|
|
20
21
|
|
|
21
22
|
/** @import { ReplaceSource } from "webpack-sources" */
|
|
22
23
|
/** @import Dependency from "../Dependency" */
|
|
23
24
|
/** @import { DependencyTemplateContext } from "../DependencyTemplate" */
|
|
24
|
-
/** @import { BuildMeta } from "../Module" */
|
|
25
|
+
/** @import Module, { BuildMeta } from "../Module" */
|
|
26
|
+
/** @import ModuleGraph from "../ModuleGraph" */
|
|
27
|
+
/** @import ChunkGraph, { ModuleId } from "../ChunkGraph" */
|
|
25
28
|
/**
|
|
26
29
|
* @import {
|
|
27
30
|
* JavascriptModuleBuildInfo
|
|
@@ -39,6 +42,39 @@ makeSerializable(
|
|
|
39
42
|
"webpack/lib/dependencies/HarmonyCompatibilityDependency"
|
|
40
43
|
);
|
|
41
44
|
|
|
45
|
+
/**
|
|
46
|
+
* Key shared by the async modules of one strongly-connected component. The spec
|
|
47
|
+
* records one `[[EvaluationError]]` per component, so a member that already
|
|
48
|
+
* fulfilled still has to report the root's error afterwards.
|
|
49
|
+
* @param {ModuleGraph} moduleGraph the module graph
|
|
50
|
+
* @param {ChunkGraph} chunkGraph the chunk graph
|
|
51
|
+
* @param {Module} module the async module
|
|
52
|
+
* @returns {ModuleId | null} the group key, or null when it is not in an async cycle
|
|
53
|
+
*/
|
|
54
|
+
const getAsyncCycleGroupId = (moduleGraph, chunkGraph, module) => {
|
|
55
|
+
const { getDeferredCycleModules } = getDeferredCycleHelpers();
|
|
56
|
+
const peers = getDeferredCycleModules(moduleGraph, module);
|
|
57
|
+
if (peers === null) return null;
|
|
58
|
+
// The component's smallest async member id names the group, so every member
|
|
59
|
+
// emits the same key and none has to carry the whole peer list.
|
|
60
|
+
let groupId = null;
|
|
61
|
+
let asyncPeerCount = 0;
|
|
62
|
+
for (const peer of peers) {
|
|
63
|
+
if (!moduleGraph.isAsync(peer)) continue;
|
|
64
|
+
asyncPeerCount++;
|
|
65
|
+
const id = chunkGraph.getModuleId(peer);
|
|
66
|
+
if (id !== null && (groupId === null || `${id}` < `${groupId}`)) {
|
|
67
|
+
groupId = id;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if (asyncPeerCount === 0) return null;
|
|
71
|
+
const ownId = chunkGraph.getModuleId(module);
|
|
72
|
+
if (ownId !== null && (groupId === null || `${ownId}` < `${groupId}`)) {
|
|
73
|
+
groupId = ownId;
|
|
74
|
+
}
|
|
75
|
+
return groupId;
|
|
76
|
+
};
|
|
77
|
+
|
|
42
78
|
HarmonyCompatibilityDependency.Template = class HarmonyExportDependencyTemplate extends (
|
|
43
79
|
NullDependency.Template
|
|
44
80
|
) {
|
|
@@ -56,10 +92,12 @@ HarmonyCompatibilityDependency.Template = class HarmonyExportDependencyTemplate
|
|
|
56
92
|
module,
|
|
57
93
|
runtimeTemplate,
|
|
58
94
|
moduleGraph,
|
|
95
|
+
chunkGraph,
|
|
59
96
|
initFragments,
|
|
60
97
|
runtimeRequirements,
|
|
61
98
|
runtime,
|
|
62
|
-
concatenationScope
|
|
99
|
+
concatenationScope,
|
|
100
|
+
getData
|
|
63
101
|
}
|
|
64
102
|
) {
|
|
65
103
|
// a wrapped module has a real exports object that still needs `__esModule`
|
|
@@ -73,20 +111,13 @@ HarmonyCompatibilityDependency.Template = class HarmonyExportDependencyTemplate
|
|
|
73
111
|
exportsArgument: module.exportsArgument,
|
|
74
112
|
runtimeRequirements
|
|
75
113
|
});
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
hooks.onDemandExportsGeneration.call(
|
|
84
|
-
module,
|
|
85
|
-
runtime,
|
|
86
|
-
content,
|
|
87
|
-
false
|
|
88
|
-
) === true;
|
|
89
|
-
if (!takenOver) {
|
|
114
|
+
|
|
115
|
+
const meta = moduleGraph.getMetaIfExisting(module);
|
|
116
|
+
if (!concatenationScope && meta && meta.onDemandExports && getData) {
|
|
117
|
+
const data = getData();
|
|
118
|
+
const before = data.get("exportsSource");
|
|
119
|
+
data.set("exportsSource", before ? `${before}${content}` : content);
|
|
120
|
+
} else {
|
|
90
121
|
initFragments.push(
|
|
91
122
|
new InitFragment(
|
|
92
123
|
content,
|
|
@@ -99,9 +130,23 @@ HarmonyCompatibilityDependency.Template = class HarmonyExportDependencyTemplate
|
|
|
99
130
|
}
|
|
100
131
|
if (moduleGraph.isAsync(module)) {
|
|
101
132
|
runtimeRequirements.add(RuntimeGlobals.module);
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
133
|
+
// Only `strictModuleErrorHandling` keeps a recorded error for later
|
|
134
|
+
// requires, so the component's peers are worth naming only then.
|
|
135
|
+
const cycleGroupId = runtimeTemplate.outputOptions
|
|
136
|
+
.strictModuleErrorHandling
|
|
137
|
+
? getAsyncCycleGroupId(moduleGraph, chunkGraph, module)
|
|
138
|
+
: null;
|
|
139
|
+
// The group is keyed by module id, so the runtime needs `module.id`.
|
|
140
|
+
if (cycleGroupId !== null) {
|
|
141
|
+
runtimeRequirements.add(RuntimeGlobals.moduleId);
|
|
142
|
+
}
|
|
143
|
+
const isAsyncBody = /** @type {BuildMeta} */ (module.buildMeta).async;
|
|
144
|
+
const hasAwait =
|
|
145
|
+
cycleGroupId === null
|
|
146
|
+
? isAsyncBody
|
|
147
|
+
? ", 1"
|
|
148
|
+
: ""
|
|
149
|
+
: `, ${isAsyncBody ? 1 : 0}, ${JSON.stringify(cycleGroupId)}`;
|
|
105
150
|
// A module-scope `await using` is disposed when its scope ends, so the body
|
|
106
151
|
// needs a block that closes before the module reports completion —
|
|
107
152
|
// otherwise dependents run before disposal is awaited.
|
|
@@ -109,10 +109,9 @@ module.exports = class HarmonyDetectionParserPlugin {
|
|
|
109
109
|
}
|
|
110
110
|
});
|
|
111
111
|
|
|
112
|
-
//
|
|
113
|
-
//
|
|
114
|
-
//
|
|
115
|
-
// through `unhandledExpressionMemberChain`.
|
|
112
|
+
// `import.meta` parses only as a module, so it marks this one ESM. Staged
|
|
113
|
+
// before the bailing DefinePlugin and ImportMetaPlugin taps, so it observes
|
|
114
|
+
// every access without ending the chain.
|
|
116
115
|
const onImportMeta = () => {
|
|
117
116
|
enableHarmony(false);
|
|
118
117
|
};
|
|
@@ -112,10 +112,8 @@ module.exports = class HarmonyExportDependencyParserPlugin {
|
|
|
112
112
|
return true;
|
|
113
113
|
});
|
|
114
114
|
// `export default <namespace binding>` is the same export as
|
|
115
|
-
// `export { ns as default }`, so it
|
|
116
|
-
//
|
|
117
|
-
// otherwise wrap the identifier in a pure-expression guard whose insertions
|
|
118
|
-
// outlive the statement this removes.
|
|
115
|
+
// `export { ns as default }`, so it becomes the same re-export. Stage -10
|
|
116
|
+
// beats the inner-graph tap, whose guard would outlive the removed statement.
|
|
119
117
|
parser.hooks.statement.tap(
|
|
120
118
|
{ name: PLUGIN_NAME, stage: -10 },
|
|
121
119
|
(statement) => {
|
|
@@ -218,14 +216,19 @@ module.exports = class HarmonyExportDependencyParserPlugin {
|
|
|
218
216
|
: undefined,
|
|
219
217
|
constValue
|
|
220
218
|
);
|
|
219
|
+
const isAnonymousClass =
|
|
220
|
+
(node.type === "ClassDeclaration" || node.type === "ClassExpression") &&
|
|
221
|
+
!node.id;
|
|
221
222
|
dep.isAnonymousDefault =
|
|
222
223
|
this.options.anonymousDefaultExportName !== false &&
|
|
223
224
|
(node.type === "ArrowFunctionExpression" ||
|
|
225
|
+
isAnonymousClass ||
|
|
224
226
|
((node.type === "FunctionDeclaration" ||
|
|
225
|
-
node.type === "FunctionExpression"
|
|
226
|
-
node.type === "ClassDeclaration" ||
|
|
227
|
-
node.type === "ClassExpression") &&
|
|
227
|
+
node.type === "FunctionExpression") &&
|
|
228
228
|
!node.id));
|
|
229
|
+
// A class observes its own name from a static initializer, which runs
|
|
230
|
+
// before the name could be patched afterwards, so it is named in place.
|
|
231
|
+
dep.isAnonymousDefaultClass = dep.isAnonymousDefault && isAnonymousClass;
|
|
229
232
|
dep.setLocWithIndex(parser.getLocation(statement), -1);
|
|
230
233
|
parser.state.current.addDependency(dep);
|
|
231
234
|
getInnerGraphUtils(parser.state.compilation).addVariableUsage(
|