webpack 5.110.2 → 5.111.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -2
- package/lib/APIPlugin.js +23 -7
- package/lib/AutomaticPrefetchPlugin.js +1 -1
- package/lib/Cache.js +8 -3
- package/lib/CacheFacade.js +1 -1
- package/lib/ChunkGraph.js +20 -18
- package/lib/CircularModulesPlugin.js +157 -55
- package/lib/CleanPlugin.js +2 -2
- package/lib/Compilation.js +321 -303
- package/lib/Compiler.js +209 -46
- package/lib/ConcatenationScope.js +25 -35
- package/lib/ContextModule.js +17 -81
- package/lib/ContextModuleFactory.js +1 -1
- package/lib/CopyPlugin.js +1054 -0
- package/lib/DefinePlugin.js +24 -8
- package/lib/DotenvPlugin.js +41 -13
- package/lib/ExternalModule.js +41 -14
- package/lib/FileSystemInfo.js +17 -14
- package/lib/FlagDependencyExportsPlugin.js +45 -21
- package/lib/FlagDependencyUsagePlugin.js +8 -2
- package/lib/HotModuleReplacementPlugin.js +53 -7
- package/lib/JavascriptMetaInfoPlugin.js +5 -3
- package/lib/MainTemplate.js +5 -1
- package/lib/Module.js +16 -7
- package/lib/MultiCompiler.js +1 -1
- package/lib/MultiWatching.js +1 -1
- package/lib/NormalModule.js +58 -32
- package/lib/NormalModuleFactory.js +1 -1
- package/lib/RuntimeGlobals.js +21 -7
- package/lib/RuntimeModule.js +28 -12
- package/lib/RuntimePlugin.js +33 -3
- package/lib/RuntimeTemplate.js +794 -477
- package/lib/SourceMapDevToolPlugin.js +1 -1
- package/lib/Watching.js +9 -0
- package/lib/WebpackOptionsApply.js +84 -91
- package/lib/asset/AssetGenerator.js +25 -8
- package/lib/asset/AssetModule.js +3 -0
- package/lib/asset/WebManifestParser.js +7 -5
- package/lib/async-modules/AsyncModuleHelpers.js +10 -4
- package/lib/cache/AddBuildDependenciesPlugin.js +33 -4
- package/lib/cache/IdleFileCachePlugin.js +2 -2
- package/lib/cache/PackFileCacheStrategy.js +14 -1
- package/lib/config/browserslistTargetHandler.js +19 -0
- package/lib/config/defaults.js +110 -64
- package/lib/config/normalization.js +100 -20
- package/lib/config/target.js +10 -0
- package/lib/container/ContainerReferencePlugin.js +6 -0
- package/lib/container/RemoteRuntimeModule.js +9 -0
- package/lib/container/declaredRemotes.js +39 -0
- package/lib/css/CssGenerator.js +8 -0
- package/lib/css/CssInjectStyleRuntimeModule.js +9 -0
- package/lib/css/CssLoadingRuntimeModule.js +94 -36
- package/lib/css/CssModule.js +1 -1
- package/lib/css/CssModulesPlugin.js +7 -6
- package/lib/css/CssParser.js +144 -11
- package/lib/css/CssServerStylesRuntimeModule.js +9 -0
- package/lib/css/cssMinify.js +11 -3
- package/lib/css/data.js +2814 -678
- package/lib/css/syntax.js +4082 -248
- package/lib/debug/ProfilingPlugin.js +4 -0
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +6 -3
- package/lib/dependencies/AMDRuntimeModules.js +18 -0
- package/lib/dependencies/CommonJsExportRequireDependency.js +3 -1
- package/lib/dependencies/CommonJsExportsParserPlugin.js +12 -13
- package/lib/dependencies/CommonJsImportsParserPlugin.js +1 -0
- package/lib/dependencies/CommonJsPlugin.js +19 -3
- package/lib/dependencies/CommonJsRequireDependency.js +32 -9
- package/lib/dependencies/ContextDependencyTemplateAsRequireCall.js +20 -7
- package/lib/dependencies/CssIcssExportDependency.js +7 -1
- package/lib/dependencies/HarmonyCompatibilityDependency.js +58 -4
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +8 -3
- package/lib/dependencies/HarmonyExportExpressionDependency.js +44 -29
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +171 -32
- package/lib/dependencies/HarmonyExportInitFragment.js +99 -19
- package/lib/dependencies/HarmonyExportSpecifierDependency.js +18 -30
- package/lib/dependencies/HarmonyImportBareSideEffectDependency.js +59 -0
- package/lib/dependencies/HarmonyImportDependency.js +99 -41
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +20 -3
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +24 -1
- package/lib/dependencies/HarmonyModulesPlugin.js +20 -0
- package/lib/dependencies/HtmlEntryDependency.js +62 -2
- package/lib/dependencies/ImportContextDependency.js +43 -3
- package/lib/dependencies/ImportDependency.js +8 -29
- package/lib/dependencies/ImportMetaMainDependency.js +104 -0
- package/lib/dependencies/ImportMetaPlugin.js +59 -15
- package/lib/dependencies/ImportParserPlugin.js +24 -14
- package/lib/dependencies/RequireHeaderDependency.js +20 -21
- package/lib/dependencies/SystemRuntimeModule.js +9 -0
- package/lib/dependencies/WorkerDependency.js +1 -2
- package/lib/dependencies/WorkletDependency.js +1 -2
- package/lib/dependencies/importOptionsCheck.js +47 -0
- package/lib/dll/DelegatedModule.js +18 -1
- package/lib/dll/DllReferencePlugin.js +11 -8
- package/lib/dll/LibManifestPlugin.js +1 -1
- package/lib/errors/AnalyzableBailoutsWarning.js +41 -0
- package/lib/errors/DotenvFileError.js +29 -0
- package/lib/errors/DuplicateModulesWarning.js +12 -7
- package/lib/errors/EmptyCopyPatternWarning.js +26 -0
- package/lib/errors/ExternalStarReexportError.js +44 -0
- package/lib/errors/ImportedBindingAssignmentError.js +30 -0
- package/lib/errors/MissingSourceMapsWarning.js +36 -0
- package/lib/errors/ModuleParseError.js +2 -1
- package/lib/errors/UnusedAssetsWarning.js +36 -0
- package/lib/errors/UnusedFederationWarning.js +35 -0
- package/lib/errors/UnusedModulesWarning.js +38 -0
- package/lib/esm/ExportWebpackRequireRuntimeModule.js +9 -0
- package/lib/esm/ModuleChunkFormatPlugin.js +28 -3
- package/lib/esm/ModuleChunkLoadingPlugin.js +30 -11
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +92 -60
- package/lib/hmr/HotModuleReplacement.runtime.js +8 -2
- package/lib/hmr/HotModuleReplacementRuntimeModule.js +9 -0
- package/lib/html/HtmlGenerator.js +11 -5
- package/lib/html/HtmlModulesPlugin.js +360 -84
- package/lib/html/HtmlParser.js +13 -6
- package/lib/html/builtinEmbeddedRenderer.js +107 -0
- package/lib/html/data.js +121 -7
- package/lib/html/htmlMinify.js +84 -113
- package/lib/html/syntax.js +1067 -569
- package/lib/ids/HashedModuleIdsPlugin.js +2 -1
- package/lib/index.js +3 -0
- package/lib/javascript/JavascriptModule.js +1 -0
- package/lib/javascript/JavascriptModulesPlugin.js +52 -22
- package/lib/javascript/JavascriptParser.js +1255 -728
- package/lib/javascript/StartupHelpers.js +27 -3
- package/lib/javascript/data.js +172 -0
- package/lib/javascript/grammar.js +5546 -0
- package/lib/javascript/parser.js +1494 -0
- package/lib/javascript/regexp.js +1762 -0
- package/lib/javascript/regexpData.js +51 -0
- package/lib/javascript/syntax.js +8696 -5225
- package/lib/library/ModuleLibraryPlugin.js +116 -5
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +22 -0
- package/lib/node/RequireChunkLoadingRuntimeModule.js +22 -0
- package/lib/optimize/ConcatenatedModule.js +133 -25
- package/lib/optimize/ConstExportsPlugin.js +50 -39
- package/lib/optimize/InlineExports.js +20 -123
- package/lib/optimize/MangleExportsPlugin.js +10 -0
- package/lib/optimize/ModuleConcatenationPlugin.js +24 -1
- package/lib/optimize/RealContentHashPlugin.js +68 -9
- package/lib/optimize/SideEffectsFlagPlugin.js +17 -9
- package/lib/performance/AnalyzableBailoutsPlugin.js +115 -0
- package/lib/performance/CacheEffectivenessPlugin.js +4 -3
- package/lib/performance/DuplicateModulesPlugin.js +57 -13
- package/lib/performance/EvalUsagePlugin.js +5 -2
- package/lib/performance/MissingSourceMapsPlugin.js +115 -0
- package/lib/performance/PureAnnotationsPlugin.js +6 -3
- package/lib/performance/TopLevelThisPlugin.js +5 -4
- package/lib/performance/UnusedAssetsPlugin.js +109 -0
- package/lib/performance/UnusedFederationPlugin.js +147 -0
- package/lib/performance/UnusedModulesPlugin.js +141 -0
- package/lib/performance/UnusedReexportsPlugin.js +1 -55
- package/lib/performance/isOnlyReexported.js +65 -0
- package/lib/prefetch/ChunkPrefetchFunctionRuntimeModule.js +25 -5
- package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +2 -0
- package/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js +9 -0
- package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +9 -0
- package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +9 -0
- package/lib/prefetch/ResourceHintPlugin.js +7 -3
- package/lib/prefetch/ResourceHintRuntimeModule.js +9 -0
- package/lib/prefetch/StartupAssetHintRuntimeModule.js +9 -0
- package/lib/rules/RuleSetCompiler.js +211 -4
- package/lib/runtime/AsyncModuleRuntimeModule.js +105 -67
- package/lib/runtime/AutoPublicPathRuntimeModule.js +9 -0
- package/lib/runtime/BaseUriRuntimeModule.js +9 -0
- package/lib/runtime/ChunkNameRuntimeModule.js +9 -0
- package/lib/runtime/EnsureChunkRuntimeModule.js +35 -16
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +9 -0
- package/lib/runtime/GetFullHashRuntimeModule.js +9 -0
- package/lib/runtime/GetMainFilenameRuntimeModule.js +9 -0
- package/lib/runtime/GetWorkletBootstrapRuntimeModule.js +9 -0
- package/lib/runtime/GlobalRuntimeModule.js +9 -0
- package/lib/runtime/HasOwnPropertyRuntimeModule.js +9 -0
- package/lib/runtime/HelperRuntimeModule.js +10 -0
- package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +338 -217
- package/lib/runtime/NonceRuntimeModule.js +9 -0
- package/lib/runtime/OnChunksLoadedRuntimeModule.js +67 -20
- package/lib/runtime/PublicPathRuntimeModule.js +9 -0
- package/lib/runtime/RuntimeIdRuntimeModule.js +9 -0
- package/lib/runtime/SpecNamespaceObjectRuntimeModule.js +90 -0
- package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +9 -0
- package/lib/runtime/StartupEntrypointRuntimeModule.js +9 -0
- package/lib/runtime/SystemContextRuntimeModule.js +9 -0
- package/lib/runtime/ToBinaryRuntimeModule.js +9 -0
- package/lib/schemes/HttpUriPlugin.js +22 -5
- package/lib/serialization/FileMiddleware.js +15 -2
- package/lib/serialization/ObjectMiddleware.js +138 -106
- package/lib/sharing/ConsumeSharedPlugin.js +12 -0
- package/lib/sharing/ConsumeSharedRuntimeModule.js +11 -0
- package/lib/sharing/ShareRuntimeModule.js +9 -0
- package/lib/sharing/declaredShared.js +47 -0
- package/lib/stats/DefaultStatsFactoryPlugin.js +3 -1
- package/lib/stats/DefaultStatsPrinterPlugin.js +3 -0
- package/lib/util/ArrayQueue.js +3 -3
- package/lib/util/SourceProcessor.js +76 -69
- package/lib/util/URLAbsoluteSpecifier.js +3 -1
- package/lib/util/async.js +292 -0
- package/lib/util/buildDiagnostics.js +69 -0
- package/lib/util/conventions.js +5 -1
- package/lib/util/fs.js +27 -1
- package/lib/util/handlerKeys.js +40 -0
- package/lib/util/identifier.js +20 -0
- package/lib/util/internalSerializables.js +6 -0
- package/lib/util/registerExternalSerializer.js +6 -45
- package/lib/wasm-async/AsyncWasmCompileRuntimeModule.js +9 -0
- package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +9 -0
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +9 -0
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +36 -0
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +19 -0
- package/package.json +22 -16
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +388 -76
- package/schemas/plugins/LoaderOptionsPlugin.check.js +1 -1
- package/schemas/plugins/ManifestPlugin.check.js +1 -1
- package/schemas/plugins/SourceMapDevToolPlugin.check.js +1 -1
- package/schemas/plugins/asset/AssetGeneratorOptions.check.js +1 -1
- package/schemas/plugins/asset/AssetResourceGeneratorOptions.check.js +1 -1
- package/schemas/plugins/container/ContainerPlugin.check.js +1 -1
- package/schemas/plugins/container/ModuleFederationPlugin.check.js +1 -1
- package/schemas/plugins/debug/ProfilingPlugin.check.js +1 -1
- package/schemas/plugins/dll/DllReferencePlugin.check.js +1 -1
- package/schemas/plugins/ids/HashedModuleIdsPlugin.check.js +1 -1
- package/schemas/plugins/schemes/HttpUriPlugin.check.js +1 -1
- package/types.d.ts +1440 -331
- package/lib/dependencies/ExportBindingInitFragment.js +0 -191
- package/lib/errors/EntrypointOverlapWarning.js +0 -45
- package/lib/performance/EntrypointOverlapPlugin.js +0 -122
package/lib/config/defaults.js
CHANGED
|
@@ -179,6 +179,7 @@ const {
|
|
|
179
179
|
* portableRecords: NonNullable<Optimization["portableRecords"]>,
|
|
180
180
|
* realContentHash: NonNullable<Optimization["realContentHash"]>,
|
|
181
181
|
* minimize: NonNullable<Optimization["minimize"]>,
|
|
182
|
+
* minimizeOptions: NonNullable<Optimization["minimizeOptions"]>,
|
|
182
183
|
* minimizer: NonNullable<Exclude<Optimization["minimizer"], "...">>,
|
|
183
184
|
* nodeEnv: NonNullable<Optimization["nodeEnv"]>,
|
|
184
185
|
* }} OptimizationNormalizedWithDefaults
|
|
@@ -302,6 +303,15 @@ const A = (obj, prop, factory) => {
|
|
|
302
303
|
}
|
|
303
304
|
};
|
|
304
305
|
|
|
306
|
+
/**
|
|
307
|
+
* Whether the library type emits an ECMAScript module, which only `output.module`
|
|
308
|
+
* output can carry — every other type is written into a script.
|
|
309
|
+
* @param {LibraryType | undefined} type library type
|
|
310
|
+
* @returns {boolean} true, when the type is only emitted as an ECMAScript module
|
|
311
|
+
*/
|
|
312
|
+
const isModuleLibraryType = (type) =>
|
|
313
|
+
type === "module" || type === "modern-module";
|
|
314
|
+
|
|
305
315
|
/**
|
|
306
316
|
* Apply webpack options base defaults.
|
|
307
317
|
* @param {WebpackOptionsNormalized} options options to be modified
|
|
@@ -363,7 +373,6 @@ const applyWebpackOptionsDefaults = (options, compilerIndex) => {
|
|
|
363
373
|
applyExperimentsDefaults(options.experiments, {
|
|
364
374
|
production,
|
|
365
375
|
development,
|
|
366
|
-
targetProperties,
|
|
367
376
|
rules: options.module.rules
|
|
368
377
|
});
|
|
369
378
|
|
|
@@ -407,9 +416,6 @@ const applyWebpackOptionsDefaults = (options, compilerIndex) => {
|
|
|
407
416
|
(typeof target === "string" && target.startsWith("browserslist")) ||
|
|
408
417
|
(Array.isArray(target) &&
|
|
409
418
|
target.some((target) => target.startsWith("browserslist"))),
|
|
410
|
-
outputModule:
|
|
411
|
-
/** @type {NonNullable<ExperimentsNormalized["outputModule"]>} */
|
|
412
|
-
(options.experiments.outputModule),
|
|
413
419
|
development,
|
|
414
420
|
entry: options.entry,
|
|
415
421
|
futureDefaults,
|
|
@@ -422,9 +428,7 @@ const applyWebpackOptionsDefaults = (options, compilerIndex) => {
|
|
|
422
428
|
// is read by another bundler, where an eval wrapper hides `import.meta` from it.
|
|
423
429
|
const noDevSourceMap = /** @type {LibraryType[]} */ (
|
|
424
430
|
options.output.enabledLibraryTypes
|
|
425
|
-
).some(
|
|
426
|
-
(type) => futureDefaults || type === "module" || type === "modern-module"
|
|
427
|
-
);
|
|
431
|
+
).some((type) => futureDefaults || isModuleLibraryType(type));
|
|
428
432
|
|
|
429
433
|
F(
|
|
430
434
|
options,
|
|
@@ -629,13 +633,12 @@ const applyWebpackOptionsDefaults = (options, compilerIndex) => {
|
|
|
629
633
|
* @param {object} options options
|
|
630
634
|
* @param {boolean} options.production is production
|
|
631
635
|
* @param {boolean} options.development is development mode
|
|
632
|
-
* @param {TargetProperties | false} options.targetProperties target properties
|
|
633
636
|
* @param {RuleSetRules} options.rules user `module.rules`, used to resolve the css/html/asyncWebAssembly/typescript "auto" defaults
|
|
634
637
|
* @returns {void}
|
|
635
638
|
*/
|
|
636
639
|
const applyExperimentsDefaults = (
|
|
637
640
|
experiments,
|
|
638
|
-
{ production, development,
|
|
641
|
+
{ production, development, rules }
|
|
639
642
|
) => {
|
|
640
643
|
D(experiments, "futureDefaults", false);
|
|
641
644
|
D(experiments, "backCompat", !experiments.futureDefaults);
|
|
@@ -646,23 +649,6 @@ const applyExperimentsDefaults = (
|
|
|
646
649
|
"asyncWebAssembly",
|
|
647
650
|
experiments.futureDefaults ? true : "auto"
|
|
648
651
|
);
|
|
649
|
-
// the universal target (web + node, neither specific) only works as ESM —
|
|
650
|
-
// unless the target cannot read one, which no output format can repair, so
|
|
651
|
-
// leave `output.chunkFormat` to say so rather than emitting a module the
|
|
652
|
-
// target has already reported it will not load
|
|
653
|
-
const universal =
|
|
654
|
-
Boolean(targetProperties) &&
|
|
655
|
-
/** @type {TargetProperties} */ (targetProperties).node === null &&
|
|
656
|
-
/** @type {TargetProperties} */ (targetProperties).web === null &&
|
|
657
|
-
/** @type {TargetProperties} */ (targetProperties).module !== false;
|
|
658
|
-
// the deno and bun targets only emit ECMAScript modules
|
|
659
|
-
const deno =
|
|
660
|
-
Boolean(targetProperties) &&
|
|
661
|
-
/** @type {TargetProperties} */ (targetProperties).deno === true;
|
|
662
|
-
const bun =
|
|
663
|
-
Boolean(targetProperties) &&
|
|
664
|
-
/** @type {TargetProperties} */ (targetProperties).bun === true;
|
|
665
|
-
D(experiments, "outputModule", universal || deno || bun);
|
|
666
652
|
D(experiments, "lazyCompilation", undefined);
|
|
667
653
|
D(experiments, "buildHttp", undefined);
|
|
668
654
|
D(experiments, "cacheUnaffected", experiments.futureDefaults);
|
|
@@ -918,6 +904,7 @@ const applyJavascriptParserOptionsDefaults = (
|
|
|
918
904
|
D(parserOptions, "wrappedContextRecursive", true);
|
|
919
905
|
D(parserOptions, "wrappedContextCritical", false);
|
|
920
906
|
D(parserOptions, "strictThisContextOnImports", false);
|
|
907
|
+
D(parserOptions, "specNamespaceObject", false);
|
|
921
908
|
D(parserOptions, "importMeta", outputModule ? "preserve-unknown" : true);
|
|
922
909
|
D(parserOptions, "dynamicImportMode", "lazy");
|
|
923
910
|
D(parserOptions, "dynamicImportPrefetch", false);
|
|
@@ -1432,8 +1419,10 @@ const applyModuleDefaults = (
|
|
|
1432
1419
|
type: HTML_MODULE_TYPE,
|
|
1433
1420
|
resolve
|
|
1434
1421
|
});
|
|
1422
|
+
// Exactly `text/html` — a string condition matches by prefix, which
|
|
1423
|
+
// would make a `data:text/htmlx,` module (JavaScript) a page.
|
|
1435
1424
|
rules.push({
|
|
1436
|
-
mimetype:
|
|
1425
|
+
mimetype: /^text\/html$/i,
|
|
1437
1426
|
type: HTML_MODULE_TYPE,
|
|
1438
1427
|
resolve
|
|
1439
1428
|
});
|
|
@@ -1592,7 +1581,6 @@ const applyModuleDefaults = (
|
|
|
1592
1581
|
* @param {string} options.context context
|
|
1593
1582
|
* @param {TargetProperties | false} options.targetProperties target properties
|
|
1594
1583
|
* @param {boolean} options.isAffectedByBrowserslist is affected by browserslist
|
|
1595
|
-
* @param {boolean} options.outputModule is outputModule experiment enabled
|
|
1596
1584
|
* @param {boolean} options.development is development mode
|
|
1597
1585
|
* @param {Entry} options.entry entry option
|
|
1598
1586
|
* @param {boolean} options.futureDefaults is future defaults enabled
|
|
@@ -1605,7 +1593,6 @@ const applyOutputDefaults = (
|
|
|
1605
1593
|
context,
|
|
1606
1594
|
targetProperties: tp,
|
|
1607
1595
|
isAffectedByBrowserslist,
|
|
1608
|
-
outputModule,
|
|
1609
1596
|
development,
|
|
1610
1597
|
entry,
|
|
1611
1598
|
futureDefaults,
|
|
@@ -1661,7 +1648,65 @@ const applyOutputDefaults = (
|
|
|
1661
1648
|
}
|
|
1662
1649
|
});
|
|
1663
1650
|
|
|
1664
|
-
|
|
1651
|
+
/**
|
|
1652
|
+
* Processes the provided fn.
|
|
1653
|
+
* @param {(entryDescription: EntryDescription) => void} fn iterator
|
|
1654
|
+
* @returns {void}
|
|
1655
|
+
*/
|
|
1656
|
+
const forEachEntry = (fn) => {
|
|
1657
|
+
for (const name of Object.keys(entry)) {
|
|
1658
|
+
fn(/** @type {{ [k: string]: EntryDescription }} */ (entry)[name]);
|
|
1659
|
+
}
|
|
1660
|
+
};
|
|
1661
|
+
|
|
1662
|
+
/**
|
|
1663
|
+
* Every library type the configuration states, wherever it was declared.
|
|
1664
|
+
* @returns {LibraryType[]} the declared library types
|
|
1665
|
+
*/
|
|
1666
|
+
const declaredLibraryTypes = () => {
|
|
1667
|
+
/** @type {LibraryType[]} */
|
|
1668
|
+
const types = [];
|
|
1669
|
+
if (output.library && output.library.type) types.push(output.library.type);
|
|
1670
|
+
// A plugin (`ModuleFederationPlugin`) pushed its type here before the defaults;
|
|
1671
|
+
// `"..."` is the extend placeholder `A` resolves, never a type of its own.
|
|
1672
|
+
if (output.enabledLibraryTypes) {
|
|
1673
|
+
for (const type of output.enabledLibraryTypes) {
|
|
1674
|
+
if (type !== "...") types.push(type);
|
|
1675
|
+
}
|
|
1676
|
+
}
|
|
1677
|
+
forEachEntry((desc) => {
|
|
1678
|
+
if (desc.library && desc.library.type) types.push(desc.library.type);
|
|
1679
|
+
});
|
|
1680
|
+
return types;
|
|
1681
|
+
};
|
|
1682
|
+
|
|
1683
|
+
const libraryTypes = declaredLibraryTypes();
|
|
1684
|
+
|
|
1685
|
+
// A library type that is an ECMAScript module is another spelling of
|
|
1686
|
+
// `output.module`, so it turns it on rather than disagreeing with it.
|
|
1687
|
+
if (libraryTypes.some(isModuleLibraryType)) {
|
|
1688
|
+
output.module = true;
|
|
1689
|
+
}
|
|
1690
|
+
|
|
1691
|
+
// Every other library type is read out of a script, which is a statement that
|
|
1692
|
+
// the output is not an ECMAScript module — so it holds the default below back.
|
|
1693
|
+
const hasScriptLibrary = libraryTypes.some(
|
|
1694
|
+
(type) => !isModuleLibraryType(type)
|
|
1695
|
+
);
|
|
1696
|
+
|
|
1697
|
+
// the universal target (web + node, neither specific), deno and bun only work
|
|
1698
|
+
// as ESM, unless `module: false` says the target cannot read one
|
|
1699
|
+
F(output, "module", () =>
|
|
1700
|
+
Boolean(
|
|
1701
|
+
tp &&
|
|
1702
|
+
((tp.node === null && tp.web === null && tp.module !== false) ||
|
|
1703
|
+
tp.deno === true ||
|
|
1704
|
+
tp.bun === true ||
|
|
1705
|
+
// webpack@6 emits ESM wherever the target reads one — a browserslist
|
|
1706
|
+
// query (or `esX`/`nodeX`) without ESM support keeps script output
|
|
1707
|
+
(futureDefaults && tp.module !== false && !hasScriptLibrary))
|
|
1708
|
+
)
|
|
1709
|
+
);
|
|
1665
1710
|
|
|
1666
1711
|
const environment = /** @type {Environment} */ (output.environment);
|
|
1667
1712
|
/**
|
|
@@ -1747,6 +1792,12 @@ const applyOutputDefaults = (
|
|
|
1747
1792
|
"generator",
|
|
1748
1793
|
() => tp && optimistic(/** @type {boolean | undefined} */ (tp.generator))
|
|
1749
1794
|
);
|
|
1795
|
+
F(
|
|
1796
|
+
environment,
|
|
1797
|
+
"topLevelAwait",
|
|
1798
|
+
() =>
|
|
1799
|
+
tp && optimistic(/** @type {boolean | undefined} */ (tp.topLevelAwait))
|
|
1800
|
+
);
|
|
1750
1801
|
F(
|
|
1751
1802
|
environment,
|
|
1752
1803
|
"forOf",
|
|
@@ -1981,7 +2032,7 @@ const applyOutputDefaults = (
|
|
|
1981
2032
|
"For the selected environment is no default script chunk format available:\n" +
|
|
1982
2033
|
`${
|
|
1983
2034
|
tp.module
|
|
1984
|
-
? "Module ('module') can be chosen when ES modules are available (please set '
|
|
2035
|
+
? "Module ('module') can be chosen when ES modules are available (please set 'output.module' to `true`)"
|
|
1985
2036
|
: ""
|
|
1986
2037
|
}\n` +
|
|
1987
2038
|
"JSONP Array push ('array-push') can be chosen when 'document' or 'importScripts' is available.\n" +
|
|
@@ -2128,16 +2179,6 @@ const applyOutputDefaults = (
|
|
|
2128
2179
|
D(trustedTypes, "onPolicyCreationFailure", "stop");
|
|
2129
2180
|
}
|
|
2130
2181
|
|
|
2131
|
-
/**
|
|
2132
|
-
* Processes the provided fn.
|
|
2133
|
-
* @param {(entryDescription: EntryDescription) => void} fn iterator
|
|
2134
|
-
* @returns {void}
|
|
2135
|
-
*/
|
|
2136
|
-
const forEachEntry = (fn) => {
|
|
2137
|
-
for (const name of Object.keys(entry)) {
|
|
2138
|
-
fn(/** @type {{ [k: string]: EntryDescription }} */ (entry)[name]);
|
|
2139
|
-
}
|
|
2140
|
-
};
|
|
2141
2182
|
A(output, "enabledLibraryTypes", () => {
|
|
2142
2183
|
/** @type {LibraryType[]} */
|
|
2143
2184
|
const enabledLibraryTypes = [];
|
|
@@ -2388,6 +2429,7 @@ const applyPerformanceDefaults = (performance, { production }) => {
|
|
|
2388
2429
|
// Stands in for every check left unset, so an explicit one still wins.
|
|
2389
2430
|
const all = performance.all !== undefined ? performance.all : false;
|
|
2390
2431
|
|
|
2432
|
+
D(performance, "analyzableBailouts", all);
|
|
2391
2433
|
D(performance, "asyncChunkWaterfalls", all);
|
|
2392
2434
|
D(performance, "broadContexts", all);
|
|
2393
2435
|
D(performance, "cacheEffectiveness", all);
|
|
@@ -2396,8 +2438,6 @@ const applyPerformanceDefaults = (performance, { production }) => {
|
|
|
2396
2438
|
D(performance, "duplicateModules", all);
|
|
2397
2439
|
D(performance, "duplicatePackages", all);
|
|
2398
2440
|
D(performance, "dynamicExports", all);
|
|
2399
|
-
D(performance, "entrypointOverlap", all);
|
|
2400
|
-
D(performance, "embeddedSourceMaps", all);
|
|
2401
2441
|
D(performance, "evalUsage", all);
|
|
2402
2442
|
D(performance, "hotspots", all);
|
|
2403
2443
|
D(performance, "legacyJavascript", all);
|
|
@@ -2410,14 +2450,13 @@ const applyPerformanceDefaults = (performance, { production }) => {
|
|
|
2410
2450
|
D(performance, "redundantDynamicImports", all);
|
|
2411
2451
|
D(performance, "scopeHoistingBailouts", all);
|
|
2412
2452
|
D(performance, "splitChunksCapped", all);
|
|
2453
|
+
D(performance, "sourceMaps", all);
|
|
2413
2454
|
D(performance, "tinyChunks", all);
|
|
2414
2455
|
D(performance, "topLevelThis", all);
|
|
2415
2456
|
D(performance, "unsplitVendors", all);
|
|
2416
|
-
D(performance, "
|
|
2417
|
-
D(performance, "
|
|
2418
|
-
D(performance, "
|
|
2419
|
-
D(performance, "unusedReexports", all);
|
|
2420
|
-
D(performance, "unusedRules", all);
|
|
2457
|
+
D(performance, "unusedAssets", all);
|
|
2458
|
+
D(performance, "unusedConfig", all);
|
|
2459
|
+
D(performance, "unusedModules", all);
|
|
2421
2460
|
F(performance, "hints", () => (production ? "warning" : false));
|
|
2422
2461
|
};
|
|
2423
2462
|
|
|
@@ -2463,20 +2502,28 @@ const applyOptimizationDefaults = (
|
|
|
2463
2502
|
D(optimization, "mangleWasmImports", false);
|
|
2464
2503
|
D(optimization, "portableRecords", records);
|
|
2465
2504
|
D(optimization, "realContentHash", production);
|
|
2466
|
-
|
|
2467
|
-
//
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2505
|
+
// A plugin assigning the object shorthand in `apply()` runs after
|
|
2506
|
+
// normalization: it replaces `minimizeOptions`, keeping `minimize` boolean.
|
|
2507
|
+
const minimizeAssignedInApply = /** @type {unknown} */ (
|
|
2508
|
+
optimization.minimize
|
|
2509
|
+
);
|
|
2510
|
+
if (typeof minimizeAssignedInApply === "object") {
|
|
2511
|
+
optimization.minimizeOptions = /** @type {OptimizationMinimizeOptions} */ (
|
|
2512
|
+
minimizeAssignedInApply
|
|
2513
|
+
);
|
|
2514
|
+
optimization.minimize = true;
|
|
2472
2515
|
}
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2516
|
+
D(optimization, "minimize", production);
|
|
2517
|
+
F(optimization, "minimizeOptions", () => ({}));
|
|
2518
|
+
const minimizeOptions =
|
|
2519
|
+
/** @type {NonNullable<Optimization["minimizeOptions"]>} */
|
|
2520
|
+
(optimization.minimizeOptions);
|
|
2521
|
+
if (optimization.minimize) {
|
|
2522
|
+
// Canonicalize the per-asset-type options: the JS minimizer's defaults
|
|
2523
|
+
// become visible in the resolved config rather than hidden in the wiring.
|
|
2524
|
+
F(minimizeOptions, "javascript", () => ({ compress: { passes: 2 } }));
|
|
2525
|
+
F(minimizeOptions, "css", () => ({}));
|
|
2526
|
+
F(minimizeOptions, "html", () => ({}));
|
|
2480
2527
|
}
|
|
2481
2528
|
A(optimization, "minimizer", () => [
|
|
2482
2529
|
{
|
|
@@ -2501,10 +2548,9 @@ const applyOptimizationDefaults = (
|
|
|
2501
2548
|
compiler
|
|
2502
2549
|
);
|
|
2503
2550
|
|
|
2504
|
-
//
|
|
2505
|
-
// object here: `false` disables a type, an object is its options.
|
|
2551
|
+
// Per asset type: `false` disables that type, an object is its options.
|
|
2506
2552
|
const minimizeByType = /** @type {OptimizationMinimizeOptions} */ (
|
|
2507
|
-
compiler.options.optimization.
|
|
2553
|
+
compiler.options.optimization.minimizeOptions
|
|
2508
2554
|
);
|
|
2509
2555
|
const terserOptions = minimizeByType.javascript || {
|
|
2510
2556
|
compress: { passes: 2 }
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
"use strict";
|
|
7
7
|
|
|
8
8
|
const util = require("util");
|
|
9
|
+
const { fileUrlToPath } = require("../util/identifier");
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* @import {
|
|
@@ -138,6 +139,28 @@ const keyedNestedConfig = (value, fn, customKeys) => {
|
|
|
138
139
|
return result;
|
|
139
140
|
};
|
|
140
141
|
|
|
142
|
+
/**
|
|
143
|
+
* Converts a file URL to the path it names. Anything that is not a string is
|
|
144
|
+
* returned unchanged, so `false` and `undefined` pass through.
|
|
145
|
+
* @template {string | false | undefined} T
|
|
146
|
+
* @param {T} pathOrUrl an absolute path, a file URL, `false` or `undefined`
|
|
147
|
+
* @returns {T} an absolute path, `false` or `undefined`
|
|
148
|
+
*/
|
|
149
|
+
const optionalFileUrlToPath = (pathOrUrl) =>
|
|
150
|
+
typeof pathOrUrl === "string"
|
|
151
|
+
? /** @type {T} */ (fileUrlToPath(pathOrUrl))
|
|
152
|
+
: pathOrUrl;
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Converts every file URL of a list to the path it names.
|
|
156
|
+
* @param {(string | RegExp)[]} pathsOrUrls absolute paths, file URLs or regular expressions
|
|
157
|
+
* @returns {(string | RegExp)[]} absolute paths and regular expressions
|
|
158
|
+
*/
|
|
159
|
+
const fileUrlsToPaths = (pathsOrUrls) =>
|
|
160
|
+
pathsOrUrls.map((pathOrUrl) =>
|
|
161
|
+
typeof pathOrUrl === "string" ? fileUrlToPath(pathOrUrl) : pathOrUrl
|
|
162
|
+
);
|
|
163
|
+
|
|
141
164
|
/**
|
|
142
165
|
* Normalize `output.resourceHints` into its object form: the scalar / array /
|
|
143
166
|
* function shorthand becomes `{ initial: <value> }` (with `"preload"` aliased to
|
|
@@ -162,6 +185,40 @@ const normalizeResourceHints = (resourceHints) => {
|
|
|
162
185
|
return { initial: alias(resourceHints) };
|
|
163
186
|
};
|
|
164
187
|
|
|
188
|
+
/**
|
|
189
|
+
* @typedef {object} NormalizedBuildDependencyItem
|
|
190
|
+
* @property {string} dependency request to resolve
|
|
191
|
+
* @property {boolean} optional when true the dependency may be missing
|
|
192
|
+
*/
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* @param {import("../../declarations/WebpackOptions").BuildDependencyItem} item build dependency
|
|
196
|
+
* @returns {NormalizedBuildDependencyItem} normalized build dependency
|
|
197
|
+
*/
|
|
198
|
+
const normalizeBuildDependencyItem = (item) => {
|
|
199
|
+
if (typeof item === "string") {
|
|
200
|
+
return { dependency: item, optional: false };
|
|
201
|
+
}
|
|
202
|
+
return {
|
|
203
|
+
dependency: item.dependency,
|
|
204
|
+
optional: item.optional === true
|
|
205
|
+
};
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* @param {import("../../declarations/WebpackOptions").FileCacheOptions["buildDependencies"]=} buildDependencies build dependencies
|
|
210
|
+
* @returns {Record<string, NormalizedBuildDependencyItem[]>} normalized build dependencies
|
|
211
|
+
*/
|
|
212
|
+
const normalizeBuildDependencies = (buildDependencies) => {
|
|
213
|
+
/** @type {Record<string, NormalizedBuildDependencyItem[]>} */
|
|
214
|
+
const result = Object.create(null);
|
|
215
|
+
if (buildDependencies === undefined) return result;
|
|
216
|
+
for (const key of Object.keys(buildDependencies)) {
|
|
217
|
+
result[key] = buildDependencies[key].map(normalizeBuildDependencyItem);
|
|
218
|
+
}
|
|
219
|
+
return result;
|
|
220
|
+
};
|
|
221
|
+
|
|
165
222
|
/**
|
|
166
223
|
* Gets normalized webpack options.
|
|
167
224
|
* @param {WebpackOptions} config input config
|
|
@@ -189,9 +246,11 @@ const getNormalizedWebpackOptions = (config) => ({
|
|
|
189
246
|
maxMemoryGenerations: cache.maxMemoryGenerations,
|
|
190
247
|
maxAge: cache.maxAge,
|
|
191
248
|
profile: cache.profile,
|
|
192
|
-
buildDependencies:
|
|
193
|
-
|
|
194
|
-
|
|
249
|
+
buildDependencies: normalizeBuildDependencies(
|
|
250
|
+
cache.buildDependencies
|
|
251
|
+
),
|
|
252
|
+
cacheDirectory: optionalFileUrlToPath(cache.cacheDirectory),
|
|
253
|
+
cacheLocation: optionalFileUrlToPath(cache.cacheLocation),
|
|
195
254
|
hashAlgorithm: cache.hashAlgorithm,
|
|
196
255
|
compression: cache.compression,
|
|
197
256
|
idleTimeout: cache.idleTimeout,
|
|
@@ -214,7 +273,7 @@ const getNormalizedWebpackOptions = (config) => ({
|
|
|
214
273
|
}
|
|
215
274
|
})
|
|
216
275
|
),
|
|
217
|
-
context: config.context,
|
|
276
|
+
context: optionalFileUrlToPath(config.context),
|
|
218
277
|
dependencies: config.dependencies,
|
|
219
278
|
devServer: optionalNestedConfig(config.devServer, (devServer) => {
|
|
220
279
|
if (devServer === false) return false;
|
|
@@ -331,7 +390,14 @@ const getNormalizedWebpackOptions = (config) => ({
|
|
|
331
390
|
cacheGroups: cloneObject(splitChunks.cacheGroups)
|
|
332
391
|
}
|
|
333
392
|
),
|
|
334
|
-
|
|
393
|
+
// TODO webpack 6: normalize `minimize` to the per-asset-type object and
|
|
394
|
+
// drop `minimizeOptions` — a breaking change for what plugins read back.
|
|
395
|
+
minimize:
|
|
396
|
+
typeof optimization.minimize === "object" ? true : optimization.minimize,
|
|
397
|
+
minimizeOptions: getNormalizedOptimizationMinimizeOptions(
|
|
398
|
+
optimization.minimize,
|
|
399
|
+
optimization.minimizeOptions
|
|
400
|
+
),
|
|
335
401
|
minimizer:
|
|
336
402
|
optimization.minimizer !== undefined
|
|
337
403
|
? /** @type {OptimizationNormalized["minimizer"]} */ (
|
|
@@ -374,6 +440,9 @@ const getNormalizedWebpackOptions = (config) => ({
|
|
|
374
440
|
cssChunkFilename: output.cssChunkFilename,
|
|
375
441
|
clean: output.clean,
|
|
376
442
|
compareBeforeEmit: output.compareBeforeEmit,
|
|
443
|
+
copy: optionalNestedConfig(output.copy, (copy) => ({
|
|
444
|
+
patterns: typeof copy === "string" ? [copy] : [...copy]
|
|
445
|
+
})),
|
|
377
446
|
crossOriginLoading: output.crossOriginLoading,
|
|
378
447
|
devtoolFallbackModuleFilenameTemplate:
|
|
379
448
|
output.devtoolFallbackModuleFilenameTemplate,
|
|
@@ -432,7 +501,7 @@ const getNormalizedWebpackOptions = (config) => ({
|
|
|
432
501
|
: libraryBase.umdNamedDefine
|
|
433
502
|
},
|
|
434
503
|
module: output.module,
|
|
435
|
-
path: output.path,
|
|
504
|
+
path: optionalFileUrlToPath(output.path),
|
|
436
505
|
pathinfo: output.pathinfo,
|
|
437
506
|
publicPath: output.publicPath,
|
|
438
507
|
resourceHints: normalizeResourceHints(output.resourceHints),
|
|
@@ -474,14 +543,16 @@ const getNormalizedWebpackOptions = (config) => ({
|
|
|
474
543
|
nestedArray(config.plugins, (p) => p.filter(Boolean))
|
|
475
544
|
),
|
|
476
545
|
profile: config.profile,
|
|
477
|
-
recordsInputPath:
|
|
546
|
+
recordsInputPath: optionalFileUrlToPath(
|
|
478
547
|
config.recordsInputPath !== undefined
|
|
479
548
|
? config.recordsInputPath
|
|
480
|
-
: config.recordsPath
|
|
481
|
-
|
|
549
|
+
: config.recordsPath
|
|
550
|
+
),
|
|
551
|
+
recordsOutputPath: optionalFileUrlToPath(
|
|
482
552
|
config.recordsOutputPath !== undefined
|
|
483
553
|
? config.recordsOutputPath
|
|
484
|
-
: config.recordsPath
|
|
554
|
+
: config.recordsPath
|
|
555
|
+
),
|
|
485
556
|
resolve: nestedConfig(config.resolve, (resolve) => ({
|
|
486
557
|
...resolve,
|
|
487
558
|
byDependency: keyedNestedConfig(resolve.byDependency, cloneObject)
|
|
@@ -517,9 +588,15 @@ const getNormalizedWebpackOptions = (config) => ({
|
|
|
517
588
|
hash: contextModule.hash
|
|
518
589
|
})
|
|
519
590
|
),
|
|
520
|
-
immutablePaths: optionalNestedArray(
|
|
521
|
-
|
|
522
|
-
|
|
591
|
+
immutablePaths: optionalNestedArray(
|
|
592
|
+
snapshot.immutablePaths,
|
|
593
|
+
fileUrlsToPaths
|
|
594
|
+
),
|
|
595
|
+
managedPaths: optionalNestedArray(snapshot.managedPaths, fileUrlsToPaths),
|
|
596
|
+
unmanagedPaths: optionalNestedArray(
|
|
597
|
+
snapshot.unmanagedPaths,
|
|
598
|
+
fileUrlsToPaths
|
|
599
|
+
)
|
|
523
600
|
})),
|
|
524
601
|
stats: nestedConfig(config.stats, (stats) => {
|
|
525
602
|
if (stats === false) {
|
|
@@ -612,15 +689,18 @@ const getNormalizedEntryStatic = (entry) => {
|
|
|
612
689
|
};
|
|
613
690
|
|
|
614
691
|
/**
|
|
615
|
-
* Gets
|
|
616
|
-
*
|
|
692
|
+
* Gets the per-asset-type minimize options. `minimize` itself stays a boolean,
|
|
693
|
+
* and its object form is a shorthand an explicit `minimizeOptions` overrides.
|
|
617
694
|
* @param {Optimization["minimize"]} minimize minimize option
|
|
618
|
-
* @
|
|
695
|
+
* @param {Optimization["minimizeOptions"]} minimizeOptions minimizeOptions option
|
|
696
|
+
* @returns {OptimizationNormalized["minimizeOptions"]} normalized minimize options
|
|
619
697
|
*/
|
|
620
|
-
const
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
698
|
+
const getNormalizedOptimizationMinimizeOptions = (
|
|
699
|
+
minimize,
|
|
700
|
+
minimizeOptions
|
|
701
|
+
) => {
|
|
702
|
+
if (minimizeOptions !== undefined) return cloneObject(minimizeOptions);
|
|
703
|
+
if (typeof minimize !== "object") return;
|
|
624
704
|
return cloneObject(minimize);
|
|
625
705
|
};
|
|
626
706
|
|
package/lib/config/target.js
CHANGED
|
@@ -82,6 +82,7 @@ const getDefaultTarget = (context) => {
|
|
|
82
82
|
* @property {boolean | null} templateLiteral template literal is available
|
|
83
83
|
* @property {boolean | null} asyncFunction async functions and await are available
|
|
84
84
|
* @property {boolean | null} generator generator functions and yield are available
|
|
85
|
+
* @property {boolean | null} topLevelAwait top-level await is available
|
|
85
86
|
* @property {(boolean | null)=} deferImport deferred evaluation (`import defer`, `import.defer()`) is available (optional; absent means "assume unavailable")
|
|
86
87
|
* @property {(boolean | null)=} sourceImport source phase imports (`import source`, `import.source()`) are available (optional; absent means "assume unavailable")
|
|
87
88
|
*/
|
|
@@ -269,6 +270,8 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
269
270
|
arrowFunction: v(6),
|
|
270
271
|
asyncFunction: v(7, 6),
|
|
271
272
|
generator: v(4),
|
|
273
|
+
// v14.8.0
|
|
274
|
+
topLevelAwait: v(14, 8),
|
|
272
275
|
forOf: v(5),
|
|
273
276
|
destructuring: v(6),
|
|
274
277
|
bigIntLiteral: v(10, 4),
|
|
@@ -329,6 +332,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
329
332
|
templateLiteral: true,
|
|
330
333
|
asyncFunction: true,
|
|
331
334
|
generator: true,
|
|
335
|
+
topLevelAwait: true,
|
|
332
336
|
// import defer - v2.8.0
|
|
333
337
|
deferImport: v(2, 8),
|
|
334
338
|
// import source - v2.6.0
|
|
@@ -380,6 +384,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
380
384
|
arrowFunction: true,
|
|
381
385
|
asyncFunction: true,
|
|
382
386
|
generator: true,
|
|
387
|
+
topLevelAwait: true,
|
|
383
388
|
forOf: true,
|
|
384
389
|
destructuring: true,
|
|
385
390
|
bigIntLiteral: true,
|
|
@@ -437,6 +442,8 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
437
442
|
arrowFunction: v(1, 1),
|
|
438
443
|
asyncFunction: v(1, 7),
|
|
439
444
|
generator: v(1, 1),
|
|
445
|
+
// 12.0.0 - Chromium 89
|
|
446
|
+
topLevelAwait: v(12),
|
|
440
447
|
forOf: v(0, 36),
|
|
441
448
|
destructuring: v(1, 1),
|
|
442
449
|
bigIntLiteral: v(4),
|
|
@@ -486,6 +493,8 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
486
493
|
arrowFunction: v(0, 15),
|
|
487
494
|
asyncFunction: v(0, 21),
|
|
488
495
|
generator: v(0, 15),
|
|
496
|
+
// 0.52.0 - Chromium 89
|
|
497
|
+
topLevelAwait: v(0, 52),
|
|
489
498
|
forOf: v(0, 13),
|
|
490
499
|
destructuring: v(0, 15),
|
|
491
500
|
bigIntLiteral: v(0, 32),
|
|
@@ -515,6 +524,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
515
524
|
destructuring: v >= 2015,
|
|
516
525
|
module: v >= 2015,
|
|
517
526
|
asyncFunction: v >= 2017,
|
|
527
|
+
topLevelAwait: v >= 2022,
|
|
518
528
|
generator: v >= 2015,
|
|
519
529
|
globalThis: v >= 2020,
|
|
520
530
|
symbol: v >= 2015,
|
|
@@ -14,6 +14,7 @@ const FallbackModuleFactory = require("./FallbackModuleFactory");
|
|
|
14
14
|
const RemoteModule = require("./RemoteModule");
|
|
15
15
|
const RemoteRuntimeModule = require("./RemoteRuntimeModule");
|
|
16
16
|
const RemoteToExternalDependency = require("./RemoteToExternalDependency");
|
|
17
|
+
const { addDeclaredRemotes } = require("./declaredRemotes");
|
|
17
18
|
const { parseOptions } = require("./options");
|
|
18
19
|
|
|
19
20
|
/**
|
|
@@ -91,6 +92,11 @@ class ContainerReferencePlugin {
|
|
|
91
92
|
compiler.hooks.compilation.tap(
|
|
92
93
|
PLUGIN_NAME,
|
|
93
94
|
(compilation, { normalModuleFactory }) => {
|
|
95
|
+
addDeclaredRemotes(
|
|
96
|
+
compilation,
|
|
97
|
+
remotes.map(([key]) => key)
|
|
98
|
+
);
|
|
99
|
+
|
|
94
100
|
compilation.dependencyFactories.set(
|
|
95
101
|
RemoteToExternalDependency,
|
|
96
102
|
normalModuleFactory
|
|
@@ -20,6 +20,15 @@ class RemoteRuntimeModule extends RuntimeModule {
|
|
|
20
20
|
super("remotes loading");
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
/**
|
|
24
|
+
* The `[handlerMap, key]` pairs this module installs onto a chunk handler map
|
|
25
|
+
* such as `__webpack_require__.f`, or `null` where it cannot name them.
|
|
26
|
+
* @returns {[string, string][] | null} installed chunk handlers (do not mutate)
|
|
27
|
+
*/
|
|
28
|
+
getInstalledChunkHandlers() {
|
|
29
|
+
return [[RuntimeGlobals.ensureChunkHandlers, "remotes"]];
|
|
30
|
+
}
|
|
31
|
+
|
|
23
32
|
/**
|
|
24
33
|
* Generates runtime code for this runtime module.
|
|
25
34
|
* @returns {string | null} runtime code
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/*
|
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
3
|
+
Author Alexander Akait @alexander-akait
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
"use strict";
|
|
7
|
+
|
|
8
|
+
/** @import Compilation from "../Compilation" */
|
|
9
|
+
|
|
10
|
+
/** @type {WeakMap<Compilation, Set<string>>} */
|
|
11
|
+
const DECLARED_REMOTES = new WeakMap();
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The remote names this build declared, in declaration order, which is the
|
|
15
|
+
* order `factorize` resolves a request against them in.
|
|
16
|
+
* @param {Compilation} compilation the compilation
|
|
17
|
+
* @returns {Set<string> | undefined} the declared names, when any were declared
|
|
18
|
+
*/
|
|
19
|
+
const getDeclaredRemotes = (compilation) => DECLARED_REMOTES.get(compilation);
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Records declared names, adding to any a previous application made.
|
|
23
|
+
* @param {Compilation} compilation the compilation
|
|
24
|
+
* @param {Iterable<string>} names what this application declared
|
|
25
|
+
* @returns {void}
|
|
26
|
+
*/
|
|
27
|
+
const addDeclaredRemotes = (compilation, names) => {
|
|
28
|
+
let declared = DECLARED_REMOTES.get(compilation);
|
|
29
|
+
|
|
30
|
+
if (declared === undefined) {
|
|
31
|
+
declared = new Set();
|
|
32
|
+
DECLARED_REMOTES.set(compilation, declared);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
for (const name of names) declared.add(name);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
module.exports.addDeclaredRemotes = addDeclaredRemotes;
|
|
39
|
+
module.exports.getDeclaredRemotes = getDeclaredRemotes;
|
package/lib/css/CssGenerator.js
CHANGED
|
@@ -32,6 +32,7 @@ const Template = require("../Template");
|
|
|
32
32
|
const { getPresentKinds } = require("../TemplatedPathPlugin");
|
|
33
33
|
const CssImportDependency = require("../dependencies/CssImportDependency");
|
|
34
34
|
const HarmonyImportSideEffectDependency = require("../dependencies/HarmonyImportSideEffectDependency");
|
|
35
|
+
const LoaderImportDependency = require("../dependencies/LoaderImportDependency");
|
|
35
36
|
|
|
36
37
|
const { encodeMappings } = require("../util/createMappings");
|
|
37
38
|
const {
|
|
@@ -668,6 +669,13 @@ class CssGenerator extends Generator {
|
|
|
668
669
|
continue;
|
|
669
670
|
}
|
|
670
671
|
|
|
672
|
+
// `importModule()` executes the module as JavaScript, and its dependency
|
|
673
|
+
// carries no origin module (`connectOrigin: false` in `LoaderPlugin`).
|
|
674
|
+
if (connection.dependency instanceof LoaderImportDependency) {
|
|
675
|
+
hasJs = true;
|
|
676
|
+
continue;
|
|
677
|
+
}
|
|
678
|
+
|
|
671
679
|
if (!connection.originModule) {
|
|
672
680
|
continue;
|
|
673
681
|
}
|