webpack 5.106.2 → 5.107.1
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 +2 -2
- package/lib/APIPlugin.js +1 -1
- package/lib/BannerPlugin.js +3 -4
- package/lib/Cache.js +3 -6
- package/lib/Chunk.js +21 -25
- package/lib/ChunkGroup.js +57 -15
- package/lib/CompatibilityPlugin.js +8 -7
- package/lib/Compilation.js +67 -37
- package/lib/Compiler.js +4 -13
- package/lib/ContextModule.js +2 -2
- package/lib/DefinePlugin.js +2 -2
- package/lib/Dependency.js +22 -1
- package/lib/DependencyTemplate.js +2 -1
- package/lib/EnvironmentPlugin.js +1 -1
- package/lib/EvalSourceMapDevToolPlugin.js +8 -10
- package/lib/ExportsInfo.js +30 -34
- package/lib/ExternalModule.js +91 -26
- package/lib/ExternalModuleFactoryPlugin.js +7 -1
- package/lib/FileSystemInfo.js +187 -72
- package/lib/Generator.js +3 -3
- package/lib/HotModuleReplacementPlugin.js +26 -8
- package/lib/IgnorePlugin.js +2 -1
- package/lib/Module.js +20 -19
- package/lib/ModuleFactory.js +1 -1
- package/lib/ModuleNotFoundError.js +3 -84
- package/lib/ModuleSourceTypeConstants.js +51 -19
- package/lib/ModuleTypeConstants.js +12 -3
- package/lib/MultiCompiler.js +2 -2
- package/lib/NodeStuffPlugin.js +1 -1
- package/lib/NormalModule.js +119 -77
- package/lib/NormalModuleFactory.js +47 -27
- package/lib/Parser.js +1 -1
- package/lib/ProgressPlugin.js +129 -56
- package/lib/RuntimeGlobals.js +5 -5
- package/lib/RuntimeModule.js +9 -7
- package/lib/RuntimePlugin.js +12 -1
- package/lib/SourceMapDevToolPlugin.js +250 -49
- package/lib/Template.js +1 -1
- package/lib/TemplatedPathPlugin.js +22 -4
- package/lib/WarnCaseSensitiveModulesPlugin.js +70 -2
- package/lib/WarnDeprecatedOptionPlugin.js +1 -1
- package/lib/WarnNoModeSetPlugin.js +16 -1
- package/lib/Watching.js +2 -3
- package/lib/WebpackError.js +3 -77
- package/lib/WebpackIsIncludedPlugin.js +1 -1
- package/lib/WebpackOptionsApply.js +13 -1
- package/lib/asset/AssetBytesGenerator.js +12 -8
- package/lib/asset/AssetGenerator.js +36 -22
- package/lib/asset/AssetModulesPlugin.js +6 -8
- package/lib/asset/AssetSourceGenerator.js +12 -8
- package/lib/buildChunkGraph.js +4 -6
- package/lib/cache/PackFileCacheStrategy.js +4 -4
- package/lib/cli.js +3 -1
- package/lib/config/defaults.js +197 -10
- package/lib/config/normalization.js +3 -1
- package/lib/css/CssGenerator.js +320 -105
- package/lib/css/CssInjectStyleRuntimeModule.js +44 -42
- package/lib/css/CssLoadingRuntimeModule.js +22 -4
- package/lib/{CssModule.js → css/CssModule.js} +15 -15
- package/lib/css/CssModulesPlugin.js +168 -88
- package/lib/css/CssParser.js +566 -269
- package/lib/css/walkCssTokens.js +148 -2
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +1 -1
- package/lib/dependencies/CommonJsDependencyHelpers.js +63 -0
- package/lib/dependencies/CommonJsExportRequireDependency.js +54 -10
- package/lib/dependencies/CommonJsExportsParserPlugin.js +1 -1
- package/lib/dependencies/CommonJsFullRequireDependency.js +32 -9
- package/lib/dependencies/CommonJsImportsParserPlugin.js +112 -4
- package/lib/dependencies/CommonJsRequireDependency.js +67 -4
- package/lib/dependencies/ContextDependency.js +1 -1
- package/lib/dependencies/ContextDependencyHelpers.js +1 -1
- package/lib/dependencies/CreateRequireParserPlugin.js +1 -1
- package/lib/dependencies/CriticalDependencyWarning.js +1 -1
- package/lib/dependencies/CssIcssExportDependency.js +332 -67
- package/lib/dependencies/CssIcssImportDependency.js +49 -7
- package/lib/dependencies/CssIcssSymbolDependency.js +11 -3
- package/lib/dependencies/CssImportDependency.js +8 -0
- package/lib/dependencies/CssUrlDependency.js +28 -2
- package/lib/dependencies/HarmonyDetectionParserPlugin.js +22 -2
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +8 -7
- package/lib/dependencies/HarmonyExportExpressionDependency.js +22 -14
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +110 -3
- package/lib/dependencies/HarmonyImportDependency.js +10 -2
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +22 -1
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +1 -1
- package/lib/{HarmonyLinkingError.js → dependencies/HarmonyLinkingError.js} +5 -3
- package/lib/dependencies/HtmlInlineScriptDependency.js +133 -0
- package/lib/dependencies/HtmlInlineStyleDependency.js +101 -0
- package/lib/dependencies/HtmlScriptSrcDependency.js +557 -0
- package/lib/dependencies/HtmlSourceDependency.js +128 -0
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +1 -1
- package/lib/dependencies/ImportParserPlugin.js +2 -2
- package/lib/dependencies/ImportPhase.js +1 -1
- package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +1 -1
- package/lib/{RequireJsStuffPlugin.js → dependencies/RequireJsStuffPlugin.js} +7 -7
- package/lib/dependencies/SystemPlugin.js +1 -1
- package/lib/dependencies/WebAssemblyImportDependency.js +1 -1
- package/lib/dependencies/WorkerPlugin.js +2 -2
- package/lib/{DelegatedModule.js → dll/DelegatedModule.js} +31 -31
- package/lib/{DelegatedModuleFactoryPlugin.js → dll/DelegatedModuleFactoryPlugin.js} +4 -4
- package/lib/{DelegatedPlugin.js → dll/DelegatedPlugin.js} +2 -2
- package/lib/{DllEntryPlugin.js → dll/DllEntryPlugin.js} +4 -4
- package/lib/{DllModule.js → dll/DllModule.js} +24 -24
- package/lib/{DllModuleFactory.js → dll/DllModuleFactory.js} +4 -4
- package/lib/{DllPlugin.js → dll/DllPlugin.js} +6 -5
- package/lib/{DllReferencePlugin.js → dll/DllReferencePlugin.js} +14 -14
- package/lib/{LibManifestPlugin.js → dll/LibManifestPlugin.js} +9 -9
- package/lib/{AsyncDependencyToInitialChunkError.js → errors/AsyncDependencyToInitialChunkError.js} +2 -2
- package/lib/errors/BuildCycleError.js +1 -1
- package/lib/{ChunkRenderError.js → errors/ChunkRenderError.js} +1 -1
- package/lib/{CodeGenerationError.js → errors/CodeGenerationError.js} +1 -1
- package/lib/{CommentCompilationWarning.js → errors/CommentCompilationWarning.js} +3 -3
- package/lib/{ConcurrentCompilationError.js → errors/ConcurrentCompilationError.js} +4 -2
- package/lib/{EnvironmentNotSupportAsyncWarning.js → errors/EnvironmentNotSupportAsyncWarning.js} +4 -4
- package/lib/{HookWebpackError.js → errors/HookWebpackError.js} +5 -5
- package/lib/{IgnoreErrorModuleFactory.js → errors/IgnoreErrorModuleFactory.js} +4 -4
- package/lib/{InvalidDependenciesModuleWarning.js → errors/InvalidDependenciesModuleWarning.js} +3 -3
- package/lib/errors/JSONParseError.js +114 -0
- package/lib/{ModuleBuildError.js → errors/ModuleBuildError.js} +5 -5
- package/lib/{ModuleDependencyError.js → errors/ModuleDependencyError.js} +2 -2
- package/lib/{ModuleDependencyWarning.js → errors/ModuleDependencyWarning.js} +4 -4
- package/lib/{ModuleError.js → errors/ModuleError.js} +5 -5
- package/lib/{ModuleHashingError.js → errors/ModuleHashingError.js} +1 -1
- package/lib/errors/ModuleNotFoundError.js +91 -0
- package/lib/{ModuleParseError.js → errors/ModuleParseError.js} +8 -6
- package/lib/{ModuleRestoreError.js → errors/ModuleRestoreError.js} +1 -1
- package/lib/{ModuleStoreError.js → errors/ModuleStoreError.js} +1 -1
- package/lib/{ModuleWarning.js → errors/ModuleWarning.js} +5 -5
- package/lib/{NodeStuffInWebError.js → errors/NodeStuffInWebError.js} +4 -4
- package/lib/errors/NonErrorEmittedError.js +28 -0
- package/lib/{UnhandledSchemeError.js → errors/UnhandledSchemeError.js} +2 -2
- package/lib/{UnsupportedFeatureWarning.js → errors/UnsupportedFeatureWarning.js} +3 -3
- package/lib/errors/WebpackError.js +84 -0
- package/lib/html/HtmlGenerator.js +379 -0
- package/lib/html/HtmlModulesPlugin.js +429 -0
- package/lib/html/HtmlParser.js +1489 -0
- package/lib/html/walkHtmlTokens.js +3249 -0
- package/lib/ids/IdHelpers.js +2 -1
- package/lib/index.js +36 -15
- package/lib/javascript/JavascriptModulesPlugin.js +91 -10
- package/lib/javascript/JavascriptParser.js +197 -16
- package/lib/javascript/JavascriptParserHelpers.js +1 -1
- package/lib/json/JsonParser.js +7 -16
- package/lib/library/AbstractLibraryPlugin.js +1 -1
- package/lib/library/EnableLibraryPlugin.js +1 -1
- package/lib/{FalseIIFEUmdWarning.js → library/FalseIIFEUmdWarning.js} +1 -1
- package/lib/library/ModuleLibraryPlugin.js +74 -0
- package/lib/node/NodeEnvironmentPlugin.js +4 -2
- package/lib/node/nodeConsole.js +113 -64
- package/lib/optimize/ConcatenatedModule.js +51 -6
- package/lib/optimize/InnerGraph.js +1 -1
- package/lib/optimize/InnerGraphPlugin.js +11 -1
- package/lib/optimize/MinMaxSizeWarning.js +4 -4
- package/lib/optimize/ModuleConcatenationPlugin.js +15 -7
- package/lib/optimize/RealContentHashPlugin.js +89 -26
- package/lib/optimize/SideEffectsFlagPlugin.js +112 -5
- package/lib/optimize/SplitChunksPlugin.js +5 -5
- package/lib/performance/AssetsOverSizeLimitWarning.js +2 -2
- package/lib/performance/EntrypointsOverSizeLimitWarning.js +2 -2
- package/lib/performance/NoAsyncChunksWarning.js +5 -3
- package/lib/performance/SizeLimitsPlugin.js +1 -1
- package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +4 -1
- package/lib/rules/UseEffectRulePlugin.js +4 -3
- package/lib/runtime/AutoPublicPathRuntimeModule.js +3 -3
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +5 -5
- package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +119 -13
- package/lib/runtime/SetAnonymousDefaultNameRuntimeModule.js +35 -0
- package/lib/schemes/DataUriPlugin.js +13 -1
- package/lib/schemes/VirtualUrlPlugin.js +1 -1
- package/lib/serialization/SerializerMiddleware.js +2 -2
- package/lib/sharing/ConsumeSharedPlugin.js +4 -10
- package/lib/sharing/ConsumeSharedRuntimeModule.js +8 -4
- package/lib/sharing/ProvideSharedModule.js +1 -1
- package/lib/sharing/ProvideSharedPlugin.js +5 -5
- package/lib/sharing/resolveMatchedConfigs.js +1 -1
- package/lib/stats/DefaultStatsFactoryPlugin.js +2 -2
- package/lib/stats/DefaultStatsPresetPlugin.js +1 -1
- package/lib/stats/DefaultStatsPrinterPlugin.js +1 -1
- package/lib/stats/StatsFactory.js +1 -1
- package/lib/typescript/TypeScriptPlugin.js +210 -0
- package/lib/url/URLParserPlugin.js +2 -2
- package/lib/util/AsyncQueue.js +2 -2
- package/lib/util/Hash.js +2 -2
- package/lib/util/LocConverter.js +53 -0
- package/lib/util/SortableSet.js +1 -1
- package/lib/util/cleverMerge.js +2 -2
- package/lib/util/comparators.js +3 -3
- package/lib/util/concatenate.js +3 -3
- package/lib/util/conventions.js +42 -1
- package/lib/util/createMappings.js +118 -0
- package/lib/{formatLocation.js → util/formatLocation.js} +2 -2
- package/lib/{SizeFormatHelpers.js → util/formatSize.js} +3 -1
- package/lib/util/fs.js +8 -8
- package/lib/util/hash/md4.js +1 -1
- package/lib/util/hash/xxhash64.js +1 -1
- package/lib/util/identifier.js +48 -0
- package/lib/util/internalSerializables.js +35 -19
- package/lib/util/magicComment.js +10 -7
- package/lib/util/parseJson.js +2 -73
- package/lib/util/source.js +21 -0
- package/lib/util/topologicalSort.js +69 -0
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +3 -4
- package/lib/wasm-async/AsyncWebAssemblyParser.js +1 -1
- package/lib/wasm-sync/UnsupportedWebAssemblyFeatureError.js +5 -3
- package/lib/wasm-sync/WasmFinalizeExportsPlugin.js +1 -1
- package/lib/wasm-sync/WebAssemblyInInitialChunkError.js +5 -3
- package/lib/webpack.js +3 -1
- package/package.json +24 -22
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +129 -12
- package/schemas/plugins/{DllPlugin.check.d.ts → HtmlGeneratorOptions.check.d.ts} +1 -1
- package/schemas/plugins/HtmlGeneratorOptions.check.js +6 -0
- package/schemas/plugins/HtmlGeneratorOptions.json +3 -0
- package/schemas/plugins/ProgressPlugin.check.js +1 -1
- package/schemas/plugins/ProgressPlugin.json +22 -0
- package/schemas/plugins/container/ContainerReferencePlugin.check.js +1 -1
- package/schemas/plugins/container/ContainerReferencePlugin.json +1 -0
- package/schemas/plugins/container/ExternalsType.check.js +1 -1
- package/schemas/plugins/container/ModuleFederationPlugin.check.js +1 -1
- package/schemas/plugins/container/ModuleFederationPlugin.json +1 -0
- package/schemas/plugins/{DllReferencePlugin.check.d.ts → css/CssAutoOrModuleParserOptions.check.d.ts} +1 -1
- package/schemas/plugins/css/CssAutoOrModuleParserOptions.check.js +6 -0
- package/schemas/plugins/css/CssAutoOrModuleParserOptions.json +3 -0
- package/schemas/plugins/dll/DllPlugin.check.d.ts +7 -0
- package/schemas/plugins/dll/DllReferencePlugin.check.d.ts +7 -0
- package/types.d.ts +1153 -233
- package/lib/CaseSensitiveModulesWarning.js +0 -80
- package/lib/GraphHelpers.js +0 -49
- package/lib/NoModeWarning.js +0 -23
- package/lib/css/CssMergeStyleSheetsRuntimeModule.js +0 -57
- /package/lib/{AbstractMethodError.js → errors/AbstractMethodError.js} +0 -0
- /package/schemas/plugins/{DllPlugin.check.js → dll/DllPlugin.check.js} +0 -0
- /package/schemas/plugins/{DllPlugin.json → dll/DllPlugin.json} +0 -0
- /package/schemas/plugins/{DllReferencePlugin.check.js → dll/DllReferencePlugin.check.js} +0 -0
- /package/schemas/plugins/{DllReferencePlugin.json → dll/DllReferencePlugin.json} +0 -0
|
@@ -121,15 +121,40 @@ class MakeDeferredNamespaceObjectRuntimeModule extends HelperRuntimeModule {
|
|
|
121
121
|
? "init?.();"
|
|
122
122
|
: "if (init) init();";
|
|
123
123
|
return `${fn} = ${runtimeTemplate.basicFunction("moduleId, mode", [
|
|
124
|
+
// Per the TC39 import-defer spec, deferred namespaces are
|
|
125
|
+
// distinct from their eager counterparts and the same module
|
|
126
|
+
// referenced from multiple defer-import sites must yield the
|
|
127
|
+
// same object. Cache the Proxy / fake namespace per-moduleId so
|
|
128
|
+
// repeated calls (including across files) share identity.
|
|
129
|
+
//
|
|
130
|
+
// Bit 16 (`createFakeNamespaceObject`'s "return value when
|
|
131
|
+
// it's Promise-like" flag added by
|
|
132
|
+
// `RuntimeTemplate.moduleNamespacePromise` for dynamic
|
|
133
|
+
// imports) is irrelevant for deferred namespaces — the value
|
|
134
|
+
// passed into `createFakeNamespaceObject` here is always the
|
|
135
|
+
// resolved module exports (after unwrapping the async-module
|
|
136
|
+
// export symbol when present), never a Promise. Strip it
|
|
137
|
+
// once so all downstream behavior, the cache key, and the
|
|
138
|
+
// `createFakeNamespaceObject` call below see the same shape
|
|
139
|
+
// mode. This keeps static defer (mode 8) and dynamic
|
|
140
|
+
// `await import.defer` (mode 8 | 16) sharing the same
|
|
141
|
+
// Deferred Module Namespace object, while still keying by
|
|
142
|
+
// `(moduleId, mode)` so distinct exports-type shapes
|
|
143
|
+
// (e.g. one importer treats a CJS module as
|
|
144
|
+
// "default-with-named", another as "namespace") get
|
|
145
|
+
// distinct cache entries.
|
|
146
|
+
"mode &= ~16;",
|
|
147
|
+
"var byMode = __webpack_module_deferred_namespace_cache__[moduleId];",
|
|
148
|
+
"if (byMode && byMode[mode] !== undefined) return byMode[mode];",
|
|
149
|
+
"if (!byMode) byMode = __webpack_module_deferred_namespace_cache__[moduleId] = {};",
|
|
124
150
|
"var cachedModule = __webpack_module_cache__[moduleId];",
|
|
125
|
-
"if (cachedModule && cachedModule.error === undefined) {",
|
|
151
|
+
"if (cachedModule && cachedModule.error === undefined && !(mode & 8)) {",
|
|
126
152
|
Template.indent([
|
|
127
153
|
"var exports = cachedModule.exports;",
|
|
128
154
|
hasAsync
|
|
129
155
|
? `if (${RuntimeGlobals.asyncModuleExportSymbol} in exports) exports = exports[${RuntimeGlobals.asyncModuleExportSymbol}];`
|
|
130
156
|
: "",
|
|
131
|
-
|
|
132
|
-
`return ${RuntimeGlobals.createFakeNamespaceObject}(exports, mode);`
|
|
157
|
+
`return byMode[mode] = ${RuntimeGlobals.createFakeNamespaceObject}(exports, mode);`
|
|
133
158
|
]),
|
|
134
159
|
"}",
|
|
135
160
|
"",
|
|
@@ -141,9 +166,23 @@ class MakeDeferredNamespaceObjectRuntimeModule extends HelperRuntimeModule {
|
|
|
141
166
|
"init = null;",
|
|
142
167
|
"if (mode & 8 || mode & 4 && ns.__esModule && typeof ns === 'object') {",
|
|
143
168
|
Template.indent([
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
169
|
+
// Drop only the read-side traps after init: with the
|
|
170
|
+
// resolved namespace's own keys mirrored onto
|
|
171
|
+
// `ns_target` below, the default `Reflect` behavior
|
|
172
|
+
// returns the right values via the live-binding
|
|
173
|
+
// getters, so we no longer need to intercept `get` /
|
|
174
|
+
// `has` / `ownKeys` / `getOwnPropertyDescriptor`.
|
|
175
|
+
//
|
|
176
|
+
// The mutation traps (`set`, `deleteProperty`,
|
|
177
|
+
// `defineProperty`) are kept because per the TC39
|
|
178
|
+
// import-defer spec, `[[Set]]` / `[[Delete]]` /
|
|
179
|
+
// `[[DefineOwnProperty]]` on a Deferred Module
|
|
180
|
+
// Namespace Exotic Object never succeed — and the
|
|
181
|
+
// proxy target itself remains extensible
|
|
182
|
+
// (architecturally we cannot freeze it up-front),
|
|
183
|
+
// so without these traps `ns.notExported = "x"`
|
|
184
|
+
// after evaluation would silently create a property
|
|
185
|
+
// on the target instead of returning false.
|
|
147
186
|
"delete handler.get;",
|
|
148
187
|
"delete handler.has;",
|
|
149
188
|
"delete handler.ownKeys;",
|
|
@@ -153,13 +192,58 @@ class MakeDeferredNamespaceObjectRuntimeModule extends HelperRuntimeModule {
|
|
|
153
192
|
Template.indent([
|
|
154
193
|
`ns = ${RuntimeGlobals.createFakeNamespaceObject}(ns, mode);`
|
|
155
194
|
]),
|
|
195
|
+
"}",
|
|
196
|
+
// Mirror own properties from the resolved namespace onto the proxy
|
|
197
|
+
// target so that proxy invariants hold for callers that structurally
|
|
198
|
+
// introspect via `Object.keys` / `Object.getOwnPropertyNames` /
|
|
199
|
+
// `Object.getOwnPropertyDescriptor`: when our trap reports a
|
|
200
|
+
// non-configurable descriptor for a key, the target must also have
|
|
201
|
+
// that key with a matching descriptor.
|
|
202
|
+
//
|
|
203
|
+
// `__esModule` and `Symbol.toStringTag` are intentionally skipped:
|
|
204
|
+
// the proxy synthesizes "Deferred Module" / true regardless of what
|
|
205
|
+
// the underlying namespace exposes (per the TC39 import-defer
|
|
206
|
+
// proposal, the [[StringTag]] of a Deferred Module Namespace
|
|
207
|
+
// Exotic Object is "Deferred Module"), and the target was already
|
|
208
|
+
// pre-populated with those values below.
|
|
209
|
+
"var keys = Reflect.ownKeys(ns);",
|
|
210
|
+
"for (var i = 0; i < keys.length; i++) {",
|
|
211
|
+
Template.indent([
|
|
212
|
+
"var k = keys[i];",
|
|
213
|
+
'if (k === "__esModule" || k === Symbol.toStringTag) continue;',
|
|
214
|
+
"if (!Object.prototype.hasOwnProperty.call(ns_target, k)) {",
|
|
215
|
+
Template.indent([
|
|
216
|
+
"try { Object.defineProperty(ns_target, k, Reflect.getOwnPropertyDescriptor(ns, k)); } catch (_) {}"
|
|
217
|
+
]),
|
|
218
|
+
"}"
|
|
219
|
+
]),
|
|
156
220
|
"}"
|
|
157
221
|
])};`,
|
|
158
222
|
"",
|
|
159
|
-
|
|
223
|
+
// The proxy target is a fresh placeholder, separate from
|
|
224
|
+
// `__webpack_module_deferred_exports__[moduleId]` (which is reused
|
|
225
|
+
// by `__webpack_require__` as `module.exports` for deferred-loaded
|
|
226
|
+
// modules and would conflict with our pre-populated synthetic
|
|
227
|
+
// `__esModule` / `Symbol.toStringTag` non-configurable properties).
|
|
228
|
+
// Using a dedicated target keeps the proxy invariant-compliant
|
|
229
|
+
// without interfering with the module's own exports object.
|
|
230
|
+
"var ns_target = { __proto__: null };",
|
|
231
|
+
// Pre-populate the synthetic deferred-namespace properties with
|
|
232
|
+
// fully non-configurable, non-writable, non-enumerable descriptors
|
|
233
|
+
// (matching the TC39 import-defer spec for Module Namespace
|
|
234
|
+
// Exotic Objects). The trap returns the same descriptors below.
|
|
235
|
+
'Object.defineProperty(ns_target, "__esModule", { value: true });',
|
|
236
|
+
'Object.defineProperty(ns_target, Symbol.toStringTag, { value: "Deferred Module" });',
|
|
237
|
+
"var ns = ns_target;",
|
|
160
238
|
"var handler = {",
|
|
161
239
|
Template.indent([
|
|
162
240
|
"__proto__: null,",
|
|
241
|
+
// Per the TC39 import-defer proposal, `IsSymbolLikeNamespaceKey`
|
|
242
|
+
// returns true for any Symbol-keyed access (and for "then"); such
|
|
243
|
+
// accesses go through `OrdinaryGetOwnProperty` and must not
|
|
244
|
+
// trigger evaluation of the deferred module. The Symbol checks
|
|
245
|
+
// below short-circuit to the pre-populated target without
|
|
246
|
+
// running `init()`.
|
|
163
247
|
`get: ${runtimeTemplate.basicFunction("_, name", [
|
|
164
248
|
"switch (name) {",
|
|
165
249
|
Template.indent([
|
|
@@ -168,6 +252,7 @@ class MakeDeferredNamespaceObjectRuntimeModule extends HelperRuntimeModule {
|
|
|
168
252
|
'case "then": return undefined;'
|
|
169
253
|
]),
|
|
170
254
|
"}",
|
|
255
|
+
'if (typeof name === "symbol") return ns_target[name];',
|
|
171
256
|
init,
|
|
172
257
|
"return ns[name];"
|
|
173
258
|
])},`,
|
|
@@ -186,6 +271,7 @@ class MakeDeferredNamespaceObjectRuntimeModule extends HelperRuntimeModule {
|
|
|
186
271
|
].filter(Boolean)
|
|
187
272
|
),
|
|
188
273
|
"}",
|
|
274
|
+
'if (typeof name === "symbol") return name in ns_target;',
|
|
189
275
|
init,
|
|
190
276
|
"return name in ns;"
|
|
191
277
|
])},`,
|
|
@@ -197,11 +283,16 @@ class MakeDeferredNamespaceObjectRuntimeModule extends HelperRuntimeModule {
|
|
|
197
283
|
`getOwnPropertyDescriptor: ${runtimeTemplate.basicFunction("_, name", [
|
|
198
284
|
"switch (name) {",
|
|
199
285
|
Template.indent([
|
|
200
|
-
|
|
201
|
-
|
|
286
|
+
// Match the descriptors actually defined on `ns_target`
|
|
287
|
+
// (non-configurable, non-writable, non-enumerable) so the
|
|
288
|
+
// proxy invariant holds for both the trap result and any
|
|
289
|
+
// post-init forwarding via the deleted-handler path.
|
|
290
|
+
'case "__esModule": return { value: true, writable: false, enumerable: false, configurable: false };',
|
|
291
|
+
'case Symbol.toStringTag: return { value: "Deferred Module", writable: false, enumerable: false, configurable: false };',
|
|
202
292
|
'case "then": return undefined;'
|
|
203
293
|
]),
|
|
204
294
|
"}",
|
|
295
|
+
'if (typeof name === "symbol") return Reflect.getOwnPropertyDescriptor(ns_target, name);',
|
|
205
296
|
init,
|
|
206
297
|
"var desc = Reflect.getOwnPropertyDescriptor(ns, name);",
|
|
207
298
|
'if (mode & 2 && name == "default" && !desc) {',
|
|
@@ -209,18 +300,33 @@ class MakeDeferredNamespaceObjectRuntimeModule extends HelperRuntimeModule {
|
|
|
209
300
|
"}",
|
|
210
301
|
"return desc;"
|
|
211
302
|
])},`,
|
|
303
|
+
// `defineProperty` always rejects, but per the TC39 spec it
|
|
304
|
+
// must still trigger evaluation for string keys (the spec
|
|
305
|
+
// algorithm calls `[[GetOwnProperty]]` first, which forces
|
|
306
|
+
// evaluation on a deferred namespace). Symbol keys go through
|
|
307
|
+
// OrdinaryDefineOwnProperty and do not trigger eval.
|
|
212
308
|
`defineProperty: ${runtimeTemplate.basicFunction("_, name", [
|
|
309
|
+
'if (typeof name === "symbol" || name === "then") return false;',
|
|
310
|
+
init,
|
|
311
|
+
"return false;"
|
|
312
|
+
])},`,
|
|
313
|
+
// `deleteProperty` rejects, but per the TC39 spec it must
|
|
314
|
+
// still trigger evaluation for string keys (the spec
|
|
315
|
+
// algorithm calls `GetModuleExportsList` for non-symbol-like
|
|
316
|
+
// keys, forcing evaluation on a deferred namespace).
|
|
317
|
+
`deleteProperty: ${runtimeTemplate.basicFunction("_, name", [
|
|
318
|
+
'if (typeof name === "symbol" || name === "then") return false;',
|
|
213
319
|
init,
|
|
214
|
-
// Note: This behavior does not match the spec one, but since webpack does not do it either
|
|
215
|
-
// for a normal Module Namespace object (in MakeNamespaceObjectRuntimeModule), let's keep it simple.
|
|
216
320
|
"return false;"
|
|
217
321
|
])},`,
|
|
218
|
-
`
|
|
322
|
+
// `set` always returns false without triggering evaluation —
|
|
323
|
+
// the spec [[Set]] algorithm for Module Namespaces is just
|
|
324
|
+
// "return false" (no [[GetOwnProperty]], no eval).
|
|
219
325
|
`set: ${runtimeTemplate.returningFunction("false")},`
|
|
220
326
|
]),
|
|
221
327
|
"}",
|
|
222
328
|
// we don't fully emulate ES Module semantics in this Proxy to align with normal webpack esm namespace object.
|
|
223
|
-
"return new Proxy(
|
|
329
|
+
"return byMode[mode] = new Proxy(ns_target, handler);"
|
|
224
330
|
])};`;
|
|
225
331
|
}
|
|
226
332
|
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/*
|
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
"use strict";
|
|
6
|
+
|
|
7
|
+
const RuntimeGlobals = require("../RuntimeGlobals");
|
|
8
|
+
const Template = require("../Template");
|
|
9
|
+
const HelperRuntimeModule = require("./HelperRuntimeModule");
|
|
10
|
+
|
|
11
|
+
/** @typedef {import("../Compilation")} Compilation */
|
|
12
|
+
|
|
13
|
+
class SetAnonymousDefaultNameRuntimeModule extends HelperRuntimeModule {
|
|
14
|
+
constructor() {
|
|
15
|
+
super("set anonymous default export name");
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Generates runtime code for this runtime module.
|
|
20
|
+
* @returns {string | null} runtime code
|
|
21
|
+
*/
|
|
22
|
+
generate() {
|
|
23
|
+
const compilation = /** @type {Compilation} */ (this.compilation);
|
|
24
|
+
const { runtimeTemplate } = compilation;
|
|
25
|
+
const fn = RuntimeGlobals.setAnonymousDefaultName;
|
|
26
|
+
return Template.asString([
|
|
27
|
+
"// set .name for anonymous default exports per ES spec",
|
|
28
|
+
`${fn} = ${runtimeTemplate.basicFunction("x", [
|
|
29
|
+
'(Object.getOwnPropertyDescriptor(x, "name") || {}).writable || Object.defineProperty(x, "name", { value: "default", configurable: true });'
|
|
30
|
+
])};`
|
|
31
|
+
]);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
module.exports = SetAnonymousDefaultNameRuntimeModule;
|
|
@@ -24,7 +24,7 @@ class DataUriPlugin {
|
|
|
24
24
|
(compilation, { normalModuleFactory }) => {
|
|
25
25
|
normalModuleFactory.hooks.resolveForScheme
|
|
26
26
|
.for("data")
|
|
27
|
-
.tap(PLUGIN_NAME, (resourceData) => {
|
|
27
|
+
.tap(PLUGIN_NAME, (resourceData, resolveData) => {
|
|
28
28
|
const match = URIRegEx.exec(resourceData.resource);
|
|
29
29
|
if (match) {
|
|
30
30
|
resourceData.data.mimetype = match[1] || "";
|
|
@@ -34,6 +34,18 @@ class DataUriPlugin {
|
|
|
34
34
|
);
|
|
35
35
|
resourceData.data.encodedContent = match[4] || "";
|
|
36
36
|
}
|
|
37
|
+
// Inherit the issuer's resolution context so any nested
|
|
38
|
+
// dependencies discovered while parsing the data URI's body
|
|
39
|
+
// (e.g. `url(...)` / `@import` inside an inline CSS data
|
|
40
|
+
// URI) resolve relative to where the URI was referenced
|
|
41
|
+
// from, instead of against the synthetic `data:.../` path
|
|
42
|
+
// that `getContext("data:…")` would otherwise infer.
|
|
43
|
+
if (
|
|
44
|
+
resourceData.context === undefined &&
|
|
45
|
+
resolveData.context !== undefined
|
|
46
|
+
) {
|
|
47
|
+
resourceData.context = resolveData.context;
|
|
48
|
+
}
|
|
37
49
|
});
|
|
38
50
|
|
|
39
51
|
NormalModule.getCompilationHooks(compilation)
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
|
|
8
8
|
const { getContext } = require("loader-runner");
|
|
9
9
|
|
|
10
|
-
const ModuleNotFoundError = require("../ModuleNotFoundError");
|
|
11
10
|
const NormalModule = require("../NormalModule");
|
|
11
|
+
const ModuleNotFoundError = require("../errors/ModuleNotFoundError");
|
|
12
12
|
const { isAbsolute, join } = require("../util/fs");
|
|
13
13
|
const { parseResourceWithoutFragment } = require("../util/identifier");
|
|
14
14
|
|
|
@@ -37,7 +37,7 @@ class SerializerMiddleware {
|
|
|
37
37
|
* @returns {SerializedType | Promise<SerializedType> | null} serialized data
|
|
38
38
|
*/
|
|
39
39
|
serialize(data, context) {
|
|
40
|
-
const AbstractMethodError = require("../AbstractMethodError");
|
|
40
|
+
const AbstractMethodError = require("../errors/AbstractMethodError");
|
|
41
41
|
|
|
42
42
|
throw new AbstractMethodError();
|
|
43
43
|
}
|
|
@@ -51,7 +51,7 @@ class SerializerMiddleware {
|
|
|
51
51
|
* @returns {DeserializedType | Promise<DeserializedType>} deserialized data
|
|
52
52
|
*/
|
|
53
53
|
deserialize(data, context) {
|
|
54
|
-
const AbstractMethodError = require("../AbstractMethodError");
|
|
54
|
+
const AbstractMethodError = require("../errors/AbstractMethodError");
|
|
55
55
|
|
|
56
56
|
throw new AbstractMethodError();
|
|
57
57
|
}
|
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
|
|
6
6
|
"use strict";
|
|
7
7
|
|
|
8
|
-
const ModuleNotFoundError = require("../ModuleNotFoundError");
|
|
9
8
|
const RuntimeGlobals = require("../RuntimeGlobals");
|
|
10
|
-
const WebpackError = require("../WebpackError");
|
|
11
9
|
const { parseOptions } = require("../container/options");
|
|
10
|
+
const ModuleNotFoundError = require("../errors/ModuleNotFoundError");
|
|
11
|
+
const WebpackError = require("../errors/WebpackError");
|
|
12
12
|
const LazySet = require("../util/LazySet");
|
|
13
13
|
const { parseRange } = require("../util/semver");
|
|
14
14
|
const ConsumeSharedFallbackDependency = require("./ConsumeSharedFallbackDependency");
|
|
@@ -356,15 +356,9 @@ class ConsumeSharedPlugin {
|
|
|
356
356
|
) {
|
|
357
357
|
return Promise.resolve();
|
|
358
358
|
}
|
|
359
|
-
const options = resolvedConsumes.get(
|
|
360
|
-
/** @type {string} */ (resource)
|
|
361
|
-
);
|
|
359
|
+
const options = resolvedConsumes.get(resource);
|
|
362
360
|
if (options !== undefined) {
|
|
363
|
-
return createConsumeSharedModule(
|
|
364
|
-
context,
|
|
365
|
-
/** @type {string} */ (resource),
|
|
366
|
-
options
|
|
367
|
-
);
|
|
361
|
+
return createConsumeSharedModule(context, resource, options);
|
|
368
362
|
}
|
|
369
363
|
return Promise.resolve();
|
|
370
364
|
}
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
const RuntimeGlobals = require("../RuntimeGlobals");
|
|
9
9
|
const RuntimeModule = require("../RuntimeModule");
|
|
10
10
|
const Template = require("../Template");
|
|
11
|
+
const { compareModulesById } = require("../util/comparators");
|
|
11
12
|
const {
|
|
12
13
|
parseVersionRuntimeCode,
|
|
13
14
|
rangeToStringRuntimeCode,
|
|
@@ -71,12 +72,14 @@ class ConsumeSharedRuntimeModule extends RuntimeModule {
|
|
|
71
72
|
);
|
|
72
73
|
}
|
|
73
74
|
};
|
|
75
|
+
const byId = compareModulesById(chunkGraph);
|
|
74
76
|
for (const chunk of /** @type {Chunk} */ (
|
|
75
77
|
this.chunk
|
|
76
78
|
).getAllReferencedChunks()) {
|
|
77
|
-
const modules = chunkGraph.
|
|
79
|
+
const modules = chunkGraph.getOrderedChunkModulesIterableBySourceType(
|
|
78
80
|
chunk,
|
|
79
|
-
"consume-shared"
|
|
81
|
+
"consume-shared",
|
|
82
|
+
byId
|
|
80
83
|
);
|
|
81
84
|
if (!modules) continue;
|
|
82
85
|
addModules(
|
|
@@ -88,9 +91,10 @@ class ConsumeSharedRuntimeModule extends RuntimeModule {
|
|
|
88
91
|
for (const chunk of /** @type {Chunk} */ (
|
|
89
92
|
this.chunk
|
|
90
93
|
).getAllInitialChunks()) {
|
|
91
|
-
const modules = chunkGraph.
|
|
94
|
+
const modules = chunkGraph.getOrderedChunkModulesIterableBySourceType(
|
|
92
95
|
chunk,
|
|
93
|
-
"consume-shared"
|
|
96
|
+
"consume-shared",
|
|
97
|
+
byId
|
|
94
98
|
);
|
|
95
99
|
if (!modules) continue;
|
|
96
100
|
addModules(modules, chunk, initialConsumes);
|
|
@@ -54,7 +54,7 @@ class ProvideSharedModule extends Module {
|
|
|
54
54
|
* @returns {string} a unique identifier of the module
|
|
55
55
|
*/
|
|
56
56
|
identifier() {
|
|
57
|
-
return `provide module (${this._shareScope}) ${this._name}@${this._version}
|
|
57
|
+
return `provide module (${this._shareScope}) ${this._name}@${this._version}|${this._request}`;
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
/**
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
|
|
6
6
|
"use strict";
|
|
7
7
|
|
|
8
|
-
const WebpackError = require("../WebpackError");
|
|
9
8
|
const { parseOptions } = require("../container/options");
|
|
9
|
+
const WebpackError = require("../errors/WebpackError");
|
|
10
10
|
const ProvideForSharedDependency = require("./ProvideForSharedDependency");
|
|
11
11
|
const ProvideSharedDependency = require("./ProvideSharedDependency");
|
|
12
12
|
const ProvideSharedModuleFactory = require("./ProvideSharedModuleFactory");
|
|
@@ -169,7 +169,7 @@ class ProvideSharedPlugin {
|
|
|
169
169
|
normalModuleFactory.hooks.module.tap(
|
|
170
170
|
PLUGIN_NAME,
|
|
171
171
|
(module, { resource, resourceResolveData }, resolveData) => {
|
|
172
|
-
if (resolvedProvideMap.has(
|
|
172
|
+
if (resolvedProvideMap.has(resource)) {
|
|
173
173
|
return module;
|
|
174
174
|
}
|
|
175
175
|
const { request } = resolveData;
|
|
@@ -179,7 +179,7 @@ class ProvideSharedPlugin {
|
|
|
179
179
|
provideSharedModule(
|
|
180
180
|
request,
|
|
181
181
|
config,
|
|
182
|
-
|
|
182
|
+
resource,
|
|
183
183
|
resourceResolveData
|
|
184
184
|
);
|
|
185
185
|
resolveData.cacheable = false;
|
|
@@ -189,12 +189,12 @@ class ProvideSharedPlugin {
|
|
|
189
189
|
if (request.startsWith(prefix)) {
|
|
190
190
|
const remainder = request.slice(prefix.length);
|
|
191
191
|
provideSharedModule(
|
|
192
|
-
|
|
192
|
+
resource,
|
|
193
193
|
{
|
|
194
194
|
...config,
|
|
195
195
|
shareKey: config.shareKey + remainder
|
|
196
196
|
},
|
|
197
|
-
|
|
197
|
+
resource,
|
|
198
198
|
resourceResolveData
|
|
199
199
|
);
|
|
200
200
|
resolveData.cacheable = false;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
"use strict";
|
|
7
7
|
|
|
8
|
-
const ModuleNotFoundError = require("../ModuleNotFoundError");
|
|
8
|
+
const ModuleNotFoundError = require("../errors/ModuleNotFoundError");
|
|
9
9
|
const LazySet = require("../util/LazySet");
|
|
10
10
|
|
|
11
11
|
/** @typedef {import("enhanced-resolve").ResolveContext} ResolveContext */
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
const util = require("util");
|
|
9
9
|
const { WEBPACK_MODULE_TYPE_RUNTIME } = require("../ModuleTypeConstants");
|
|
10
10
|
const ModuleDependency = require("../dependencies/ModuleDependency");
|
|
11
|
-
const formatLocation = require("../formatLocation");
|
|
12
11
|
const { LogType } = require("../logging/Logger");
|
|
13
12
|
const AggressiveSplittingPlugin = require("../optimize/AggressiveSplittingPlugin");
|
|
14
13
|
const SizeLimitsPlugin = require("../performance/SizeLimitsPlugin");
|
|
@@ -22,6 +21,7 @@ const {
|
|
|
22
21
|
compareSelect,
|
|
23
22
|
concatComparators
|
|
24
23
|
} = require("../util/comparators");
|
|
24
|
+
const formatLocation = require("../util/formatLocation");
|
|
25
25
|
const { makePathsRelative, parseResource } = require("../util/identifier");
|
|
26
26
|
|
|
27
27
|
/** @typedef {import("webpack-sources").Source} Source */
|
|
@@ -48,7 +48,7 @@ const { makePathsRelative, parseResource } = require("../util/identifier");
|
|
|
48
48
|
/** @typedef {import("../Module").BuildInfo} BuildInfo */
|
|
49
49
|
/** @typedef {import("../ModuleGraphConnection")} ModuleGraphConnection */
|
|
50
50
|
/** @typedef {import("../ModuleProfile")} ModuleProfile */
|
|
51
|
-
/** @typedef {import("../WebpackError")} WebpackError */
|
|
51
|
+
/** @typedef {import("../errors/WebpackError")} WebpackError */
|
|
52
52
|
/** @typedef {import("../serialization/AggregateErrorSerializer").AggregateError} AggregateError */
|
|
53
53
|
/** @typedef {import("../serialization/ErrorObjectSerializer").ErrorWithCause} ErrorWithCause */
|
|
54
54
|
/** @typedef {import("../ExportsInfo").ExportInfoName} ExportInfoName */
|
|
@@ -31,7 +31,7 @@ const applyDefaults = (options, defaults) => {
|
|
|
31
31
|
}
|
|
32
32
|
};
|
|
33
33
|
|
|
34
|
-
/** @typedef {{ [Key in Exclude<StatsValue, boolean |
|
|
34
|
+
/** @typedef {{ [Key in Exclude<StatsValue, boolean | StatsOptions | "normal">]: StatsOptions }} NamedPresets */
|
|
35
35
|
|
|
36
36
|
/** @type {NamedPresets} */
|
|
37
37
|
const NAMED_PRESETS = {
|
|
@@ -1510,7 +1510,7 @@ const AVAILABLE_FORMATS = {
|
|
|
1510
1510
|
(oversize ? yellow : green)(filename),
|
|
1511
1511
|
formatFlag: (flag) => `[${flag}]`,
|
|
1512
1512
|
formatLayer: (layer) => `(in ${layer})`,
|
|
1513
|
-
formatSize: require("../
|
|
1513
|
+
formatSize: require("../util/formatSize"),
|
|
1514
1514
|
formatDateTime: (dateTime, { bold }) => {
|
|
1515
1515
|
const d = new Date(dateTime);
|
|
1516
1516
|
const x = twoDigit;
|
|
@@ -18,7 +18,7 @@ const smartGrouping = require("../util/smartGrouping");
|
|
|
18
18
|
/** @typedef {import("../Module")} Module */
|
|
19
19
|
/** @typedef {import("../ModuleGraph").ModuleProfile} ModuleProfile */
|
|
20
20
|
/** @typedef {import("../ModuleGraphConnection")} ModuleGraphConnection */
|
|
21
|
-
/** @typedef {import("../WebpackError")} WebpackError */
|
|
21
|
+
/** @typedef {import("../errors/WebpackError")} WebpackError */
|
|
22
22
|
/** @typedef {import("../util/comparators").Comparator<EXPECTED_ANY>} Comparator */
|
|
23
23
|
/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
|
|
24
24
|
/**
|