webpack 5.90.3 → 5.92.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.
Potentially problematic release.
This version of webpack might be problematic. Click here for more details.
- package/README.md +5 -5
- package/bin/webpack.js +6 -3
- package/lib/APIPlugin.js +14 -6
- package/lib/AutomaticPrefetchPlugin.js +1 -1
- package/lib/BannerPlugin.js +3 -1
- package/lib/Cache.js +8 -2
- package/lib/CacheFacade.js +3 -3
- package/lib/Chunk.js +7 -4
- package/lib/ChunkGraph.js +52 -25
- package/lib/ChunkGroup.js +23 -17
- package/lib/CleanPlugin.js +8 -6
- package/lib/Compilation.js +295 -120
- package/lib/Compiler.js +223 -87
- package/lib/ConcatenationScope.js +3 -3
- package/lib/ConditionalInitFragment.js +4 -5
- package/lib/ContextModule.js +95 -41
- package/lib/ContextModuleFactory.js +4 -2
- package/lib/ContextReplacementPlugin.js +3 -2
- package/lib/DefinePlugin.js +18 -6
- package/lib/Dependency.js +12 -10
- package/lib/DependencyTemplate.js +17 -7
- package/lib/DllModule.js +1 -0
- package/lib/DllReferencePlugin.js +7 -3
- package/lib/EntryOptionPlugin.js +4 -1
- package/lib/EntryPlugin.js +6 -1
- package/lib/Entrypoint.js +1 -1
- package/lib/EvalDevToolModulePlugin.js +11 -0
- package/lib/ExportsInfo.js +23 -8
- package/lib/ExternalModule.js +160 -35
- package/lib/ExternalModuleFactoryPlugin.js +37 -2
- package/lib/FileSystemInfo.js +69 -42
- package/lib/FlagDependencyExportsPlugin.js +21 -7
- package/lib/Generator.js +4 -4
- package/lib/HookWebpackError.js +2 -2
- package/lib/HotModuleReplacementPlugin.js +108 -45
- package/lib/IgnorePlugin.js +4 -1
- package/lib/InitFragment.js +5 -3
- package/lib/LibManifestPlugin.js +17 -9
- package/lib/Module.js +41 -14
- package/lib/ModuleFactory.js +3 -3
- package/lib/ModuleFilenameHelpers.js +30 -17
- package/lib/ModuleGraph.js +60 -31
- package/lib/ModuleGraphConnection.js +2 -1
- package/lib/MultiCompiler.js +62 -9
- package/lib/NodeStuffPlugin.js +14 -3
- package/lib/NormalModule.js +13 -13
- package/lib/NormalModuleFactory.js +18 -9
- package/lib/NormalModuleReplacementPlugin.js +5 -1
- package/lib/Parser.js +1 -1
- package/lib/PlatformPlugin.js +39 -0
- package/lib/ProgressPlugin.js +1 -1
- package/lib/ProvidePlugin.js +3 -1
- package/lib/RawModule.js +2 -1
- package/lib/RecordIdsPlugin.js +4 -4
- package/lib/ResolverFactory.js +6 -4
- package/lib/RuntimeModule.js +4 -4
- package/lib/RuntimePlugin.js +1 -0
- package/lib/RuntimeTemplate.js +124 -52
- package/lib/SourceMapDevToolPlugin.js +4 -1
- package/lib/Stats.js +11 -4
- package/lib/Template.js +5 -5
- package/lib/TemplatedPathPlugin.js +48 -7
- package/lib/Watching.js +67 -60
- package/lib/WebpackError.js +6 -6
- package/lib/WebpackOptionsApply.js +18 -5
- package/lib/asset/AssetGenerator.js +15 -0
- package/lib/asset/RawDataUrlModule.js +3 -1
- package/lib/async-modules/AwaitDependenciesInitFragment.js +2 -2
- package/lib/buildChunkGraph.js +120 -67
- package/lib/cache/IdleFileCachePlugin.js +8 -3
- package/lib/cache/MemoryCachePlugin.js +1 -1
- package/lib/cache/MemoryWithGcCachePlugin.js +6 -2
- package/lib/cache/PackFileCacheStrategy.js +51 -18
- package/lib/cache/ResolverCachePlugin.js +22 -14
- package/lib/cache/getLazyHashedEtag.js +2 -2
- package/lib/cli.js +5 -5
- package/lib/config/browserslistTargetHandler.js +7 -1
- package/lib/config/defaults.js +108 -34
- package/lib/config/normalization.js +3 -1
- package/lib/config/target.js +18 -11
- package/lib/container/ContainerEntryDependency.js +2 -1
- package/lib/container/ContainerEntryModule.js +4 -2
- package/lib/container/ContainerPlugin.js +14 -10
- package/lib/container/FallbackModule.js +1 -1
- package/lib/container/RemoteRuntimeModule.js +12 -3
- package/lib/css/CssExportsGenerator.js +68 -25
- package/lib/css/CssGenerator.js +34 -6
- package/lib/css/CssLoadingRuntimeModule.js +217 -98
- package/lib/css/CssModulesPlugin.js +238 -107
- package/lib/css/CssParser.js +24 -15
- package/lib/css/walkCssTokens.js +1 -1
- package/lib/debug/ProfilingPlugin.js +28 -3
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +9 -5
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +4 -1
- package/lib/dependencies/CommonJsDependencyHelpers.js +2 -1
- package/lib/dependencies/CommonJsExportRequireDependency.js +33 -18
- package/lib/dependencies/CommonJsExportsDependency.js +13 -5
- package/lib/dependencies/CommonJsExportsParserPlugin.js +20 -15
- package/lib/dependencies/CommonJsImportsParserPlugin.js +1 -2
- package/lib/dependencies/ContextDependencyHelpers.js +49 -29
- package/lib/dependencies/ContextElementDependency.js +8 -1
- package/lib/dependencies/CssExportDependency.js +2 -2
- package/lib/dependencies/CssLocalIdentifierDependency.js +71 -9
- package/lib/dependencies/CssUrlDependency.js +10 -7
- package/lib/dependencies/ExportsInfoDependency.js +5 -4
- package/lib/dependencies/ExternalModuleDependency.js +4 -2
- package/lib/dependencies/ExternalModuleInitFragment.js +5 -3
- package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +4 -4
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +43 -23
- package/lib/dependencies/HarmonyExportHeaderDependency.js +1 -1
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +73 -32
- package/lib/dependencies/HarmonyExportInitFragment.js +10 -2
- package/lib/dependencies/HarmonyImportDependency.js +28 -12
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +70 -19
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +7 -6
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +47 -35
- package/lib/dependencies/ImportDependency.js +9 -2
- package/lib/dependencies/ImportEagerDependency.js +4 -2
- package/lib/dependencies/ImportMetaContextDependency.js +7 -0
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +25 -14
- package/lib/dependencies/ImportMetaPlugin.js +1 -1
- package/lib/dependencies/ImportParserPlugin.js +15 -5
- package/lib/dependencies/ImportWeakDependency.js +4 -2
- package/lib/dependencies/LoaderDependency.js +2 -1
- package/lib/dependencies/LoaderImportDependency.js +2 -1
- package/lib/dependencies/LoaderPlugin.js +2 -2
- package/lib/dependencies/ModuleDependency.js +4 -5
- package/lib/dependencies/PureExpressionDependency.js +64 -47
- package/lib/dependencies/RequireContextPlugin.js +1 -1
- package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +26 -14
- package/lib/dependencies/RequireEnsureDependency.js +1 -1
- package/lib/dependencies/URLDependency.js +7 -4
- package/lib/dependencies/WorkerDependency.js +1 -1
- package/lib/dependencies/WorkerPlugin.js +2 -1
- package/lib/dependencies/getFunctionExpression.js +3 -1
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +92 -3
- package/lib/hmr/LazyCompilationPlugin.js +2 -2
- package/lib/ids/ChunkModuleIdRangePlugin.js +1 -1
- package/lib/ids/DeterministicChunkIdsPlugin.js +1 -1
- package/lib/ids/DeterministicModuleIdsPlugin.js +1 -1
- package/lib/ids/IdHelpers.js +6 -6
- package/lib/ids/NamedChunkIdsPlugin.js +1 -1
- package/lib/ids/NamedModuleIdsPlugin.js +1 -1
- package/lib/ids/SyncModuleIdsPlugin.js +2 -2
- package/lib/index.js +11 -0
- package/lib/javascript/BasicEvaluatedExpression.js +2 -2
- package/lib/javascript/ChunkHelpers.js +2 -2
- package/lib/javascript/CommonJsChunkFormatPlugin.js +1 -1
- package/lib/javascript/JavascriptGenerator.js +0 -1
- package/lib/javascript/JavascriptModulesPlugin.js +174 -17
- package/lib/javascript/JavascriptParser.js +204 -71
- package/lib/javascript/JavascriptParserHelpers.js +1 -1
- package/lib/javascript/StartupHelpers.js +22 -5
- package/lib/library/AbstractLibraryPlugin.js +2 -2
- package/lib/library/AmdLibraryPlugin.js +2 -2
- package/lib/library/AssignLibraryPlugin.js +3 -3
- package/lib/library/ExportPropertyLibraryPlugin.js +2 -2
- package/lib/library/JsonpLibraryPlugin.js +2 -2
- package/lib/library/ModuleLibraryPlugin.js +2 -2
- package/lib/library/SystemLibraryPlugin.js +2 -2
- package/lib/library/UmdLibraryPlugin.js +33 -12
- package/lib/logging/Logger.js +27 -2
- package/lib/logging/createConsoleLogger.js +13 -9
- package/lib/node/CommonJsChunkLoadingPlugin.js +2 -1
- package/lib/node/NodeEnvironmentPlugin.js +14 -8
- package/lib/node/NodeTemplatePlugin.js +1 -1
- package/lib/node/NodeWatchFileSystem.js +37 -26
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +2 -1
- package/lib/node/ReadFileCompileWasmPlugin.js +1 -1
- package/lib/node/RequireChunkLoadingRuntimeModule.js +2 -1
- package/lib/node/nodeConsole.js +24 -1
- package/lib/optimize/AggressiveMergingPlugin.js +1 -1
- package/lib/optimize/AggressiveSplittingPlugin.js +1 -0
- package/lib/optimize/ConcatenatedModule.js +140 -121
- package/lib/optimize/EnsureChunkConditionsPlugin.js +1 -1
- package/lib/optimize/InnerGraph.js +8 -3
- package/lib/optimize/InnerGraphPlugin.js +36 -13
- package/lib/optimize/LimitChunkCountPlugin.js +1 -2
- package/lib/optimize/ModuleConcatenationPlugin.js +13 -3
- package/lib/optimize/RealContentHashPlugin.js +3 -3
- package/lib/optimize/RemoveParentModulesPlugin.js +1 -0
- package/lib/optimize/RuntimeChunkPlugin.js +6 -1
- package/lib/optimize/SideEffectsFlagPlugin.js +48 -17
- package/lib/optimize/SplitChunksPlugin.js +10 -10
- package/lib/performance/SizeLimitsPlugin.js +13 -2
- package/lib/rules/ObjectMatcherRulePlugin.js +15 -1
- package/lib/rules/RuleSetCompiler.js +9 -7
- package/lib/runtime/EnsureChunkRuntimeModule.js +2 -1
- package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +2 -1
- package/lib/runtime/LoadScriptRuntimeModule.js +1 -1
- package/lib/runtime/StartupChunkDependenciesPlugin.js +1 -1
- package/lib/schemes/HttpUriPlugin.js +1 -1
- package/lib/serialization/BinaryMiddleware.js +4 -4
- package/lib/serialization/FileMiddleware.js +4 -3
- package/lib/serialization/NullPrototypeObjectSerializer.js +2 -2
- package/lib/serialization/ObjectMiddleware.js +8 -5
- package/lib/serialization/PlainObjectSerializer.js +2 -2
- package/lib/serialization/Serializer.js +19 -0
- package/lib/serialization/SerializerMiddleware.js +2 -2
- package/lib/serialization/SingleItemMiddleware.js +2 -2
- package/lib/serialization/types.js +1 -1
- package/lib/sharing/ConsumeSharedModule.js +2 -2
- package/lib/sharing/ConsumeSharedPlugin.js +17 -3
- package/lib/sharing/ConsumeSharedRuntimeModule.js +9 -2
- package/lib/sharing/ProvideSharedPlugin.js +13 -6
- package/lib/sharing/resolveMatchedConfigs.js +3 -3
- package/lib/sharing/utils.js +13 -6
- package/lib/stats/DefaultStatsFactoryPlugin.js +20 -20
- package/lib/stats/DefaultStatsPrinterPlugin.js +1 -1
- package/lib/stats/StatsFactory.js +2 -2
- package/lib/stats/StatsPrinter.js +6 -6
- package/lib/util/ArrayQueue.js +14 -21
- package/lib/util/AsyncQueue.js +1 -1
- package/lib/util/Queue.js +8 -2
- package/lib/util/SortableSet.js +16 -4
- package/lib/util/StackedCacheMap.js +26 -0
- package/lib/util/TupleQueue.js +8 -2
- package/lib/util/WeakTupleMap.js +57 -13
- package/lib/util/binarySearchBounds.js +1 -1
- package/lib/util/cleverMerge.js +26 -13
- package/lib/util/comparators.js +37 -15
- package/lib/util/conventions.js +129 -0
- package/lib/util/createHash.js +3 -5
- package/lib/util/deprecation.js +3 -3
- package/lib/util/deterministicGrouping.js +2 -2
- package/lib/util/findGraphRoots.js +1 -1
- package/lib/util/fs.js +383 -69
- package/lib/util/hash/BatchedHash.js +3 -0
- package/lib/util/hash/xxhash64.js +2 -2
- package/lib/util/identifier.js +5 -5
- package/lib/util/mergeScope.js +79 -0
- package/lib/util/runtime.js +2 -17
- package/lib/util/semver.js +3 -0
- package/lib/util/smartGrouping.js +3 -3
- package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +4 -2
- package/lib/wasm-async/AsyncWebAssemblyGenerator.js +1 -1
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +4 -2
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +3 -3
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +16 -7
- package/lib/wasm-sync/WebAssemblyGenerator.js +40 -19
- package/lib/wasm-sync/WebAssemblyModulesPlugin.js +1 -1
- package/lib/wasm-sync/WebAssemblyParser.js +7 -4
- package/lib/wasm-sync/WebAssemblyUtils.js +2 -1
- package/lib/web/FetchCompileWasmPlugin.js +1 -1
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +3 -2
- package/lib/webpack.js +19 -6
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +2 -1
- package/package.json +40 -39
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +97 -8
- package/schemas/plugins/BannerPlugin.check.js +1 -1
- package/schemas/plugins/BannerPlugin.json +5 -1
- package/schemas/plugins/css/CssAutoGeneratorOptions.check.js +1 -1
- package/schemas/plugins/css/CssGeneratorOptions.check.js +1 -1
- package/schemas/plugins/css/CssGlobalGeneratorOptions.check.js +1 -1
- package/schemas/plugins/css/CssModuleGeneratorOptions.check.js +1 -1
- package/types.d.ts +1826 -639
@@ -26,6 +26,7 @@ const { concatComparators } = require("../util/comparators");
|
|
26
26
|
const createHash = require("../util/createHash");
|
27
27
|
const { makePathsRelative } = require("../util/identifier");
|
28
28
|
const makeSerializable = require("../util/makeSerializable");
|
29
|
+
const { getAllReferences, getPathInAst } = require("../util/mergeScope");
|
29
30
|
const propertyAccess = require("../util/propertyAccess");
|
30
31
|
const { propertyName } = require("../util/propertyName");
|
31
32
|
const {
|
@@ -37,7 +38,9 @@ const {
|
|
37
38
|
subtractRuntimeCondition
|
38
39
|
} = require("../util/runtime");
|
39
40
|
|
41
|
+
/** @typedef {import("eslint-scope").Reference} Reference */
|
40
42
|
/** @typedef {import("eslint-scope").Scope} Scope */
|
43
|
+
/** @typedef {import("eslint-scope").Variable} Variable */
|
41
44
|
/** @typedef {import("webpack-sources").Source} Source */
|
42
45
|
/** @typedef {import("../../declarations/WebpackOptions").WebpackOptionsNormalized} WebpackOptions */
|
43
46
|
/** @typedef {import("../ChunkGraph")} ChunkGraph */
|
@@ -48,10 +51,12 @@ const {
|
|
48
51
|
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
|
49
52
|
/** @typedef {import("../DependencyTemplates")} DependencyTemplates */
|
50
53
|
/** @typedef {import("../ExportsInfo").ExportInfo} ExportInfo */
|
51
|
-
/** @
|
54
|
+
/** @typedef {import("../Module").BuildInfo} BuildInfo */
|
55
|
+
/** @typedef {import("../Module").BuildMeta} BuildMeta */
|
52
56
|
/** @typedef {import("../Module").CodeGenerationContext} CodeGenerationContext */
|
53
57
|
/** @typedef {import("../Module").CodeGenerationResult} CodeGenerationResult */
|
54
58
|
/** @typedef {import("../Module").LibIdentOptions} LibIdentOptions */
|
59
|
+
/** @typedef {import("../Module").ReadOnlyRuntimeRequirements} ReadOnlyRuntimeRequirements */
|
55
60
|
/** @typedef {import("../Module").SourceTypes} SourceTypes */
|
56
61
|
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
57
62
|
/** @typedef {import("../ModuleGraphConnection")} ModuleGraphConnection */
|
@@ -61,21 +66,34 @@ const {
|
|
61
66
|
/** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
|
62
67
|
/** @typedef {import("../WebpackError")} WebpackError */
|
63
68
|
/** @typedef {import("../javascript/JavascriptModulesPlugin").ChunkRenderContext} ChunkRenderContext */
|
69
|
+
/** @typedef {import("../javascript/JavascriptParser").Program} Program */
|
70
|
+
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
71
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
64
72
|
/** @typedef {import("../util/Hash")} Hash */
|
65
73
|
/** @typedef {typeof import("../util/Hash")} HashConstructor */
|
66
74
|
/** @typedef {import("../util/fs").InputFileSystem} InputFileSystem */
|
67
75
|
/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
|
68
76
|
|
77
|
+
/**
|
78
|
+
* @template T
|
79
|
+
* @typedef {import("../InitFragment")<T>} InitFragment
|
80
|
+
*/
|
81
|
+
|
82
|
+
/**
|
83
|
+
* @template T
|
84
|
+
* @typedef {import("../util/comparators").Comparator<T>} Comparator
|
85
|
+
*/
|
86
|
+
|
69
87
|
// fix eslint-scope to support class properties correctly
|
70
88
|
// cspell:word Referencer
|
71
|
-
const ReferencerClass = Referencer;
|
89
|
+
const ReferencerClass = /** @type {any} */ (Referencer);
|
72
90
|
if (!ReferencerClass.prototype.PropertyDefinition) {
|
73
91
|
ReferencerClass.prototype.PropertyDefinition =
|
74
92
|
ReferencerClass.prototype.Property;
|
75
93
|
}
|
76
94
|
|
77
95
|
/**
|
78
|
-
* @typedef {
|
96
|
+
* @typedef {object} ReexportInfo
|
79
97
|
* @property {Module} module
|
80
98
|
* @property {string[]} export
|
81
99
|
*/
|
@@ -83,7 +101,7 @@ if (!ReferencerClass.prototype.PropertyDefinition) {
|
|
83
101
|
/** @typedef {RawBinding | SymbolBinding} Binding */
|
84
102
|
|
85
103
|
/**
|
86
|
-
* @typedef {
|
104
|
+
* @typedef {object} RawBinding
|
87
105
|
* @property {ModuleInfo} info
|
88
106
|
* @property {string} rawName
|
89
107
|
* @property {string=} comment
|
@@ -92,7 +110,7 @@ if (!ReferencerClass.prototype.PropertyDefinition) {
|
|
92
110
|
*/
|
93
111
|
|
94
112
|
/**
|
95
|
-
* @typedef {
|
113
|
+
* @typedef {object} SymbolBinding
|
96
114
|
* @property {ConcatenatedModuleInfo} info
|
97
115
|
* @property {string} name
|
98
116
|
* @property {string=} comment
|
@@ -104,32 +122,32 @@ if (!ReferencerClass.prototype.PropertyDefinition) {
|
|
104
122
|
/** @typedef {ConcatenatedModuleInfo | ExternalModuleInfo | ReferenceToModuleInfo } ModuleInfoOrReference */
|
105
123
|
|
106
124
|
/**
|
107
|
-
* @typedef {
|
125
|
+
* @typedef {object} ConcatenatedModuleInfo
|
108
126
|
* @property {"concatenated"} type
|
109
127
|
* @property {Module} module
|
110
128
|
* @property {number} index
|
111
|
-
* @property {
|
129
|
+
* @property {Program | undefined} ast
|
112
130
|
* @property {Source} internalSource
|
113
131
|
* @property {ReplaceSource} source
|
114
132
|
* @property {InitFragment<ChunkRenderContext>[]=} chunkInitFragments
|
115
|
-
* @property {
|
133
|
+
* @property {ReadOnlyRuntimeRequirements} runtimeRequirements
|
116
134
|
* @property {Scope} globalScope
|
117
135
|
* @property {Scope} moduleScope
|
118
136
|
* @property {Map<string, string>} internalNames
|
119
|
-
* @property {Map<string, string>} exportMap
|
120
|
-
* @property {Map<string, string>} rawExportMap
|
137
|
+
* @property {Map<string, string> | undefined} exportMap
|
138
|
+
* @property {Map<string, string> | undefined} rawExportMap
|
121
139
|
* @property {string=} namespaceExportSymbol
|
122
|
-
* @property {string} namespaceObjectName
|
140
|
+
* @property {string | undefined} namespaceObjectName
|
123
141
|
* @property {boolean} interopNamespaceObjectUsed
|
124
|
-
* @property {string} interopNamespaceObjectName
|
142
|
+
* @property {string | undefined} interopNamespaceObjectName
|
125
143
|
* @property {boolean} interopNamespaceObject2Used
|
126
|
-
* @property {string} interopNamespaceObject2Name
|
144
|
+
* @property {string | undefined} interopNamespaceObject2Name
|
127
145
|
* @property {boolean} interopDefaultAccessUsed
|
128
|
-
* @property {string} interopDefaultAccessName
|
146
|
+
* @property {string | undefined} interopDefaultAccessName
|
129
147
|
*/
|
130
148
|
|
131
149
|
/**
|
132
|
-
* @typedef {
|
150
|
+
* @typedef {object} ExternalModuleInfo
|
133
151
|
* @property {"external"} type
|
134
152
|
* @property {Module} module
|
135
153
|
* @property {RuntimeSpec | boolean} runtimeCondition
|
@@ -144,12 +162,14 @@ if (!ReferencerClass.prototype.PropertyDefinition) {
|
|
144
162
|
*/
|
145
163
|
|
146
164
|
/**
|
147
|
-
* @typedef {
|
165
|
+
* @typedef {object} ReferenceToModuleInfo
|
148
166
|
* @property {"reference"} type
|
149
167
|
* @property {RuntimeSpec | boolean} runtimeCondition
|
150
168
|
* @property {ConcatenatedModuleInfo | ExternalModuleInfo} target
|
151
169
|
*/
|
152
170
|
|
171
|
+
/** @typedef {Set<string>} UsedNames */
|
172
|
+
|
153
173
|
const RESERVED_NAMES = new Set(
|
154
174
|
[
|
155
175
|
// internal names (should always be renamed)
|
@@ -190,6 +210,12 @@ const RESERVED_NAMES = new Set(
|
|
190
210
|
|
191
211
|
const createComparator = (property, comparator) => (a, b) =>
|
192
212
|
comparator(a[property], b[property]);
|
213
|
+
|
214
|
+
/**
|
215
|
+
* @param {number} a a
|
216
|
+
* @param {number} b b
|
217
|
+
* @returns {0 | 1 | -1} result
|
218
|
+
*/
|
193
219
|
const compareNumbers = (a, b) => {
|
194
220
|
if (isNaN(a)) {
|
195
221
|
if (!isNaN(b)) {
|
@@ -208,6 +234,10 @@ const compareNumbers = (a, b) => {
|
|
208
234
|
const bySourceOrder = createComparator("sourceOrder", compareNumbers);
|
209
235
|
const byRangeStart = createComparator("rangeStart", compareNumbers);
|
210
236
|
|
237
|
+
/**
|
238
|
+
* @param {Iterable<string>} iterable iterable object
|
239
|
+
* @returns {string} joined iterable object
|
240
|
+
*/
|
211
241
|
const joinIterableWithComma = iterable => {
|
212
242
|
// This is more performant than Array.from().join(", ")
|
213
243
|
// as it doesn't create an array
|
@@ -225,7 +255,7 @@ const joinIterableWithComma = iterable => {
|
|
225
255
|
};
|
226
256
|
|
227
257
|
/**
|
228
|
-
* @typedef {
|
258
|
+
* @typedef {object} ConcatenationEntry
|
229
259
|
* @property {"concatenated" | "external"} type
|
230
260
|
* @property {Module} module
|
231
261
|
* @property {RuntimeSpec | boolean} runtimeCondition
|
@@ -241,7 +271,7 @@ const joinIterableWithComma = iterable => {
|
|
241
271
|
* @param {RuntimeTemplate} runtimeTemplate the runtime template
|
242
272
|
* @param {Set<ConcatenatedModuleInfo>} neededNamespaceObjects modules for which a namespace object should be generated
|
243
273
|
* @param {boolean} asCall asCall
|
244
|
-
* @param {boolean} strictHarmonyModule strictHarmonyModule
|
274
|
+
* @param {boolean | undefined} strictHarmonyModule strictHarmonyModule
|
245
275
|
* @param {boolean | undefined} asiSafe asiSafe
|
246
276
|
* @param {Set<ExportInfo>} alreadyVisited alreadyVisited
|
247
277
|
* @returns {Binding} the final variable
|
@@ -270,7 +300,7 @@ const getFinalBinding = (
|
|
270
300
|
info.interopNamespaceObject2Used = true;
|
271
301
|
return {
|
272
302
|
info,
|
273
|
-
rawName: info.interopNamespaceObject2Name,
|
303
|
+
rawName: /** @type {string} */ (info.interopNamespaceObject2Name),
|
274
304
|
ids: exportName,
|
275
305
|
exportName
|
276
306
|
};
|
@@ -278,7 +308,7 @@ const getFinalBinding = (
|
|
278
308
|
info.interopNamespaceObjectUsed = true;
|
279
309
|
return {
|
280
310
|
info,
|
281
|
-
rawName: info.interopNamespaceObjectName,
|
311
|
+
rawName: /** @type {string} */ (info.interopNamespaceObjectName),
|
282
312
|
ids: exportName,
|
283
313
|
exportName
|
284
314
|
};
|
@@ -366,7 +396,7 @@ const getFinalBinding = (
|
|
366
396
|
neededNamespaceObjects.add(info);
|
367
397
|
return {
|
368
398
|
info,
|
369
|
-
rawName: info.namespaceObjectName,
|
399
|
+
rawName: /** @type {string} */ (info.namespaceObjectName),
|
370
400
|
ids: exportName,
|
371
401
|
exportName
|
372
402
|
};
|
@@ -393,7 +423,7 @@ const getFinalBinding = (
|
|
393
423
|
neededNamespaceObjects.add(info);
|
394
424
|
return {
|
395
425
|
info,
|
396
|
-
rawName: info.namespaceObjectName,
|
426
|
+
rawName: /** @type {string} */ (info.namespaceObjectName),
|
397
427
|
ids: exportName,
|
398
428
|
exportName
|
399
429
|
};
|
@@ -445,7 +475,7 @@ const getFinalBinding = (
|
|
445
475
|
const refInfo = moduleToInfoMap.get(reexport.module);
|
446
476
|
return getFinalBinding(
|
447
477
|
moduleGraph,
|
448
|
-
refInfo,
|
478
|
+
/** @type {ModuleInfo} */ (refInfo),
|
449
479
|
reexport.export
|
450
480
|
? [...reexport.export, ...exportName.slice(1)]
|
451
481
|
: exportName.slice(1),
|
@@ -455,7 +485,8 @@ const getFinalBinding = (
|
|
455
485
|
runtimeTemplate,
|
456
486
|
neededNamespaceObjects,
|
457
487
|
asCall,
|
458
|
-
|
488
|
+
/** @type {BuildMeta} */
|
489
|
+
(info.module.buildMeta).strictHarmonyModule,
|
459
490
|
asiSafe,
|
460
491
|
alreadyVisited
|
461
492
|
);
|
@@ -466,7 +497,7 @@ const getFinalBinding = (
|
|
466
497
|
);
|
467
498
|
return {
|
468
499
|
info,
|
469
|
-
rawName: info.namespaceObjectName,
|
500
|
+
rawName: /** @type {string} */ (info.namespaceObjectName),
|
470
501
|
ids: usedName,
|
471
502
|
exportName
|
472
503
|
};
|
@@ -508,8 +539,8 @@ const getFinalBinding = (
|
|
508
539
|
* @param {RuntimeTemplate} runtimeTemplate the runtime template
|
509
540
|
* @param {Set<ConcatenatedModuleInfo>} neededNamespaceObjects modules for which a namespace object should be generated
|
510
541
|
* @param {boolean} asCall asCall
|
511
|
-
* @param {boolean} callContext callContext
|
512
|
-
* @param {boolean} strictHarmonyModule strictHarmonyModule
|
542
|
+
* @param {boolean | undefined} callContext callContext
|
543
|
+
* @param {boolean | undefined} strictHarmonyModule strictHarmonyModule
|
513
544
|
* @param {boolean | undefined} asiSafe asiSafe
|
514
545
|
* @returns {string} the final name
|
515
546
|
*/
|
@@ -576,6 +607,12 @@ const getFinalName = (
|
|
576
607
|
}
|
577
608
|
};
|
578
609
|
|
610
|
+
/**
|
611
|
+
* @param {Scope | null} s scope
|
612
|
+
* @param {UsedNames} nameSet name set
|
613
|
+
* @param {TODO} scopeSet1 scope set 1
|
614
|
+
* @param {TODO} scopeSet2 scope set 2
|
615
|
+
*/
|
579
616
|
const addScopeSymbols = (s, nameSet, scopeSet1, scopeSet2) => {
|
580
617
|
let scope = s;
|
581
618
|
while (scope) {
|
@@ -589,63 +626,6 @@ const addScopeSymbols = (s, nameSet, scopeSet1, scopeSet2) => {
|
|
589
626
|
}
|
590
627
|
};
|
591
628
|
|
592
|
-
const getAllReferences = variable => {
|
593
|
-
let set = variable.references;
|
594
|
-
// Look for inner scope variables too (like in class Foo { t() { Foo } })
|
595
|
-
const identifiers = new Set(variable.identifiers);
|
596
|
-
for (const scope of variable.scope.childScopes) {
|
597
|
-
for (const innerVar of scope.variables) {
|
598
|
-
if (innerVar.identifiers.some(id => identifiers.has(id))) {
|
599
|
-
set = set.concat(innerVar.references);
|
600
|
-
break;
|
601
|
-
}
|
602
|
-
}
|
603
|
-
}
|
604
|
-
return set;
|
605
|
-
};
|
606
|
-
|
607
|
-
const getPathInAst = (ast, node) => {
|
608
|
-
if (ast === node) {
|
609
|
-
return [];
|
610
|
-
}
|
611
|
-
|
612
|
-
const nr = node.range;
|
613
|
-
|
614
|
-
const enterNode = n => {
|
615
|
-
if (!n) return undefined;
|
616
|
-
const r = n.range;
|
617
|
-
if (r) {
|
618
|
-
if (r[0] <= nr[0] && r[1] >= nr[1]) {
|
619
|
-
const path = getPathInAst(n, node);
|
620
|
-
if (path) {
|
621
|
-
path.push(n);
|
622
|
-
return path;
|
623
|
-
}
|
624
|
-
}
|
625
|
-
}
|
626
|
-
return undefined;
|
627
|
-
};
|
628
|
-
|
629
|
-
if (Array.isArray(ast)) {
|
630
|
-
for (let i = 0; i < ast.length; i++) {
|
631
|
-
const enterResult = enterNode(ast[i]);
|
632
|
-
if (enterResult !== undefined) return enterResult;
|
633
|
-
}
|
634
|
-
} else if (ast && typeof ast === "object") {
|
635
|
-
const keys = Object.keys(ast);
|
636
|
-
for (let i = 0; i < keys.length; i++) {
|
637
|
-
const value = ast[keys[i]];
|
638
|
-
if (Array.isArray(value)) {
|
639
|
-
const pathResult = getPathInAst(value, node);
|
640
|
-
if (pathResult !== undefined) return pathResult;
|
641
|
-
} else if (value && typeof value === "object") {
|
642
|
-
const enterResult = enterNode(value);
|
643
|
-
if (enterResult !== undefined) return enterResult;
|
644
|
-
}
|
645
|
-
}
|
646
|
-
}
|
647
|
-
};
|
648
|
-
|
649
629
|
const TYPES = new Set(["javascript"]);
|
650
630
|
|
651
631
|
class ConcatenatedModule extends Module {
|
@@ -653,7 +633,7 @@ class ConcatenatedModule extends Module {
|
|
653
633
|
* @param {Module} rootModule the root module of the concatenation
|
654
634
|
* @param {Set<Module>} modules all modules in the concatenation (including the root module)
|
655
635
|
* @param {RuntimeSpec} runtime the runtime
|
656
|
-
* @param {
|
636
|
+
* @param {object=} associatedObjectForCache object for caching
|
657
637
|
* @param {string | HashConstructor=} hashFunction hash function to use
|
658
638
|
* @returns {ConcatenatedModule} the module
|
659
639
|
*/
|
@@ -679,7 +659,7 @@ class ConcatenatedModule extends Module {
|
|
679
659
|
}
|
680
660
|
|
681
661
|
/**
|
682
|
-
* @param {
|
662
|
+
* @param {object} options options
|
683
663
|
* @param {string} options.identifier the identifier of the module
|
684
664
|
* @param {Module=} options.rootModule the root module of the concatenation
|
685
665
|
* @param {RuntimeSpec} options.runtime the selected runtime
|
@@ -772,11 +752,14 @@ class ConcatenatedModule extends Module {
|
|
772
752
|
*/
|
773
753
|
build(options, compilation, resolver, fs, callback) {
|
774
754
|
const { rootModule } = this;
|
755
|
+
const { moduleArgument, exportsArgument } =
|
756
|
+
/** @type {BuildInfo} */
|
757
|
+
(rootModule.buildInfo);
|
775
758
|
this.buildInfo = {
|
776
759
|
strict: true,
|
777
760
|
cacheable: true,
|
778
|
-
moduleArgument
|
779
|
-
exportsArgument
|
761
|
+
moduleArgument,
|
762
|
+
exportsArgument,
|
780
763
|
fileDependencies: new LazySet(),
|
781
764
|
contextDependencies: new LazySet(),
|
782
765
|
missingDependencies: new LazySet(),
|
@@ -789,7 +772,7 @@ class ConcatenatedModule extends Module {
|
|
789
772
|
|
790
773
|
for (const m of this._modules) {
|
791
774
|
// populate cacheable
|
792
|
-
if (!m.buildInfo.cacheable) {
|
775
|
+
if (!(/** @type {BuildInfo} */ (m.buildInfo).cacheable)) {
|
793
776
|
this.buildInfo.cacheable = false;
|
794
777
|
}
|
795
778
|
|
@@ -797,7 +780,9 @@ class ConcatenatedModule extends Module {
|
|
797
780
|
for (const d of m.dependencies.filter(
|
798
781
|
dep =>
|
799
782
|
!(dep instanceof HarmonyImportDependency) ||
|
800
|
-
!this._modules.has(
|
783
|
+
!this._modules.has(
|
784
|
+
/** @type {Module} */ (compilation.moduleGraph.getModule(dep))
|
785
|
+
)
|
801
786
|
)) {
|
802
787
|
this.dependencies.push(d);
|
803
788
|
}
|
@@ -822,11 +807,14 @@ class ConcatenatedModule extends Module {
|
|
822
807
|
}
|
823
808
|
}
|
824
809
|
|
810
|
+
const { assets, assetsInfo, topLevelDeclarations } =
|
811
|
+
/** @type {BuildInfo} */ (m.buildInfo);
|
812
|
+
|
825
813
|
// populate topLevelDeclarations
|
826
|
-
if (
|
814
|
+
if (topLevelDeclarations) {
|
827
815
|
const topLevelDeclarations = this.buildInfo.topLevelDeclarations;
|
828
816
|
if (topLevelDeclarations !== undefined) {
|
829
|
-
for (const decl of
|
817
|
+
for (const decl of topLevelDeclarations) {
|
830
818
|
topLevelDeclarations.add(decl);
|
831
819
|
}
|
832
820
|
}
|
@@ -835,17 +823,17 @@ class ConcatenatedModule extends Module {
|
|
835
823
|
}
|
836
824
|
|
837
825
|
// populate assets
|
838
|
-
if (
|
826
|
+
if (assets) {
|
839
827
|
if (this.buildInfo.assets === undefined) {
|
840
828
|
this.buildInfo.assets = Object.create(null);
|
841
829
|
}
|
842
|
-
Object.assign(this.buildInfo.assets,
|
830
|
+
Object.assign(/** @type {BuildInfo} */ (this.buildInfo).assets, assets);
|
843
831
|
}
|
844
|
-
if (
|
832
|
+
if (assetsInfo) {
|
845
833
|
if (this.buildInfo.assetsInfo === undefined) {
|
846
834
|
this.buildInfo.assetsInfo = new Map();
|
847
835
|
}
|
848
|
-
for (const [key, value] of
|
836
|
+
for (const [key, value] of assetsInfo) {
|
849
837
|
this.buildInfo.assetsInfo.set(key, value);
|
850
838
|
}
|
851
839
|
}
|
@@ -1045,7 +1033,7 @@ class ConcatenatedModule extends Module {
|
|
1045
1033
|
/**
|
1046
1034
|
* @param {Module} rootModule the root module of the concatenation
|
1047
1035
|
* @param {Set<Module>} modules all modules in the concatenation (including the root module)
|
1048
|
-
* @param {
|
1036
|
+
* @param {object=} associatedObjectForCache object for caching
|
1049
1037
|
* @param {string | HashConstructor=} hashFunction hash function to use
|
1050
1038
|
* @returns {string} the identifier
|
1051
1039
|
*/
|
@@ -1056,7 +1044,7 @@ class ConcatenatedModule extends Module {
|
|
1056
1044
|
hashFunction = "md4"
|
1057
1045
|
) {
|
1058
1046
|
const cachedMakePathsRelative = makePathsRelative.bindContextCache(
|
1059
|
-
rootModule.context,
|
1047
|
+
/** @type {string} */ (rootModule.context),
|
1060
1048
|
associatedObjectForCache
|
1061
1049
|
);
|
1062
1050
|
let identifiers = [];
|
@@ -1139,12 +1127,12 @@ class ConcatenatedModule extends Module {
|
|
1139
1127
|
const topLevelDeclarations = new Set();
|
1140
1128
|
|
1141
1129
|
// List of additional names in scope for module references
|
1142
|
-
/** @type {Map<string, { usedNames:
|
1130
|
+
/** @type {Map<string, { usedNames: UsedNames, alreadyCheckedScopes: Set<TODO> }>} */
|
1143
1131
|
const usedNamesInScopeInfo = new Map();
|
1144
1132
|
/**
|
1145
1133
|
* @param {string} module module identifier
|
1146
1134
|
* @param {string} id export id
|
1147
|
-
* @returns {{ usedNames:
|
1135
|
+
* @returns {{ usedNames: UsedNames, alreadyCheckedScopes: Set<TODO> }} info
|
1148
1136
|
*/
|
1149
1137
|
const getUsedNamesInScopeInfo = (module, id) => {
|
1150
1138
|
const key = `${module}-${id}`;
|
@@ -1174,6 +1162,10 @@ class ConcatenatedModule extends Module {
|
|
1174
1162
|
// We get ranges of all super class expressions to make
|
1175
1163
|
// renaming to work correctly
|
1176
1164
|
const superClassCache = new WeakMap();
|
1165
|
+
/**
|
1166
|
+
* @param {Scope} scope scope
|
1167
|
+
* @returns {TODO} result
|
1168
|
+
*/
|
1177
1169
|
const getSuperClassExpressions = scope => {
|
1178
1170
|
const cacheEntry = superClassCache.get(scope);
|
1179
1171
|
if (cacheEntry !== undefined) return cacheEntry;
|
@@ -1216,7 +1208,8 @@ class ConcatenatedModule extends Module {
|
|
1216
1208
|
runtimeTemplate,
|
1217
1209
|
neededNamespaceObjects,
|
1218
1210
|
false,
|
1219
|
-
|
1211
|
+
/** @type {BuildMeta} */
|
1212
|
+
(info.module.buildMeta).strictHarmonyModule,
|
1220
1213
|
true
|
1221
1214
|
);
|
1222
1215
|
if (!binding.ids) continue;
|
@@ -1227,8 +1220,10 @@ class ConcatenatedModule extends Module {
|
|
1227
1220
|
);
|
1228
1221
|
for (const expr of getSuperClassExpressions(reference.from)) {
|
1229
1222
|
if (
|
1230
|
-
expr.range[0] <=
|
1231
|
-
|
1223
|
+
expr.range[0] <=
|
1224
|
+
/** @type {Range} */ (reference.identifier.range)[0] &&
|
1225
|
+
expr.range[1] >=
|
1226
|
+
/** @type {Range} */ (reference.identifier.range)[1]
|
1232
1227
|
) {
|
1233
1228
|
for (const variable of expr.variables) {
|
1234
1229
|
usedNames.add(variable.name);
|
@@ -1287,7 +1282,7 @@ class ConcatenatedModule extends Module {
|
|
1287
1282
|
references.map(r => r.identifier).concat(variable.identifiers)
|
1288
1283
|
);
|
1289
1284
|
for (const identifier of allIdentifiers) {
|
1290
|
-
const r = identifier.range;
|
1285
|
+
const r = /** @type {Range} */ (identifier.range);
|
1291
1286
|
const path = getPathInAst(info.ast, identifier);
|
1292
1287
|
if (path && path.length > 1) {
|
1293
1288
|
const maybeProperty =
|
@@ -1325,7 +1320,9 @@ class ConcatenatedModule extends Module {
|
|
1325
1320
|
);
|
1326
1321
|
allUsedNames.add(namespaceObjectName);
|
1327
1322
|
}
|
1328
|
-
info.namespaceObjectName =
|
1323
|
+
info.namespaceObjectName =
|
1324
|
+
/** @type {string} */
|
1325
|
+
(namespaceObjectName);
|
1329
1326
|
topLevelDeclarations.add(namespaceObjectName);
|
1330
1327
|
break;
|
1331
1328
|
}
|
@@ -1342,7 +1339,8 @@ class ConcatenatedModule extends Module {
|
|
1342
1339
|
break;
|
1343
1340
|
}
|
1344
1341
|
}
|
1345
|
-
|
1342
|
+
const buildMeta = /** @type {BuildMeta} */ (info.module.buildMeta);
|
1343
|
+
if (buildMeta.exportsType !== "namespace") {
|
1346
1344
|
const externalNameInterop = this.findNewName(
|
1347
1345
|
"namespaceObject",
|
1348
1346
|
allUsedNames,
|
@@ -1354,8 +1352,8 @@ class ConcatenatedModule extends Module {
|
|
1354
1352
|
topLevelDeclarations.add(externalNameInterop);
|
1355
1353
|
}
|
1356
1354
|
if (
|
1357
|
-
|
1358
|
-
|
1355
|
+
buildMeta.exportsType === "default" &&
|
1356
|
+
buildMeta.defaultObject !== "redirect"
|
1359
1357
|
) {
|
1360
1358
|
const externalNameInterop = this.findNewName(
|
1361
1359
|
"namespaceObject2",
|
@@ -1367,10 +1365,7 @@ class ConcatenatedModule extends Module {
|
|
1367
1365
|
info.interopNamespaceObject2Name = externalNameInterop;
|
1368
1366
|
topLevelDeclarations.add(externalNameInterop);
|
1369
1367
|
}
|
1370
|
-
if (
|
1371
|
-
info.module.buildMeta.exportsType === "dynamic" ||
|
1372
|
-
!info.module.buildMeta.exportsType
|
1373
|
-
) {
|
1368
|
+
if (buildMeta.exportsType === "dynamic" || !buildMeta.exportsType) {
|
1374
1369
|
const externalNameInterop = this.findNewName(
|
1375
1370
|
"default",
|
1376
1371
|
allUsedNames,
|
@@ -1404,10 +1399,11 @@ class ConcatenatedModule extends Module {
|
|
1404
1399
|
neededNamespaceObjects,
|
1405
1400
|
match.call,
|
1406
1401
|
!match.directImport,
|
1407
|
-
|
1402
|
+
/** @type {BuildMeta} */
|
1403
|
+
(info.module.buildMeta).strictHarmonyModule,
|
1408
1404
|
match.asiSafe
|
1409
1405
|
);
|
1410
|
-
const r = reference.identifier.range;
|
1406
|
+
const r = /** @type {Range} */ (reference.identifier.range);
|
1411
1407
|
const source = info.source;
|
1412
1408
|
// range is extended by 2 chars to cover the appended "._"
|
1413
1409
|
source.replace(r[0], r[1] + 1, finalName);
|
@@ -1427,7 +1423,9 @@ class ConcatenatedModule extends Module {
|
|
1427
1423
|
const rootInfo = /** @type {ConcatenatedModuleInfo} */ (
|
1428
1424
|
moduleToInfoMap.get(this.rootModule)
|
1429
1425
|
);
|
1430
|
-
const strictHarmonyModule =
|
1426
|
+
const strictHarmonyModule =
|
1427
|
+
/** @type {BuildMeta} */
|
1428
|
+
(rootInfo.module.buildMeta).strictHarmonyModule;
|
1431
1429
|
const exportsInfo = moduleGraph.getExportsInfo(rootInfo.module);
|
1432
1430
|
for (const exportInfo of exportsInfo.orderedExports) {
|
1433
1431
|
const name = exportInfo.name;
|
@@ -1457,7 +1455,9 @@ class ConcatenatedModule extends Module {
|
|
1457
1455
|
exportInfo.isReexport() ? "reexport" : "binding"
|
1458
1456
|
} */ ${finalName}`;
|
1459
1457
|
} catch (e) {
|
1460
|
-
|
1458
|
+
/** @type {Error} */
|
1459
|
+
(e).message +=
|
1460
|
+
`\nwhile generating the root export '${name}' (used name: '${used}')`;
|
1461
1461
|
throw e;
|
1462
1462
|
}
|
1463
1463
|
});
|
@@ -1527,7 +1527,8 @@ class ConcatenatedModule extends Module {
|
|
1527
1527
|
neededNamespaceObjects,
|
1528
1528
|
false,
|
1529
1529
|
undefined,
|
1530
|
-
|
1530
|
+
/** @type {BuildMeta} */
|
1531
|
+
(info.module.buildMeta).strictHarmonyModule,
|
1531
1532
|
true
|
1532
1533
|
);
|
1533
1534
|
nsObj.push(
|
@@ -1698,7 +1699,9 @@ ${defineGetters}`
|
|
1698
1699
|
codeGenerationResults,
|
1699
1700
|
sourceTypes: TYPES
|
1700
1701
|
});
|
1701
|
-
const source =
|
1702
|
+
const source = /** @type {Source} */ (
|
1703
|
+
codeGenResult.sources.get("javascript")
|
1704
|
+
);
|
1702
1705
|
const data = codeGenResult.data;
|
1703
1706
|
const chunkInitFragments = data && data.get("chunkInitFragments");
|
1704
1707
|
const code = source.source().toString();
|
@@ -1730,7 +1733,7 @@ ${defineGetters}`
|
|
1730
1733
|
ignoreEval: true,
|
1731
1734
|
impliedStrict: true
|
1732
1735
|
});
|
1733
|
-
const globalScope = scopeManager.acquire(ast);
|
1736
|
+
const globalScope = /** @type {Scope} */ (scopeManager.acquire(ast));
|
1734
1737
|
const moduleScope = globalScope.childScopes[0];
|
1735
1738
|
const resultSource = new ReplaceSource(source);
|
1736
1739
|
info.runtimeRequirements = codeGenResult.runtimeRequirements;
|
@@ -1741,7 +1744,9 @@ ${defineGetters}`
|
|
1741
1744
|
info.globalScope = globalScope;
|
1742
1745
|
info.moduleScope = moduleScope;
|
1743
1746
|
} catch (err) {
|
1744
|
-
|
1747
|
+
/** @type {Error} */
|
1748
|
+
(err).message +=
|
1749
|
+
`\nwhile analyzing module ${m.identifier()} for concatenation`;
|
1745
1750
|
throw err;
|
1746
1751
|
}
|
1747
1752
|
}
|
@@ -1809,7 +1814,10 @@ ${defineGetters}`
|
|
1809
1814
|
`Unsupported concatenation entry type ${info.type}`
|
1810
1815
|
);
|
1811
1816
|
}
|
1812
|
-
map.set(
|
1817
|
+
map.set(
|
1818
|
+
/** @type {ModuleInfo} */ (item).module,
|
1819
|
+
/** @type {ModuleInfo} */ (item)
|
1820
|
+
);
|
1813
1821
|
return item;
|
1814
1822
|
} else {
|
1815
1823
|
/** @type {ReferenceToModuleInfo} */
|
@@ -1824,6 +1832,13 @@ ${defineGetters}`
|
|
1824
1832
|
return [list, map];
|
1825
1833
|
}
|
1826
1834
|
|
1835
|
+
/**
|
1836
|
+
* @param {string} oldName old name
|
1837
|
+
* @param {UsedNames} usedNamed1 used named 1
|
1838
|
+
* @param {UsedNames} usedNamed2 used named 2
|
1839
|
+
* @param {string} extraInfo extra info
|
1840
|
+
* @returns {string} found new name
|
1841
|
+
*/
|
1827
1842
|
findNewName(oldName, usedNamed1, usedNamed2, extraInfo) {
|
1828
1843
|
let name = oldName;
|
1829
1844
|
|
@@ -1889,6 +1904,10 @@ ${defineGetters}`
|
|
1889
1904
|
super.updateHash(hash, context);
|
1890
1905
|
}
|
1891
1906
|
|
1907
|
+
/**
|
1908
|
+
* @param {ObjectDeserializerContext} context context
|
1909
|
+
* @returns {ConcatenatedModule} ConcatenatedModule
|
1910
|
+
*/
|
1892
1911
|
static deserialize(context) {
|
1893
1912
|
const obj = new ConcatenatedModule({
|
1894
1913
|
identifier: undefined,
|
@@ -56,7 +56,7 @@ class EnsureChunkConditionsPlugin {
|
|
56
56
|
// We reached the entrypoint: fail
|
57
57
|
if (chunkGroup.isInitial()) {
|
58
58
|
throw new Error(
|
59
|
-
"Cannot
|
59
|
+
"Cannot fulfil chunk condition of " + module.identifier()
|
60
60
|
);
|
61
61
|
}
|
62
62
|
// Try placing in all parents
|