@depup/webpack 5.110.1-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/ChunkGraph.js +20 -18
- package/lib/CircularModulesPlugin.js +157 -55
- package/lib/CleanPlugin.js +2 -2
- package/lib/CompatibilityPlugin.js +3 -4
- package/lib/Compilation.js +337 -338
- package/lib/Compiler.js +213 -51
- package/lib/ConcatenationScope.js +25 -35
- 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 +64 -40
- package/lib/ErrorHelpers.js +113 -0
- package/lib/ExportsInfo.js +30 -16
- package/lib/ExternalModule.js +47 -22
- package/lib/FileSystemInfo.js +17 -14
- package/lib/FlagDependencyExportsPlugin.js +53 -34
- package/lib/FlagDependencyUsagePlugin.js +17 -15
- 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 +148 -70
- package/lib/NormalModuleFactory.js +1 -1
- package/lib/RuntimeGlobals.js +21 -7
- package/lib/RuntimeModule.js +28 -12
- package/lib/RuntimePlugin.js +33 -3
- package/lib/RuntimeTemplate.js +1147 -847
- 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/async-modules/AsyncModuleHelpers.js +10 -4
- 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 +162 -142
- package/lib/config/getClaimedAssetTypes.js +10 -11
- package/lib/config/normalization.js +100 -20
- 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 +92 -15
- package/lib/css/CssModule.js +1 -1
- package/lib/css/CssModulesPlugin.js +3 -10
- 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 +3526 -871
- package/lib/css/syntax.js +6455 -1237
- 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 +32 -9
- package/lib/dependencies/CommonJsSelfReferenceDependency.js +2 -4
- package/lib/dependencies/ContextDependency.js +1 -1
- package/lib/dependencies/ContextDependencyHelpers.js +3 -9
- package/lib/dependencies/ContextDependencyTemplateAsRequireCall.js +20 -7
- 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/HarmonyEvaluatedImportSpecifierDependency.js +10 -4
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +12 -7
- package/lib/dependencies/HarmonyExportExpressionDependency.js +47 -33
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +217 -34
- 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 +99 -41
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +198 -25
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +117 -4
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +40 -3
- package/lib/dependencies/HarmonyModulesPlugin.js +20 -0
- package/lib/dependencies/HtmlEntryDependency.js +136 -104
- package/lib/dependencies/HtmlInlineScriptDependency.js +3 -4
- package/lib/dependencies/HtmlInlineStyleDependency.js +3 -4
- package/lib/dependencies/ImportContextDependency.js +43 -3
- package/lib/dependencies/ImportDependency.js +8 -29
- 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 +25 -15
- package/lib/dependencies/LoaderPlugin.js +26 -1
- package/lib/dependencies/RequireContextDependencyParserPlugin.js +1 -1
- package/lib/dependencies/RequireHeaderDependency.js +20 -21
- 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 +16 -21
- package/lib/dependencies/WorkerDependency.js +12 -18
- package/lib/dependencies/WorkletDependency.js +12 -20
- package/lib/dependencies/importOptionsCheck.js +47 -0
- 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/DotenvFileError.js +29 -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/ImportedBindingAssignmentError.js +30 -0
- 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 +21 -5
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +91 -53
- 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 +479 -215
- 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 +2031 -1556
- 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 +76 -80
- 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 +170 -14
- package/lib/node/NodeWatchFileSystem.js +3 -9
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +22 -0
- package/lib/node/ReadFileCompileAsyncWasmPlugin.js +8 -15
- package/lib/node/RequireChunkLoadingRuntimeModule.js +22 -0
- package/lib/optimize/AggressiveMergingPlugin.js +3 -5
- package/lib/optimize/ConcatenatedModule.js +222 -125
- package/lib/optimize/ConstExportsPlugin.js +50 -34
- package/lib/optimize/FlagIncludedChunksPlugin.js +3 -11
- package/lib/optimize/InlineExports.js +20 -2
- 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 +179 -44
- 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 +29 -35
- 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 +103 -67
- 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 +313 -222
- 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/HttpUriPlugin.js +22 -5
- package/lib/schemes/VirtualUrlPlugin.js +1 -1
- package/lib/serialization/BinaryMiddleware.js +9 -9
- package/lib/serialization/FileMiddleware.js +31 -18
- 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 +10 -13
- package/lib/url/URLParserPlugin.js +6 -8
- package/lib/util/ArrayQueue.js +3 -3
- package/lib/util/LocConverter.js +4 -7
- package/lib/util/SourceProcessor.js +115 -99
- package/lib/util/URLAbsoluteSpecifier.js +3 -1
- 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/conventions.js +5 -1
- package/lib/util/createHooksRegistry.js +1 -2
- package/lib/util/createMappings.js +25 -3
- 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 +7 -1
- package/lib/util/registerExternalSerializer.js +6 -45
- package/lib/util/removeBOM.js +82 -1
- package/lib/util/semver.js +5 -3
- package/lib/wasm-async/AsyncWasmCompileRuntimeModule.js +14 -3
- package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +14 -3
- package/lib/wasm-async/AsyncWebAssemblyGenerator.js +6 -1
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +5 -1
- package/lib/wasm-async/UniversalCompileAsyncWasmPlugin.js +7 -12
- 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/FetchCompileAsyncWasmPlugin.js +10 -6
- package/lib/web/FetchCompileWasmPlugin.js +4 -2
- 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 +388 -76
- 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 +1795 -608
- 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
|
|
@@ -20,6 +20,7 @@ const HarmonyImportGuard = require("./HarmonyImportGuard");
|
|
|
20
20
|
const ModuleDependency = require("./ModuleDependency");
|
|
21
21
|
|
|
22
22
|
/** @import { ReplaceSource } from "webpack-sources" */
|
|
23
|
+
/** @import ConcatenationScope from "../ConcatenationScope" */
|
|
23
24
|
/**
|
|
24
25
|
* @import {
|
|
25
26
|
* GetConditionFn,
|
|
@@ -30,12 +31,13 @@ const ModuleDependency = require("./ModuleDependency");
|
|
|
30
31
|
/** @import { DependencyTemplateContext } from "../DependencyTemplate" */
|
|
31
32
|
/** @import Module from "../Module" */
|
|
32
33
|
/** @import ModuleGraph from "../ModuleGraph" */
|
|
34
|
+
/** @import ModuleGraphConnection from "../ModuleGraphConnection" */
|
|
33
35
|
/** @import { Range } from "../javascript/JavascriptParser" */
|
|
34
36
|
/** @import { UsedByExports } from "../optimize/InnerGraph" */
|
|
35
37
|
/** @import { RuntimeSpec } from "../util/runtime" */
|
|
36
38
|
/** @import { DependencyGuard } from "./HarmonyImportGuard" */
|
|
37
|
-
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext<[RawReferencedExports | null, Range | undefined, DependencyGuard[] | undefined, boolean, boolean, UsedByExports | undefined]>} ObjectDeserializerContext */
|
|
38
|
-
/** @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 */
|
|
39
41
|
|
|
40
42
|
/**
|
|
41
43
|
* Trims a member-access path at the first segment that is definitively not a
|
|
@@ -91,6 +93,10 @@ class CommonJsRequireDependency extends ModuleDependency {
|
|
|
91
93
|
// `new require(...)`; see the template for the return-value rule
|
|
92
94
|
/** @type {boolean} */
|
|
93
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;
|
|
94
100
|
}
|
|
95
101
|
|
|
96
102
|
get type() {
|
|
@@ -200,6 +206,19 @@ class CommonJsRequireDependency extends ModuleDependency {
|
|
|
200
206
|
return concatenateCommonJsModules && this._canConcatenate;
|
|
201
207
|
}
|
|
202
208
|
|
|
209
|
+
/**
|
|
210
|
+
* @param {ModuleGraphConnection} connection the active connection of this dependency
|
|
211
|
+
* @param {ConcatenationScope} concatenationScope the concatenation scope
|
|
212
|
+
* @returns {boolean} true when the call becomes a module reference
|
|
213
|
+
*/
|
|
214
|
+
rendersAsConcatenatedReference(connection, concatenationScope) {
|
|
215
|
+
return (
|
|
216
|
+
this._canConcatenate &&
|
|
217
|
+
this.valueRange !== undefined &&
|
|
218
|
+
concatenationScope.isModuleInScope(connection.module)
|
|
219
|
+
);
|
|
220
|
+
}
|
|
221
|
+
|
|
203
222
|
/**
|
|
204
223
|
* Serializes this instance into the provided serializer context.
|
|
205
224
|
* @param {ObjectSerializerContext} context context
|
|
@@ -211,7 +230,8 @@ class CommonJsRequireDependency extends ModuleDependency {
|
|
|
211
230
|
.write(this.branchGuards)
|
|
212
231
|
.write(this._canConcatenate)
|
|
213
232
|
.write(this.callNew)
|
|
214
|
-
.write(this.usedByExports)
|
|
233
|
+
.write(this.usedByExports)
|
|
234
|
+
.write(this.asiSafe);
|
|
215
235
|
super.serialize(context);
|
|
216
236
|
}
|
|
217
237
|
|
|
@@ -231,7 +251,9 @@ class CommonJsRequireDependency extends ModuleDependency {
|
|
|
231
251
|
this.callNew = c4.read();
|
|
232
252
|
const c5 = c4.rest;
|
|
233
253
|
this.usedByExports = c5.read();
|
|
234
|
-
|
|
254
|
+
const c6 = c5.rest;
|
|
255
|
+
this.asiSafe = c6.read();
|
|
256
|
+
super.deserialize(c6.rest);
|
|
235
257
|
}
|
|
236
258
|
}
|
|
237
259
|
|
|
@@ -278,9 +300,9 @@ CommonJsRequireDependency.Template = class CommonJsRequireDependencyTemplate ext
|
|
|
278
300
|
if (
|
|
279
301
|
connection &&
|
|
280
302
|
concatenationScope !== undefined &&
|
|
281
|
-
dep.
|
|
282
|
-
concatenationScope.isModuleInScope(connection.module)
|
|
303
|
+
dep.rendersAsConcatenatedReference(connection, concatenationScope)
|
|
283
304
|
) {
|
|
305
|
+
const valueRange = /** @type {Range} */ (dep.valueRange);
|
|
284
306
|
let content = concatenationScope.createModuleReference(
|
|
285
307
|
connection.module,
|
|
286
308
|
{
|
|
@@ -288,7 +310,9 @@ CommonJsRequireDependency.Template = class CommonJsRequireDependencyTemplate ext
|
|
|
288
310
|
ids: isRequireEsmModuleExportsModule(connection.module, moduleGraph)
|
|
289
311
|
? [ESM_MODULE_EXPORTS_NAME]
|
|
290
312
|
: undefined,
|
|
291
|
-
|
|
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,
|
|
292
316
|
moduleExportsAccess: true
|
|
293
317
|
}
|
|
294
318
|
);
|
|
@@ -300,8 +324,7 @@ CommonJsRequireDependency.Template = class CommonJsRequireDependencyTemplate ext
|
|
|
300
324
|
);
|
|
301
325
|
content = `${RuntimeGlobals.constructRequire}(${content})`;
|
|
302
326
|
}
|
|
303
|
-
source.replace(
|
|
304
|
-
concatenationScope.registerReplacedRequire(dep.valueRange);
|
|
327
|
+
source.replace(valueRange[0], valueRange[1] - 1, content);
|
|
305
328
|
return;
|
|
306
329
|
}
|
|
307
330
|
const importedModule = /** @type {Module} */ (moduleGraph.getModule(dep));
|
|
@@ -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
|
);
|
|
@@ -22,11 +22,9 @@ class ContextDependencyTemplateAsRequireCall
|
|
|
22
22
|
* @param {DependencyTemplateContext} templateContext the context object
|
|
23
23
|
* @returns {void}
|
|
24
24
|
*/
|
|
25
|
-
apply(
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
{ runtimeTemplate, moduleGraph, chunkGraph, runtimeRequirements }
|
|
29
|
-
) {
|
|
25
|
+
apply(dependency, source, templateContext) {
|
|
26
|
+
const { runtimeTemplate, moduleGraph, chunkGraph, runtimeRequirements } =
|
|
27
|
+
templateContext;
|
|
30
28
|
const dep = /** @type {ContextDependency} */ (dependency);
|
|
31
29
|
let moduleExports = runtimeTemplate.moduleExports({
|
|
32
30
|
module: moduleGraph.getModule(dep),
|
|
@@ -49,8 +47,7 @@ class ContextDependencyTemplateAsRequireCall
|
|
|
49
47
|
source.replace(rep.range[0], rep.range[1] - 1, rep.value);
|
|
50
48
|
}
|
|
51
49
|
}
|
|
52
|
-
|
|
53
|
-
source.replace(range[0], dep.valueRange[0] - 1, `${moduleExports}(`);
|
|
50
|
+
this.replaceCall(dep, source, moduleExports, templateContext);
|
|
54
51
|
} else {
|
|
55
52
|
source.replace(range[0], range[1] - 1, moduleExports);
|
|
56
53
|
}
|
|
@@ -58,6 +55,22 @@ class ContextDependencyTemplateAsRequireCall
|
|
|
58
55
|
source.replace(range[0], range[1] - 1, moduleExports);
|
|
59
56
|
}
|
|
60
57
|
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Rewrites the call around its request, dropping anything the original one
|
|
61
|
+
* carried after it. Overridden where a later argument must be kept.
|
|
62
|
+
* @param {ContextDependency} dep the dependency
|
|
63
|
+
* @param {ReplaceSource} source the current replace source which can be modified
|
|
64
|
+
* @param {string} moduleExports the expression the request is passed to
|
|
65
|
+
* @param {DependencyTemplateContext} templateContext the context object
|
|
66
|
+
* @returns {void}
|
|
67
|
+
*/
|
|
68
|
+
replaceCall(dep, source, moduleExports, templateContext) {
|
|
69
|
+
const range = /** @type {Range} */ (dep.range);
|
|
70
|
+
const valueRange = /** @type {Range} */ (dep.valueRange);
|
|
71
|
+
source.replace(valueRange[1], range[1] - 1, ")");
|
|
72
|
+
source.replace(range[0], valueRange[0] - 1, `${moduleExports}(`);
|
|
73
|
+
}
|
|
61
74
|
}
|
|
62
75
|
|
|
63
76
|
module.exports = ContextDependencyTemplateAsRequireCall;
|
|
@@ -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;
|