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/buildChunkGraph.js
CHANGED
|
@@ -641,16 +641,13 @@ const visitModules = (
|
|
|
641
641
|
}
|
|
642
642
|
} else {
|
|
643
643
|
entrypoint = /** @type {Entrypoint} */ (cgi.chunkGroup);
|
|
644
|
-
// Fill in
|
|
645
|
-
//
|
|
646
|
-
//
|
|
647
|
-
|
|
648
|
-
//
|
|
649
|
-
//
|
|
650
|
-
//
|
|
651
|
-
// from a block that deduped in via its module would leave
|
|
652
|
-
// `entrypoint.name` out of sync and make module codegen
|
|
653
|
-
// order-dependent, which breaks persistent caching.
|
|
644
|
+
// Fill in only the options still unset: blocks deduping to one
|
|
645
|
+
// entrypoint may carry different values, so the first to create it
|
|
646
|
+
// wins.
|
|
647
|
+
|
|
648
|
+
// `name` is excluded, being the entrypoint's identity and fixed at
|
|
649
|
+
// creation. Back-filling it would make codegen order-dependent, which
|
|
650
|
+
// breaks persistent caching.
|
|
654
651
|
const existingOptions = entrypoint.options;
|
|
655
652
|
for (const key_ of Object.keys(entryOptions)) {
|
|
656
653
|
const key =
|
|
@@ -1370,11 +1367,10 @@ const connectChunkGroups = (
|
|
|
1370
1367
|
|
|
1371
1368
|
// For each edge in the basic chunk graph
|
|
1372
1369
|
for (const [block, connections] of blockConnections) {
|
|
1373
|
-
//
|
|
1374
|
-
//
|
|
1375
|
-
//
|
|
1376
|
-
|
|
1377
|
-
// connections and modules can only create one version
|
|
1370
|
+
// Skip the whole set when no dependency needs connecting. They cannot be
|
|
1371
|
+
// filtered one by one without inconsistent connections, since a module can
|
|
1372
|
+
// only carry one version.
|
|
1373
|
+
|
|
1378
1374
|
// TODO maybe decide this per runtime
|
|
1379
1375
|
if (
|
|
1380
1376
|
// Blocks with nested blocks must stay connected — skipping orphans the
|
|
@@ -31,13 +31,13 @@ class MemoryCachePlugin {
|
|
|
31
31
|
const cacheEntry = cache.get(identifier);
|
|
32
32
|
// A recorded miss: the whole chain was asked for this identifier already.
|
|
33
33
|
if (cacheEntry === null) return null;
|
|
34
|
-
//
|
|
35
|
-
// object, so equal content reached through a second object is a
|
|
34
|
+
// WHY: etags are compared by identity, and a lazy one is interned per
|
|
35
|
+
// source object, so equal content reached through a second object is a
|
|
36
36
|
// different etag. Hashing to tell those apart would cost every hit what
|
|
37
37
|
// laziness saves, so a mismatch falls through to the next stage instead:
|
|
38
38
|
// the file cache compares etags by value and can still answer. Returning
|
|
39
|
-
// `null` here would bail the hook and lose that
|
|
40
|
-
// `undefined` regardless, so it buys the caller nothing
|
|
39
|
+
// `null` here would bail the hook and lose that, and `Cache.get` maps it
|
|
40
|
+
// to `undefined` regardless, so it buys the caller nothing.
|
|
41
41
|
if (cacheEntry !== undefined && cacheEntry.etag === etag) {
|
|
42
42
|
return cacheEntry.data;
|
|
43
43
|
}
|
|
@@ -79,10 +79,9 @@ class MemoryWithGcCachePlugin {
|
|
|
79
79
|
continue;
|
|
80
80
|
}
|
|
81
81
|
if (entry !== undefined) {
|
|
82
|
-
//
|
|
83
|
-
//
|
|
84
|
-
//
|
|
85
|
-
// It will be deleted when removed from oldCache.
|
|
82
|
+
// Set to undefined rather than deleted, reserving the slot and sparing
|
|
83
|
+
// a rehash as entries come and go. It goes for good once `oldCache`
|
|
84
|
+
// drops it.
|
|
86
85
|
cache.set(identifier, undefined);
|
|
87
86
|
oldCache.delete(identifier);
|
|
88
87
|
oldCache.set(identifier, {
|
|
@@ -105,13 +104,13 @@ class MemoryWithGcCachePlugin {
|
|
|
105
104
|
const cacheEntry = cache.get(identifier);
|
|
106
105
|
// A recorded miss: the whole chain was asked for this identifier already.
|
|
107
106
|
if (cacheEntry === null) return null;
|
|
108
|
-
//
|
|
109
|
-
// object, so equal content reached through a second object is a
|
|
107
|
+
// WHY: etags are compared by identity, and a lazy one is interned per
|
|
108
|
+
// source object, so equal content reached through a second object is a
|
|
110
109
|
// different etag. Hashing to tell those apart would cost every hit what
|
|
111
110
|
// laziness saves, so a mismatch falls through to the next stage instead:
|
|
112
111
|
// the file cache compares etags by value and can still answer. Returning
|
|
113
|
-
// `null` here would bail the hook and lose that
|
|
114
|
-
// `undefined` regardless, so it buys the caller nothing
|
|
112
|
+
// `null` here would bail the hook and lose that, and `Cache.get` maps it
|
|
113
|
+
// to `undefined` regardless, so it buys the caller nothing.
|
|
115
114
|
let known = cacheEntry !== undefined;
|
|
116
115
|
if (cacheEntry !== undefined) {
|
|
117
116
|
if (cacheEntry.etag === etag) return cacheEntry.data;
|
|
@@ -901,24 +901,9 @@ makeSerializable(
|
|
|
901
901
|
/** @typedef {(() => Promise<PackContentItems> | PackContentItems) & Partial<{ options: { size?: number } }>} LazyFunction */
|
|
902
902
|
|
|
903
903
|
class PackContent {
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
A1 | undefined | Map | false | fresh content
|
|
908
|
-
A2 | undefined | Map | true | (will not happen)
|
|
909
|
-
B1 | lazy () => {} | undefined | false | not deserialized
|
|
910
|
-
B2 | lazy () => {} | undefined | true | not deserialized, but some items has been removed
|
|
911
|
-
C1 | lazy* () => {} | Map | false | deserialized
|
|
912
|
-
C2 | lazy* () => {} | Map | true | deserialized, and some items has been removed
|
|
913
|
-
|
|
914
|
-
this.used is a subset of this.items.
|
|
915
|
-
this.items is a subset of this.content.keys() resp. this.lazy().map.keys()
|
|
916
|
-
When this.outdated === false, this.items === this.content.keys() resp. this.lazy().map.keys()
|
|
917
|
-
When this.outdated === true, this.items should be used to recreated this.lazy/this.content.
|
|
918
|
-
When this.lazy and this.content is set, they contain the same data.
|
|
919
|
-
this.get must only be called with a valid item from this.items.
|
|
920
|
-
In state C this.lazy is unMemoized
|
|
921
|
-
*/
|
|
904
|
+
// `used` is a subset of `items`, itself a subset of the content's keys, and the
|
|
905
|
+
// two coincide while `outdated` is false. `lazy` and `content` hold the same
|
|
906
|
+
// data whenever both are set, and `get` takes only an item of `items`.
|
|
922
907
|
|
|
923
908
|
/**
|
|
924
909
|
* Creates an instance of PackContent.
|
|
@@ -42,11 +42,9 @@ class LazyHashedEtag {
|
|
|
42
42
|
/** @type {HashableObject} */
|
|
43
43
|
(this._obj).updateHash(hash);
|
|
44
44
|
this._hash = hash.digest("base64");
|
|
45
|
-
// Drop the captured object once the hash is memoized
|
|
46
|
-
//
|
|
47
|
-
//
|
|
48
|
-
// a heavy `CachedSource` here that would otherwise stay reachable
|
|
49
|
-
// through this etag for the lifetime of the compilation cache.
|
|
45
|
+
// Drop the captured object once the hash is memoized: the hash never
|
|
46
|
+
// resets, and callers often capture a heavy `CachedSource` that would
|
|
47
|
+
// otherwise stay reachable for the compilation cache's lifetime.
|
|
50
48
|
this._obj = undefined;
|
|
51
49
|
}
|
|
52
50
|
return this._hash;
|
|
@@ -422,10 +422,7 @@ const resolve = (browsers) => {
|
|
|
422
422
|
ios_saf: [15, 4],
|
|
423
423
|
samsung: 17,
|
|
424
424
|
android: 93,
|
|
425
|
-
// and_qq
|
|
426
|
-
// baidu: Not supported
|
|
427
|
-
// and_uc: Not supported
|
|
428
|
-
// kaios: Not supported
|
|
425
|
+
// and_qq, baidu, and_uc and kaios are not supported.
|
|
429
426
|
node: [16, 9]
|
|
430
427
|
}),
|
|
431
428
|
topLevelAwait: rawChecker({
|
|
@@ -441,10 +438,7 @@ const resolve = (browsers) => {
|
|
|
441
438
|
ios_saf: 15,
|
|
442
439
|
samsung: 15,
|
|
443
440
|
android: 89,
|
|
444
|
-
// and_qq
|
|
445
|
-
// baidu: Not supported
|
|
446
|
-
// and_uc: Not supported
|
|
447
|
-
// kaios: Not supported
|
|
441
|
+
// and_qq, baidu, and_uc and kaios are not supported.
|
|
448
442
|
node: [14, 8]
|
|
449
443
|
}),
|
|
450
444
|
spread: rawChecker({
|
package/lib/config/defaults.js
CHANGED
|
@@ -492,10 +492,9 @@ const applyWebpackOptionsDefaults = (options, compilerIndex) => {
|
|
|
492
492
|
library: options.output.library
|
|
493
493
|
});
|
|
494
494
|
|
|
495
|
-
// `output.resourceHints.urlHints`
|
|
496
|
-
//
|
|
497
|
-
//
|
|
498
|
-
// `parser.<type>.urlHints` rules — matched later, last-match-wins — override.
|
|
495
|
+
// `output.resourceHints.urlHints` fans the project-wide rules out as the base
|
|
496
|
+
// `urlHints` of every URL-emitting parser. They go first, so a parser-scoped
|
|
497
|
+
// rule matches later and wins.
|
|
499
498
|
const outputUrlHints =
|
|
500
499
|
options.output.resourceHints && options.output.resourceHints.urlHints;
|
|
501
500
|
if (outputUrlHints && outputUrlHints.length > 0) {
|
|
@@ -660,14 +659,12 @@ const applyExperimentsDefaults = (
|
|
|
660
659
|
experiments.futureDefaults ? true : "auto"
|
|
661
660
|
);
|
|
662
661
|
|
|
663
|
-
// Resolve
|
|
664
|
-
//
|
|
665
|
-
//
|
|
666
|
-
|
|
667
|
-
//
|
|
668
|
-
//
|
|
669
|
-
// then step aside per-module for requests that loaders were applied to
|
|
670
|
-
// (inline requests or loaders injected via hooks, e.g. html-webpack-plugin).
|
|
662
|
+
// Resolve `"auto"`: enable the built-in type unless a loader is already
|
|
663
|
+
// registered for these files, so the default breaks no existing setup. Both
|
|
664
|
+
// extensions are sampled, since `/\.css$/i` also covers `.module.css`.
|
|
665
|
+
|
|
666
|
+
// Enabled implicitly the value stays `"auto"`, and the plugins then step
|
|
667
|
+
// aside per module for requests loaders were applied to.
|
|
671
668
|
// TODO webpack 6: css/html default to `true`, drop the `"auto"` marker.
|
|
672
669
|
if (experiments.css === "auto") {
|
|
673
670
|
experiments.css =
|
|
@@ -1227,18 +1224,13 @@ const applyModuleDefaults = (
|
|
|
1227
1224
|
}
|
|
1228
1225
|
|
|
1229
1226
|
if (html) {
|
|
1230
|
-
// `
|
|
1231
|
-
//
|
|
1232
|
-
//
|
|
1233
|
-
// behaviour. Setting `extract: true` forces extraction for all HTML
|
|
1234
|
-
// modules (including imported ones); `extract: false` disables it
|
|
1235
|
-
// everywhere.
|
|
1227
|
+
// `extract` is deliberately left undefined, which HtmlGenerator reads as
|
|
1228
|
+
// "extract only a module that is a compilation entry". `true` forces it for
|
|
1229
|
+
// imported modules too, `false` disables it everywhere.
|
|
1236
1230
|
F(module.generator, HTML_MODULE_TYPE, () => ({}));
|
|
1237
|
-
// `
|
|
1238
|
-
//
|
|
1239
|
-
//
|
|
1240
|
-
// Users may pass `false` to disable extraction entirely or an array
|
|
1241
|
-
// (with `"..."` to include the defaults) to customize it.
|
|
1231
|
+
// `sources` defaults to `true`, so HtmlParser extracts URL-like attributes
|
|
1232
|
+
// as dependencies from its built-in list. `false` disables extraction, and
|
|
1233
|
+
// an array customizes it, with `"..."` keeping the defaults.
|
|
1242
1234
|
F(module.parser, HTML_MODULE_TYPE, () => ({}));
|
|
1243
1235
|
D(
|
|
1244
1236
|
/** @type {NonNullable<ParserOptionsByModuleTypeKnown[HTML_MODULE_TYPE]>} */
|
|
@@ -1372,11 +1364,9 @@ const applyModuleDefaults = (
|
|
|
1372
1364
|
type: CSS_MODULE_TYPE,
|
|
1373
1365
|
resolve
|
|
1374
1366
|
});
|
|
1375
|
-
// For
|
|
1376
|
-
//
|
|
1377
|
-
//
|
|
1378
|
-
// the same modules-mode behavior from the auto rule, and forcing a
|
|
1379
|
-
// different type stamp here would create a duplicate module instance.
|
|
1367
|
+
// For `composes: className from "./style.css"`. A file already detected as
|
|
1368
|
+
// a CSS module by extension is skipped: it gets modules mode from the auto
|
|
1369
|
+
// rule anyway, and a second type stamp would duplicate the module.
|
|
1380
1370
|
const moduleExtension = /\.module\.\w+$/i;
|
|
1381
1371
|
rules.push({
|
|
1382
1372
|
dependency: /css-import-local-module/,
|
|
@@ -1426,11 +1416,9 @@ const applyModuleDefaults = (
|
|
|
1426
1416
|
type: HTML_MODULE_TYPE,
|
|
1427
1417
|
resolve
|
|
1428
1418
|
});
|
|
1429
|
-
// `<iframe srcdoc>` content
|
|
1430
|
-
// `data:text/html` module. `extract: "inline"` exposes the
|
|
1431
|
-
//
|
|
1432
|
-
// Template` reads back into the attribute, without emitting a standalone
|
|
1433
|
-
// `.html` file (the module is never a page on its own).
|
|
1419
|
+
// `<iframe srcdoc>` content goes back through the HTML pipeline as a
|
|
1420
|
+
// `data:text/html` module. `extract: "inline"` exposes it on the `html`
|
|
1421
|
+
// channel without emitting a file: it is never a page on its own.
|
|
1434
1422
|
rules.push({
|
|
1435
1423
|
dependency: "html-srcdoc",
|
|
1436
1424
|
generator: {
|
|
@@ -1439,12 +1427,9 @@ const applyModuleDefaults = (
|
|
|
1439
1427
|
resolve
|
|
1440
1428
|
});
|
|
1441
1429
|
if (css) {
|
|
1442
|
-
// Inline `<style>` content
|
|
1443
|
-
//
|
|
1444
|
-
//
|
|
1445
|
-
// processed CSS text on the `css-text` codegen channel that
|
|
1446
|
-
// `HtmlInlineStyleDependency.Template` reads back into the
|
|
1447
|
-
// `<style>` tag.
|
|
1430
|
+
// Inline `<style>` content goes into the CSS pipeline as a
|
|
1431
|
+
// `data:text/css` module. `exportType: "text"` is forced, so the
|
|
1432
|
+
// processed text reaches the `css-text` channel the template reads.
|
|
1448
1433
|
rules.push({
|
|
1449
1434
|
dependency: "html-style",
|
|
1450
1435
|
parser: {
|
|
@@ -1750,12 +1735,11 @@ const applyOutputDefaults = (
|
|
|
1750
1735
|
"const",
|
|
1751
1736
|
() => tp && optimistic(/** @type {boolean | undefined} */ (tp.const))
|
|
1752
1737
|
);
|
|
1753
|
-
// Only the browserslist target reports these;
|
|
1754
|
-
//
|
|
1755
|
-
|
|
1756
|
-
// `let` was added after `const
|
|
1757
|
-
//
|
|
1758
|
-
// do report `let` (browserslist, built-ins) keep their own accurate value.
|
|
1738
|
+
// Only the browserslist target reports these; unset elsewhere, which
|
|
1739
|
+
// `optimistic` reads as the modern spelling being available.
|
|
1740
|
+
|
|
1741
|
+
// `let` was added after `const`, so a target predating it reports only
|
|
1742
|
+
// `const` and falls back to it. One reporting `let` keeps its own value.
|
|
1759
1743
|
F(environment, "let", () =>
|
|
1760
1744
|
conditionallyOptimistic(
|
|
1761
1745
|
/** @type {boolean | undefined} */ (tp && tp.let),
|
|
@@ -1887,10 +1871,9 @@ const applyOutputDefaults = (
|
|
|
1887
1871
|
tp && optimistic(/** @type {boolean | undefined} */ (tp.modulePreload))
|
|
1888
1872
|
);
|
|
1889
1873
|
|
|
1890
|
-
//
|
|
1891
|
-
//
|
|
1892
|
-
//
|
|
1893
|
-
// tags (no waterfall), so it stays opt-in.
|
|
1874
|
+
// For ESM output, preload the entry's initial dependency graph, which native
|
|
1875
|
+
// `import()` would otherwise fetch in a waterfall. Classic output loads its
|
|
1876
|
+
// initial chunks in parallel already, so it stays opt-in.
|
|
1894
1877
|
if (output.module && output.resourceHints === undefined) {
|
|
1895
1878
|
output.resourceHints = {};
|
|
1896
1879
|
}
|
|
@@ -1944,13 +1927,9 @@ const applyOutputDefaults = (
|
|
|
1944
1927
|
}
|
|
1945
1928
|
return "[id].css";
|
|
1946
1929
|
});
|
|
1947
|
-
// Derive html
|
|
1948
|
-
//
|
|
1949
|
-
//
|
|
1950
|
-
// extracted HTML modules in one compilation don't collide on the same
|
|
1951
|
-
// emitted file. For example: `output.filename: "bundle.js"` would derive
|
|
1952
|
-
// `bundle.html` — two `.html` modules extracted in the same build would
|
|
1953
|
-
// both want that name and conflict at emit time.
|
|
1930
|
+
// Derive the html filenames from `output.filename`, as the CSS pipeline does.
|
|
1931
|
+
// A derived template with no per-module placeholder falls back to
|
|
1932
|
+
// `[name].html`, or two extracted modules would want the same file.
|
|
1954
1933
|
const HAS_PATH_PLACEHOLDER_REGEXP =
|
|
1955
1934
|
/\[(name|id|chunkhash|contenthash|fullhash|hash)/;
|
|
1956
1935
|
/**
|
|
@@ -1997,11 +1976,9 @@ const applyOutputDefaults = (
|
|
|
1997
1976
|
if (tp) {
|
|
1998
1977
|
if (tp.global) return "global";
|
|
1999
1978
|
if (tp.globalThis) return "globalThis";
|
|
2000
|
-
//
|
|
2001
|
-
//
|
|
2002
|
-
//
|
|
2003
|
-
// scopes, `global` covers Node.js. Naming either alone leaves the other
|
|
2004
|
-
// platform reading an undeclared binding.
|
|
1979
|
+
// A universal target has no identifier defined on both sides, so this is
|
|
1980
|
+
// `globalThis` where nothing argues against it and a guarded pair where
|
|
1981
|
+
// something does: naming one alone leaves the other undeclared.
|
|
2005
1982
|
if (tp.web === null && tp.node === null) {
|
|
2006
1983
|
return tp.globalThis === undefined
|
|
2007
1984
|
? "globalThis"
|
|
@@ -2531,19 +2508,17 @@ const applyOptimizationDefaults = (
|
|
|
2531
2508
|
// Lazy load the minimizer plugin
|
|
2532
2509
|
const TerserPlugin = require("minimizer-webpack-plugin");
|
|
2533
2510
|
|
|
2534
|
-
//
|
|
2535
|
-
// native CSS
|
|
2536
|
-
// functions each dispatched by its own `filter
|
|
2537
|
-
// cssMinify
|
|
2538
|
-
// worker-safe by resolving their parser with `require("webpack/…")`
|
|
2539
|
-
// the worker, so all three share the
|
|
2540
|
-
//
|
|
2541
|
-
|
|
2542
|
-
//
|
|
2543
|
-
//
|
|
2544
|
-
//
|
|
2545
|
-
// than resolved per asset — a coarse check, but it keeps the outcome
|
|
2546
|
-
// independent of tap order and of the plugin version in use.
|
|
2511
|
+
// WHY: one minimizer instance, so one worker-thread pool, handles JS and
|
|
2512
|
+
// — where native CSS and HTML are enabled — those assets too, as an array
|
|
2513
|
+
// of minify functions each dispatched by its own `filter`: terser to JS,
|
|
2514
|
+
// `cssMinify` to CSS, `htmlMinify` to HTML. The CSS and HTML serializers
|
|
2515
|
+
// stay worker-safe by resolving their parser with `require("webpack/…")`
|
|
2516
|
+
// in the worker, so all three share the pool, and `test` is widened to let
|
|
2517
|
+
// those assets reach the dispatcher.
|
|
2518
|
+
|
|
2519
|
+
// Step aside for a minimizer the user configured for these types:
|
|
2520
|
+
// whichever ran first would mark the asset `minimized` and silently
|
|
2521
|
+
// disable the other. Matchers are read directly, coarse but stable.
|
|
2547
2522
|
const claimedByOtherMinimizer = require("./getClaimedAssetTypes")(
|
|
2548
2523
|
compiler
|
|
2549
2524
|
);
|
|
@@ -2619,10 +2594,9 @@ const applyOptimizationDefaults = (
|
|
|
2619
2594
|
}
|
|
2620
2595
|
if (minifyHtml) {
|
|
2621
2596
|
minify.push(require("../html/htmlMinify"));
|
|
2622
|
-
// `minimize.css` rides
|
|
2623
|
-
//
|
|
2624
|
-
//
|
|
2625
|
-
// each language the other's answer.
|
|
2597
|
+
// `minimize.css` rides under its own key rather than spread beside the
|
|
2598
|
+
// HTML options: the two name some of the same switches, so one flat
|
|
2599
|
+
// object would hand each language the other's answer.
|
|
2626
2600
|
minimizerOptions.push({
|
|
2627
2601
|
environment: cssEnvironment,
|
|
2628
2602
|
css: cssOptions,
|
|
@@ -17,19 +17,18 @@ const { matchObject } = require("../ModuleFilenameHelpers");
|
|
|
17
17
|
* @returns {boolean} whether the candidate minimizes that file
|
|
18
18
|
*/
|
|
19
19
|
const claims = (candidate, file) => {
|
|
20
|
-
//
|
|
21
|
-
// `css-minimizer-webpack-plugin`, `html-minimizer-webpack-plugin`, …
|
|
22
|
-
//
|
|
23
|
-
//
|
|
24
|
-
//
|
|
25
|
-
//
|
|
26
|
-
//
|
|
20
|
+
// WHY: every minimizer in the `minimizer-webpack-plugin` family — itself,
|
|
21
|
+
// `css-minimizer-webpack-plugin`, `html-minimizer-webpack-plugin`, … — keeps
|
|
22
|
+
// its implementation on `options.minimizer` and its asset matcher alongside
|
|
23
|
+
// it, in the shape `matchObject` reads. The matcher alone is not enough to
|
|
24
|
+
// recognize one: `BannerPlugin` and `SourceMapDevToolPlugin` carry the same
|
|
25
|
+
// three keys, and `LoaderOptionsPlugin` defaults `test` to match every file,
|
|
26
|
+
// so reading those as minimizers would disable minification.
|
|
27
27
|
const { options } = /** @type {{ options?: MinimizerOptions }} */ (candidate);
|
|
28
28
|
if (!options || !options.minimizer) return false;
|
|
29
|
-
// `test
|
|
30
|
-
// files within them
|
|
31
|
-
// to a subdirectory claim nothing, and webpack would then race it
|
|
32
|
-
// files it was configured for.
|
|
29
|
+
// `test` and `include` say which types it handles, while `exclude` only
|
|
30
|
+
// narrows the files within them: honoring that narrowing would let a minimizer
|
|
31
|
+
// scoped to a subdirectory claim nothing, and webpack would then race it.
|
|
33
32
|
const { test, include } = options;
|
|
34
33
|
return (
|
|
35
34
|
(test !== undefined && matchObject({ test }, file)) ||
|
package/lib/config/target.js
CHANGED
|
@@ -345,10 +345,9 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
345
345
|
"Bun in version X.Y. Output is always ECMAScript modules. Examples: bun, bun1.1.",
|
|
346
346
|
/^bun((\d+)(?:\.(\d+))?)?$/,
|
|
347
347
|
() => ({
|
|
348
|
-
// Bun
|
|
349
|
-
//
|
|
350
|
-
//
|
|
351
|
-
// CommonJS `require` is never available.
|
|
348
|
+
// Every released Bun supports the full modern feature set, so a version is
|
|
349
|
+
// accepted but gates nothing. Output is always ESM, leaving no synchronous
|
|
350
|
+
// CommonJS `require`.
|
|
352
351
|
node: true,
|
|
353
352
|
bun: true,
|
|
354
353
|
web: false,
|
|
@@ -6,49 +6,52 @@
|
|
|
6
6
|
"use strict";
|
|
7
7
|
|
|
8
8
|
const { OriginalSource, RawSource } = require("webpack-sources");
|
|
9
|
-
const AsyncDependenciesBlock = require("
|
|
10
|
-
const Module = require("
|
|
9
|
+
const AsyncDependenciesBlock = require("../AsyncDependenciesBlock");
|
|
10
|
+
const Module = require("../Module");
|
|
11
11
|
const {
|
|
12
12
|
JAVASCRIPT_TYPE,
|
|
13
13
|
JAVASCRIPT_TYPES
|
|
14
|
-
} = require("
|
|
15
|
-
const { JAVASCRIPT_MODULE_TYPE_DYNAMIC } = require("
|
|
16
|
-
const RuntimeGlobals = require("
|
|
17
|
-
const Template = require("
|
|
14
|
+
} = require("../ModuleSourceTypeConstants");
|
|
15
|
+
const { JAVASCRIPT_MODULE_TYPE_DYNAMIC } = require("../ModuleTypeConstants");
|
|
16
|
+
const RuntimeGlobals = require("../RuntimeGlobals");
|
|
17
|
+
const Template = require("../Template");
|
|
18
18
|
const {
|
|
19
19
|
getOutgoingAsyncModules
|
|
20
|
-
} = require("
|
|
21
|
-
const {
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
} = require("../async-modules/AsyncModuleHelpers");
|
|
21
|
+
const {
|
|
22
|
+
ImportPhase,
|
|
23
|
+
ImportPhaseUtils
|
|
24
|
+
} = require("../dependencies/ImportPhase");
|
|
25
|
+
const { makeWebpackError } = require("../errors/HookWebpackError");
|
|
26
|
+
const WebpackError = require("../errors/WebpackError");
|
|
24
27
|
const {
|
|
25
28
|
compareLocations,
|
|
26
29
|
compareModulesById,
|
|
27
30
|
compareSelect,
|
|
28
31
|
concatComparators,
|
|
29
32
|
keepOriginalOrder
|
|
30
|
-
} = require("
|
|
33
|
+
} = require("../util/comparators");
|
|
31
34
|
const {
|
|
32
35
|
contextify,
|
|
33
36
|
makePathsRelative,
|
|
34
37
|
parseResource
|
|
35
|
-
} = require("
|
|
36
|
-
const makeSerializable = require("
|
|
37
|
-
const { propertyAccess } = require("
|
|
38
|
+
} = require("../util/identifier");
|
|
39
|
+
const makeSerializable = require("../util/makeSerializable");
|
|
40
|
+
const { propertyAccess } = require("../util/property");
|
|
38
41
|
|
|
39
42
|
/** @import { Source } from "webpack-sources" */
|
|
40
|
-
/** @import { ResolveOptions } from "
|
|
43
|
+
/** @import { ResolveOptions } from "../../declarations/WebpackOptions" */
|
|
41
44
|
/**
|
|
42
45
|
* @import {
|
|
43
46
|
* WebpackOptionsNormalizedWithDefaults as WebpackOptions
|
|
44
|
-
* } from "
|
|
47
|
+
* } from "../config/defaults"
|
|
45
48
|
*/
|
|
46
|
-
/** @import Chunk, { ChunkId, ChunkName } from "
|
|
47
|
-
/** @import ChunkGraph, { ModuleId } from "
|
|
48
|
-
/** @import { RawChunkGroupOptions } from "
|
|
49
|
-
/** @import Compilation, { FileSystemDependencies } from "
|
|
50
|
-
/** @import Dependency, { RawReferencedExports } from "
|
|
51
|
-
/** @import { Snapshot } from "
|
|
49
|
+
/** @import Chunk, { ChunkId, ChunkName } from "../Chunk" */
|
|
50
|
+
/** @import ChunkGraph, { ModuleId } from "../ChunkGraph" */
|
|
51
|
+
/** @import { RawChunkGroupOptions } from "../ChunkGroup" */
|
|
52
|
+
/** @import Compilation, { FileSystemDependencies } from "../Compilation" */
|
|
53
|
+
/** @import Dependency, { RawReferencedExports } from "../Dependency" */
|
|
54
|
+
/** @import { Snapshot } from "../FileSystemInfo" */
|
|
52
55
|
/**
|
|
53
56
|
* @import {
|
|
54
57
|
* BuildCallback,
|
|
@@ -63,17 +66,17 @@ const { propertyAccess } = require("./util/property");
|
|
|
63
66
|
* RuntimeRequirements,
|
|
64
67
|
* Sources,
|
|
65
68
|
* SourceTypes
|
|
66
|
-
* } from "
|
|
69
|
+
* } from "../Module"
|
|
67
70
|
*/
|
|
68
|
-
/** @import RequestShortener from "
|
|
69
|
-
/** @import { ResolverWithOptions } from "
|
|
70
|
-
/** @import RuntimeTemplate from "
|
|
71
|
-
/** @import ContextElementDependency from "
|
|
72
|
-
/** @import { ImportAttributes } from "
|
|
73
|
-
/** @typedef {import("
|
|
74
|
-
/** @typedef {import("
|
|
75
|
-
/** @import { InputFileSystem } from "
|
|
76
|
-
/** @import { ImportPhaseType } from "
|
|
71
|
+
/** @import RequestShortener from "../RequestShortener" */
|
|
72
|
+
/** @import { ResolverWithOptions } from "../ResolverFactory" */
|
|
73
|
+
/** @import RuntimeTemplate from "../RuntimeTemplate" */
|
|
74
|
+
/** @import ContextElementDependency from "../dependencies/ContextElementDependency" */
|
|
75
|
+
/** @import { ImportAttributes } from "../javascript/JavascriptParser" */
|
|
76
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext<[string, boolean]>} ObjectDeserializerContext */
|
|
77
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext<[string, boolean]>} ObjectSerializerContext */
|
|
78
|
+
/** @import { InputFileSystem } from "../util/fs" */
|
|
79
|
+
/** @import { ImportPhaseType } from "../dependencies/ImportPhase" */
|
|
77
80
|
|
|
78
81
|
/** @typedef {"sync" | "eager" | "weak" | "async-weak" | "lazy" | "lazy-once"} ContextMode Context mode */
|
|
79
82
|
|
|
@@ -1473,7 +1476,7 @@ module.exports = webpackEmptyAsyncContext;`;
|
|
|
1473
1476
|
const returnModuleObject = this.getReturnModuleObjectSource(fakeMap);
|
|
1474
1477
|
const globImportAccess = this.getImportPropertyAccess();
|
|
1475
1478
|
const sortedDependencies =
|
|
1476
|
-
/** @type {import("
|
|
1479
|
+
/** @type {import("../dependencies/ContextElementDependency")[]} */
|
|
1477
1480
|
(dependencies).sort((a, b) =>
|
|
1478
1481
|
a.userRequest < b.userRequest
|
|
1479
1482
|
? -1
|
|
@@ -1724,6 +1727,6 @@ module.exports = webpackEmptyAsyncContext;`;
|
|
|
1724
1727
|
}
|
|
1725
1728
|
}
|
|
1726
1729
|
|
|
1727
|
-
makeSerializable(ContextModule, "webpack/lib/ContextModule");
|
|
1730
|
+
makeSerializable(ContextModule, "webpack/lib/context/ContextModule");
|
|
1728
1731
|
|
|
1729
1732
|
module.exports = ContextModule;
|