webpack 5.111.0 → 5.111.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/lib/APIPlugin.js +3 -4
- package/lib/CompatibilityPlugin.js +3 -4
- package/lib/Compilation.js +16 -35
- package/lib/Compiler.js +4 -5
- package/lib/ConstPlugin.js +16 -132
- package/lib/DependencyTemplate.js +2 -1
- package/lib/DotenvPlugin.js +24 -28
- package/lib/ErrorHelpers.js +113 -0
- package/lib/ExportsInfo.js +20 -16
- package/lib/ExternalModule.js +6 -8
- package/lib/FlagDependencyExportsPlugin.js +8 -13
- package/lib/FlagDependencyUsagePlugin.js +9 -13
- package/lib/Generator.js +24 -2
- package/lib/HotModuleReplacementPlugin.js +2 -0
- package/lib/IgnorePlugin.js +1 -1
- package/lib/LoaderOptionsPlugin.js +1 -1
- package/lib/Module.js +3 -3
- package/lib/ModuleGraph.js +6 -9
- package/lib/MultiCompiler.js +6 -16
- package/lib/NormalModule.js +96 -44
- package/lib/RuntimeTemplate.js +33 -43
- package/lib/SourceMapDevToolPlugin.js +53 -103
- package/lib/TemplatedPathPlugin.js +16 -59
- package/lib/asset/AssetBytesGenerator.js +7 -1
- package/lib/asset/AssetGenerator.js +25 -16
- package/lib/asset/AssetSourceGenerator.js +7 -1
- package/lib/buildChunkGraph.js +11 -15
- package/lib/cache/MemoryCachePlugin.js +4 -4
- package/lib/cache/MemoryWithGcCachePlugin.js +7 -8
- package/lib/cache/PackFileCacheStrategy.js +3 -18
- package/lib/cache/getLazyHashedEtag.js +3 -5
- package/lib/config/browserslistTargetHandler.js +2 -8
- package/lib/config/defaults.js +52 -78
- package/lib/config/getClaimedAssetTypes.js +10 -11
- package/lib/config/target.js +3 -4
- package/lib/{ContextExclusionPlugin.js → context/ContextExclusionPlugin.js} +1 -1
- package/lib/{ContextModule.js → context/ContextModule.js} +37 -34
- package/lib/{ContextModuleFactory.js → context/ContextModuleFactory.js} +19 -21
- package/lib/{ContextReplacementPlugin.js → context/ContextReplacementPlugin.js} +4 -4
- package/lib/css/CssGenerator.js +19 -11
- package/lib/css/CssParser.js +18 -20
- package/lib/css/cssMinify.js +32 -29
- package/lib/css/data.js +797 -288
- package/lib/css/syntax.js +2250 -934
- package/lib/debug/ProfilingPlugin.js +3 -4
- package/lib/dependencies/CommonJsExportRequireDependency.js +10 -11
- package/lib/dependencies/CommonJsImportsParserPlugin.js +4 -5
- package/lib/dependencies/CommonJsSelfReferenceDependency.js +2 -4
- package/lib/dependencies/ContextDependency.js +1 -1
- package/lib/dependencies/ContextDependencyHelpers.js +3 -9
- package/lib/dependencies/ContextElementDependency.js +1 -1
- package/lib/dependencies/CssIcssExportDependency.js +6 -8
- package/lib/dependencies/CssIcssImportDependency.js +3 -6
- package/lib/dependencies/CssUrlDependency.js +3 -5
- package/lib/dependencies/HarmonyCompatibilityDependency.js +11 -20
- package/lib/dependencies/HarmonyDetectionParserPlugin.js +3 -4
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +2 -4
- package/lib/dependencies/HarmonyExportExpressionDependency.js +3 -4
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +3 -4
- package/lib/dependencies/HarmonyExportInitFragment.js +26 -19
- package/lib/dependencies/HarmonyExportSpecifierDependency.js +7 -28
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +103 -16
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +3 -4
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +16 -2
- package/lib/dependencies/HtmlEntryDependency.js +74 -102
- package/lib/dependencies/HtmlInlineScriptDependency.js +3 -4
- package/lib/dependencies/HtmlInlineStyleDependency.js +3 -4
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +1 -1
- package/lib/dependencies/ImportMetaGlobHelpers.js +1 -1
- package/lib/dependencies/ImportMetaPlugin.js +8 -10
- package/lib/dependencies/ImportParserPlugin.js +1 -1
- package/lib/dependencies/LoaderPlugin.js +26 -1
- package/lib/dependencies/RequireContextDependencyParserPlugin.js +1 -1
- package/lib/dependencies/URLContextDependency.js +1 -1
- package/lib/dependencies/URLDependency.js +6 -5
- package/lib/dependencies/WorkerAndWorkletPlugin.js +15 -21
- package/lib/dependencies/WorkerDependency.js +6 -5
- package/lib/dependencies/WorkletDependency.js +6 -9
- package/lib/errors/HookWebpackError.js +3 -2
- package/lib/hmr/LazyCompilationPlugin.js +3 -5
- package/lib/html/HtmlGenerator.js +61 -82
- package/lib/html/HtmlModulesPlugin.js +88 -139
- package/lib/html/HtmlParser.js +97 -141
- package/lib/html/data.js +21 -0
- package/lib/html/htmlMinify.js +10 -11
- package/lib/html/syntax.js +883 -993
- package/lib/index.js +46 -3
- package/lib/javascript/ChunkFormatHelpers.js +4 -3
- package/lib/javascript/JavascriptGenerator.js +8 -1
- package/lib/javascript/JavascriptModulesPlugin.js +21 -48
- package/lib/javascript/JavascriptParser.js +721 -178
- package/lib/javascript/parser.js +6 -0
- package/lib/javascript/syntax.js +420 -92
- package/lib/json/JsonGenerator.js +7 -1
- package/lib/library/ModuleLibraryPlugin.js +64 -136
- package/lib/loaders/LoaderRunner.js +137 -9
- package/lib/node/NodeWatchFileSystem.js +3 -9
- package/lib/optimize/AggressiveMergingPlugin.js +3 -5
- package/lib/optimize/ConcatenatedModule.js +81 -100
- package/lib/optimize/FlagIncludedChunksPlugin.js +3 -11
- package/lib/optimize/InnerGraphPlugin.js +7 -13
- package/lib/optimize/LimitChunkCountPlugin.js +5 -8
- package/lib/optimize/MangleExportsPlugin.js +3 -4
- package/lib/optimize/ModuleConcatenationPlugin.js +3 -4
- package/lib/optimize/SideEffectsFlagPlugin.js +7 -19
- package/lib/optimize/SplitChunksPlugin.js +2 -4
- package/lib/performance/BroadContextsPlugin.js +1 -1
- package/lib/performance/CacheEffectivenessPlugin.js +3 -4
- package/lib/performance/SizeLimitsPlugin.js +2 -4
- package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +6 -8
- package/lib/prefetch/ResourceHintPlugin.js +17 -21
- package/lib/prefetch/StartupAssetHintRuntimeModule.js +7 -10
- package/lib/runtime/AsyncModuleRuntimeModule.js +3 -5
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +3 -4
- package/lib/runtime/GlobalRuntimeModule.js +2 -4
- package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +55 -85
- package/lib/schemes/DataUriPlugin.js +3 -6
- package/lib/schemes/VirtualUrlPlugin.js +1 -1
- package/lib/serialization/BinaryMiddleware.js +9 -9
- package/lib/serialization/FileMiddleware.js +16 -16
- package/lib/serialization/ObjectMiddleware.js +30 -33
- package/lib/stats/DefaultStatsFactoryPlugin.js +3 -4
- package/lib/typescript/TypeScriptPlugin.js +2 -3
- package/lib/url/URLParserPlugin.js +6 -8
- package/lib/util/LocConverter.js +4 -7
- package/lib/util/SourceProcessor.js +15 -22
- package/lib/util/chainedImports.js +3 -4
- package/lib/util/concatenate.js +4 -4
- package/lib/util/createHooksRegistry.js +1 -2
- package/lib/util/dataURL.js +2 -3
- package/lib/util/deterministicGrouping.js +8 -13
- package/lib/util/findGraphRoots.js +6 -13
- package/lib/util/globUtils.js +1 -1
- package/lib/util/hash/wasm-hash.js +3 -4
- package/lib/util/internalSerializables.js +1 -1
- package/lib/util/semver.js +5 -3
- package/lib/wasm-async/AsyncWebAssemblyGenerator.js +6 -1
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +5 -1
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +3 -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/package.json +30 -23
- package/types.d.ts +299 -280
package/lib/index.js
CHANGED
|
@@ -38,7 +38,7 @@ const memoize = require("./util/memoize");
|
|
|
38
38
|
/** @typedef {import("./asset/AssetModule").AssetModuleBuildInfo} AssetModuleBuildInfo */
|
|
39
39
|
/** @typedef {import("./ChunkGroup")} ChunkGroup */
|
|
40
40
|
/** @typedef {import("./Compiler").AssetEmittedInfo} AssetEmittedInfo */
|
|
41
|
-
/** @typedef {import("./ContextModule").ContextModuleBuildInfo} ContextModuleBuildInfo */
|
|
41
|
+
/** @typedef {import("./context/ContextModule").ContextModuleBuildInfo} ContextModuleBuildInfo */
|
|
42
42
|
/** @typedef {import("./css/CssModule").CssModuleBuildInfo} CssModuleBuildInfo */
|
|
43
43
|
/** @typedef {import("./css/CssModule").CssModuleBuildMeta} CssModuleBuildMeta */
|
|
44
44
|
/** @typedef {import("./ExternalModule").ExternalModuleBuildInfo} ExternalModuleBuildInfo */
|
|
@@ -237,10 +237,10 @@ module.exports = mergeExports(fn, {
|
|
|
237
237
|
return require("./ConcatenationScope");
|
|
238
238
|
},
|
|
239
239
|
get ContextExclusionPlugin() {
|
|
240
|
-
return require("./ContextExclusionPlugin");
|
|
240
|
+
return require("./context/ContextExclusionPlugin");
|
|
241
241
|
},
|
|
242
242
|
get ContextReplacementPlugin() {
|
|
243
|
-
return require("./ContextReplacementPlugin");
|
|
243
|
+
return require("./context/ContextReplacementPlugin");
|
|
244
244
|
},
|
|
245
245
|
get CopyPlugin() {
|
|
246
246
|
return require("./CopyPlugin");
|
|
@@ -743,3 +743,46 @@ module.exports = mergeExports(fn, {
|
|
|
743
743
|
}
|
|
744
744
|
}
|
|
745
745
|
});
|
|
746
|
+
|
|
747
|
+
/**
|
|
748
|
+
* The loader-authoring types, re-exported here because this file is what
|
|
749
|
+
* `generate-types.js` reads webpack's public type surface from
|
|
750
|
+
* @template [OptionsType={}]
|
|
751
|
+
* @template [ContextAdditions={}]
|
|
752
|
+
* @typedef {import("./loaders/LoaderRunner").LoaderModule<OptionsType, ContextAdditions>} LoaderModule
|
|
753
|
+
*/
|
|
754
|
+
|
|
755
|
+
/**
|
|
756
|
+
* @template [OptionsType={}]
|
|
757
|
+
* @template [ContextAdditions={}]
|
|
758
|
+
* @typedef {import("./loaders/LoaderRunner").RawLoaderDefinition<OptionsType, ContextAdditions>} RawLoaderDefinition
|
|
759
|
+
*/
|
|
760
|
+
|
|
761
|
+
/**
|
|
762
|
+
* @template [OptionsType={}]
|
|
763
|
+
* @template [ContextAdditions={}]
|
|
764
|
+
* @typedef {import("./loaders/LoaderRunner").LoaderDefinition<OptionsType, ContextAdditions>} LoaderDefinition
|
|
765
|
+
*/
|
|
766
|
+
|
|
767
|
+
/**
|
|
768
|
+
* @template [OptionsType={}]
|
|
769
|
+
* @template [ContextAdditions={}]
|
|
770
|
+
* @typedef {import("./loaders/LoaderRunner").LoaderDefinitionFunction<OptionsType, ContextAdditions>} LoaderDefinitionFunction
|
|
771
|
+
*/
|
|
772
|
+
|
|
773
|
+
/**
|
|
774
|
+
* @template [OptionsType={}]
|
|
775
|
+
* @template [ContextAdditions={}]
|
|
776
|
+
* @typedef {import("./loaders/LoaderRunner").PitchLoaderDefinitionFunction<OptionsType, ContextAdditions>} PitchLoaderDefinitionFunction
|
|
777
|
+
*/
|
|
778
|
+
|
|
779
|
+
/**
|
|
780
|
+
* @template [OptionsType={}]
|
|
781
|
+
* @template [ContextAdditions={}]
|
|
782
|
+
* @typedef {import("./loaders/LoaderRunner").RawLoaderDefinitionFunction<OptionsType, ContextAdditions>} RawLoaderDefinitionFunction
|
|
783
|
+
*/
|
|
784
|
+
|
|
785
|
+
/**
|
|
786
|
+
* @template OptionsType
|
|
787
|
+
* @typedef {import("./NormalModule").LoaderContext<OptionsType>} LoaderContext
|
|
788
|
+
*/
|
|
@@ -55,10 +55,11 @@ function createChunkHashHandler(name) {
|
|
|
55
55
|
hash.update(name);
|
|
56
56
|
hash.update("1");
|
|
57
57
|
if (runtimeChunk && runtimeChunk.hash) {
|
|
58
|
-
//
|
|
59
|
-
//
|
|
60
|
-
//
|
|
58
|
+
// WHY: any change to the runtime chunk must move this hash, and its
|
|
59
|
+
// internal implementation is not ours to depend on or inspect — the import
|
|
60
|
+
// names its hashed filename:
|
|
61
61
|
// import __webpack_require__ from "./runtime-main.e9400aee33633a3973bd.js";
|
|
62
|
+
// https://github.com/webpack/webpack/issues/19439
|
|
62
63
|
hash.update(runtimeChunk.hash);
|
|
63
64
|
}
|
|
64
65
|
updateHashForEntryStartup(hash, chunkGraph, entries, chunk);
|
|
@@ -256,6 +256,7 @@ class JavascriptGenerator extends Generator {
|
|
|
256
256
|
/** @type {NonNullable<GenerateContext["codeGenerationResults"]>} */
|
|
257
257
|
(generateContext.codeGenerationResults),
|
|
258
258
|
initFragments,
|
|
259
|
+
getData: generateContext.getData,
|
|
259
260
|
get chunkInitFragments() {
|
|
260
261
|
if (!chunkInitFragments) {
|
|
261
262
|
const data =
|
|
@@ -332,7 +333,13 @@ class JavascriptGenerator extends Generator {
|
|
|
332
333
|
* @returns {Source | null} generated code
|
|
333
334
|
*/
|
|
334
335
|
generateError(error, module, generateContext) {
|
|
335
|
-
return new RawSource(
|
|
336
|
+
return new RawSource(
|
|
337
|
+
Generator.throwBuildErrorCode(
|
|
338
|
+
error,
|
|
339
|
+
undefined,
|
|
340
|
+
generateContext.runtimeTemplate.requestShortener
|
|
341
|
+
)
|
|
342
|
+
);
|
|
336
343
|
}
|
|
337
344
|
}
|
|
338
345
|
|
|
@@ -78,7 +78,6 @@ const { releaseParserCaches } = require("./syntax");
|
|
|
78
78
|
/** @import DependencyTemplates from "../DependencyTemplates" */
|
|
79
79
|
/** @import Entrypoint from "../Entrypoint" */
|
|
80
80
|
/** @import Module, { BuildInfo, CodeGenerationResultData } from "../Module" */
|
|
81
|
-
/** @import { RuntimeSpec } from "../util/runtime" */
|
|
82
81
|
/** @import ModuleGraph from "../ModuleGraph" */
|
|
83
82
|
/** @import RuntimeTemplate from "../RuntimeTemplate" */
|
|
84
83
|
/** @import WebpackError from "../errors/WebpackError" */
|
|
@@ -332,18 +331,6 @@ const createCompilationHooks = () => ({
|
|
|
332
331
|
* @since 5.22.0
|
|
333
332
|
*/
|
|
334
333
|
inlineInRuntimeBailout: new SyncBailHook(["module", "renderContext"]),
|
|
335
|
-
/**
|
|
336
|
-
* Offers a module's rendered export-definition call to a consumer that can place
|
|
337
|
-
* it better — a library whose entry exports the same bindings natively takes it
|
|
338
|
-
* over and emits it only where the module is wrapped. Return true to take it.
|
|
339
|
-
* @type {SyncBailHook<[Module, RuntimeSpec, string, boolean], boolean | void>}
|
|
340
|
-
*/
|
|
341
|
-
onDemandExportsGeneration: new SyncBailHook([
|
|
342
|
-
"module",
|
|
343
|
-
"runtime",
|
|
344
|
-
"source",
|
|
345
|
-
"placeAtEnd"
|
|
346
|
-
]),
|
|
347
334
|
/**
|
|
348
335
|
* @type {SyncBailHook<[Module, RenderContext], string | void>}
|
|
349
336
|
* @since 5.22.0
|
|
@@ -1597,17 +1584,14 @@ class JavascriptModulesPlugin {
|
|
|
1597
1584
|
}
|
|
1598
1585
|
|
|
1599
1586
|
if (runtimeRequirements.has(RuntimeGlobals.makeDeferredNamespaceObject)) {
|
|
1600
|
-
//
|
|
1601
|
-
//
|
|
1602
|
-
//
|
|
1603
|
-
// is evaluated.
|
|
1587
|
+
// The deferred namespace drops its proxy handlers once the module has
|
|
1588
|
+
// initialized, which needs every deferred import of it to reach the exports
|
|
1589
|
+
// object before evaluation.
|
|
1604
1590
|
buf.push("// The deferred module cache");
|
|
1605
1591
|
buf.push(`${bootstrapCst} __webpack_module_deferred_exports__ = {};`);
|
|
1606
|
-
//
|
|
1607
|
-
//
|
|
1608
|
-
//
|
|
1609
|
-
// Cache the deferred namespace proxy here so calls from different
|
|
1610
|
-
// files share identity.
|
|
1592
|
+
// Every defer-import site for one module must yield the same Deferred
|
|
1593
|
+
// Module Namespace, distinct from any eager one, so the proxy is cached
|
|
1594
|
+
// here for call sites in different files to share.
|
|
1611
1595
|
buf.push("// The deferred namespace cache");
|
|
1612
1596
|
buf.push(
|
|
1613
1597
|
`${bootstrapCst} __webpack_module_deferred_namespace_cache__ = {};`
|
|
@@ -1797,13 +1781,9 @@ class JavascriptModulesPlugin {
|
|
|
1797
1781
|
result.allowInlineStartup = false;
|
|
1798
1782
|
}
|
|
1799
1783
|
|
|
1800
|
-
// `__webpack_exports__` may be reassigned later
|
|
1801
|
-
// `onChunksLoaded` wrapper
|
|
1802
|
-
//
|
|
1803
|
-
// bridge reassigns `__webpack_exports__` to the awaited
|
|
1804
|
-
// value), or by other downstream codegen. Always declare
|
|
1805
|
-
// with `let` (or `var` if `let` is unsupported) so
|
|
1806
|
-
// reassignment is allowed.
|
|
1784
|
+
// `__webpack_exports__` may be reassigned later, by the
|
|
1785
|
+
// `onChunksLoaded` wrapper, a top-level `await` bridge or other
|
|
1786
|
+
// codegen, so it is never declared as a constant.
|
|
1807
1787
|
const exportsDecl = runtimeTemplate.renderLet();
|
|
1808
1788
|
if (chunks.length > 0) {
|
|
1809
1789
|
const awaitEntry =
|
|
@@ -2012,11 +1992,9 @@ class JavascriptModulesPlugin {
|
|
|
2012
1992
|
const needModuleDefer = runtimeRequirements.has(
|
|
2013
1993
|
RuntimeGlobals.makeDeferredNamespaceObject
|
|
2014
1994
|
);
|
|
2015
|
-
// Both deferred-namespace runtimes re-invoke `__webpack_require__` on
|
|
2016
|
-
//
|
|
2017
|
-
//
|
|
2018
|
-
// does not use `__webpack_module_deferred_exports__`, so it is tracked
|
|
2019
|
-
// separately from `needModuleDefer`.
|
|
1995
|
+
// Both deferred-namespace runtimes re-invoke `__webpack_require__` on access,
|
|
1996
|
+
// so an evaluation error must be retained and re-thrown. The optimized one
|
|
1997
|
+
// skips the deferred exports object, hence the separate flag.
|
|
2020
1998
|
const needModuleDeferAny =
|
|
2021
1999
|
needModuleDefer ||
|
|
2022
2000
|
runtimeRequirements.has(
|
|
@@ -2144,10 +2122,9 @@ class JavascriptModulesPlugin {
|
|
|
2144
2122
|
allModules.every((m) => /** @type {BuildInfo} */ (m.buildInfo).strict);
|
|
2145
2123
|
const isMultipleEntries = inlinedModules.size > 1;
|
|
2146
2124
|
const singleEntryWithModules = inlinedModules.size === 1 && hasChunkModules;
|
|
2147
|
-
//
|
|
2148
|
-
//
|
|
2149
|
-
//
|
|
2150
|
-
// ('it uses a non-standard name for the exports') is not handled here.
|
|
2125
|
+
// Runs before the IIFE reason is calculated, and only for the cases whose
|
|
2126
|
+
// reason it can remove: several inlined entries, or one beside other chunk
|
|
2127
|
+
// modules. A non-standard exports name is not handled here.
|
|
2151
2128
|
if (innerStrict || (!isMultipleEntries && !singleEntryWithModules)) {
|
|
2152
2129
|
return false;
|
|
2153
2130
|
}
|
|
@@ -2206,11 +2183,9 @@ class JavascriptModulesPlugin {
|
|
|
2206
2183
|
}
|
|
2207
2184
|
}
|
|
2208
2185
|
|
|
2209
|
-
//
|
|
2210
|
-
//
|
|
2211
|
-
//
|
|
2212
|
-
// declarations, or a reserved name, no renaming is needed and the entries
|
|
2213
|
-
// don't have to be parsed at all.
|
|
2186
|
+
// Codegen reports each inlined entry's rendered top-level declarations and
|
|
2187
|
+
// free names, so where nothing collides there is no renaming to do and the
|
|
2188
|
+
// entries need not be parsed at all.
|
|
2214
2189
|
fastPath: {
|
|
2215
2190
|
const { codeGenerationResults, chunk } = renderContext;
|
|
2216
2191
|
/** @type {Set<string>} */
|
|
@@ -2295,11 +2270,9 @@ class JavascriptModulesPlugin {
|
|
|
2295
2270
|
}
|
|
2296
2271
|
}
|
|
2297
2272
|
|
|
2298
|
-
//
|
|
2299
|
-
//
|
|
2300
|
-
//
|
|
2301
|
-
// reference, or with a reserved name, so the modules can be emitted without a
|
|
2302
|
-
// per-entry IIFE.
|
|
2273
|
+
// Several inlined entries share the chunk's startup scope, so any top-level
|
|
2274
|
+
// declaration colliding with another's declaration, any module's free
|
|
2275
|
+
// reference or a reserved name is renamed, sparing them a per-entry IIFE.
|
|
2303
2276
|
if (isMultipleEntries) {
|
|
2304
2277
|
/** @type {Set<string>} */
|
|
2305
2278
|
const allUsedNames = new Set(nonInlinedModuleThroughIdentifiers);
|