webpack 5.108.4 → 5.109.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/lib/APIPlugin.js +48 -29
- package/lib/CacheFacade.js +8 -0
- package/lib/ChunkGroup.js +1 -0
- package/lib/CompatibilityPlugin.js +31 -29
- package/lib/Compilation.js +49 -4
- package/lib/ConstPlugin.js +11 -11
- package/lib/ContextModule.js +239 -6
- package/lib/ContextModuleFactory.js +139 -14
- package/lib/DefinePlugin.js +396 -101
- package/lib/Entrypoint.js +1 -1
- package/lib/ExportsInfoApiPlugin.js +2 -2
- package/lib/ExternalModule.js +107 -5
- package/lib/ExternalModuleFactoryPlugin.js +20 -1
- package/lib/FileSystemInfo.js +130 -74
- package/lib/HotModuleReplacementPlugin.js +18 -15
- package/lib/Module.js +3 -0
- package/lib/ModuleFilenameHelpers.js +2 -2
- package/lib/ModuleTypeConstants.js +8 -1
- package/lib/MultiCompiler.js +13 -2
- package/lib/MultiWatching.js +1 -0
- package/lib/NodeStuffPlugin.js +51 -33
- package/lib/NormalModule.js +169 -401
- package/lib/NormalModuleFactory.js +76 -2
- package/lib/ProgressPlugin.js +211 -119
- package/lib/ProvidePlugin.js +2 -2
- package/lib/RuntimeGlobals.js +47 -0
- package/lib/RuntimePlugin.js +33 -0
- package/lib/RuntimeTemplate.js +304 -16
- package/lib/UseStrictPlugin.js +1 -1
- package/lib/WebpackIsIncludedPlugin.js +1 -1
- package/lib/WebpackOptionsApply.js +24 -19
- package/lib/asset/AssetGenerator.js +110 -28
- package/lib/asset/AssetModulesPlugin.js +92 -2
- package/lib/asset/WebManifestGenerator.js +164 -0
- package/lib/asset/WebManifestParser.js +130 -0
- package/lib/async-modules/AwaitDependenciesInitFragment.js +14 -4
- package/lib/async-modules/isGeneratorLowered.js +26 -0
- package/lib/cache/PackFileCacheStrategy.js +9 -3
- package/lib/config/browserslistTargetHandler.js +40 -0
- package/lib/config/defaults.js +219 -29
- package/lib/config/normalization.js +26 -0
- package/lib/config/target.js +9 -1
- package/lib/css/CssGenerator.js +40 -31
- package/lib/css/CssLoadingRuntimeModule.js +5 -1
- package/lib/css/CssModulesPlugin.js +13 -0
- package/lib/css/CssParser.js +594 -263
- package/lib/css/syntax.js +875 -462
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +6 -6
- package/lib/dependencies/AMDPlugin.js +2 -2
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +13 -13
- package/lib/dependencies/CommonJsDependencyHelpers.js +39 -0
- package/lib/dependencies/CommonJsExportsDependency.js +47 -2
- package/lib/dependencies/CommonJsExportsParserPlugin.js +10 -10
- package/lib/dependencies/CommonJsImportsParserPlugin.js +18 -18
- package/lib/dependencies/CommonJsPlugin.js +2 -2
- package/lib/dependencies/CommonJsRequireDependency.js +26 -1
- package/lib/dependencies/CommonJsSelfReferenceDependency.js +32 -1
- package/lib/dependencies/ContextDependencyHelpers.js +3 -3
- package/lib/dependencies/CreateRequireParserPlugin.js +6 -6
- package/lib/dependencies/CssIcssExportDependency.js +162 -71
- package/lib/dependencies/CssUrlDependency.js +35 -4
- package/lib/dependencies/ExternalModuleInitFragmentDependency.js +2 -2
- package/lib/dependencies/HarmonyCompatibilityDependency.js +32 -14
- package/lib/dependencies/HarmonyDetectionParserPlugin.js +43 -13
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +7 -19
- package/lib/dependencies/HarmonyImportDependency.js +12 -1
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +11 -11
- package/lib/dependencies/HarmonyModulesPlugin.js +6 -0
- package/lib/dependencies/HarmonyTopLevelThisParserPlugin.js +1 -1
- package/lib/dependencies/HtmlEntryDependency.js +797 -172
- package/lib/dependencies/HtmlSourceDependency.js +26 -0
- package/lib/dependencies/ImportDependency.js +43 -1
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +31 -18
- package/lib/dependencies/ImportMetaContextPlugin.js +38 -7
- package/lib/dependencies/ImportMetaGlobDependency.js +81 -0
- package/lib/dependencies/ImportMetaGlobDependencyParserPlugin.js +78 -0
- package/lib/dependencies/ImportMetaGlobHelpers.js +660 -0
- package/lib/dependencies/ImportMetaPlugin.js +532 -180
- package/lib/dependencies/ImportMetaResolveDependency.js +90 -0
- package/lib/dependencies/ImportParserPlugin.js +80 -17
- package/lib/dependencies/ImportPhase.js +10 -8
- package/lib/dependencies/LoaderPlugin.js +5 -1
- package/lib/dependencies/RequireContextDependencyParserPlugin.js +1 -1
- package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +3 -6
- package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +4 -11
- package/lib/dependencies/SystemPlugin.js +2 -4
- package/lib/dependencies/TopLevelAwaitDependency.js +93 -0
- package/lib/dependencies/URLDependency.js +141 -21
- package/lib/dependencies/{WorkerPlugin.js → WorkerAndWorkletPlugin.js} +324 -112
- package/lib/dependencies/WorkerDependency.js +86 -18
- package/lib/dependencies/WorkletDependency.js +278 -0
- package/lib/dll/DelegatedModuleFactoryPlugin.js +19 -0
- package/lib/errors/EnvironmentNotSupportAsyncWarning.js +1 -1
- package/lib/errors/LoaderLoadingError.js +20 -0
- package/lib/errors/ModuleParseError.js +39 -22
- package/lib/errors/NodeStuffInWebError.js +1 -1
- package/lib/esm/ModuleChunkFormatPlugin.js +47 -14
- package/lib/esm/ModuleChunkLoadingPlugin.js +8 -1
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +29 -1
- package/lib/hmr/lazyCompilationBackend.js +32 -8
- package/lib/html/HtmlGenerator.js +887 -15
- package/lib/html/HtmlModule.js +2 -2
- package/lib/html/HtmlModulesPlugin.js +610 -166
- package/lib/html/HtmlParser.js +603 -247
- package/lib/html/favicon.svg +1 -0
- package/lib/html/syntax.js +1264 -661
- package/lib/ids/IdHelpers.js +1 -1
- package/lib/index.js +6 -0
- package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +4 -5
- package/lib/javascript/BasicEvaluatedExpression.js +366 -48
- package/lib/javascript/JavascriptGenerator.js +197 -49
- package/lib/javascript/JavascriptModulesPlugin.js +178 -24
- package/lib/javascript/JavascriptParser.js +701 -355
- package/lib/javascript/JavascriptParserHelpers.js +3 -6
- package/lib/javascript/syntax.js +4380 -0
- package/lib/library/ModuleLibraryPlugin.js +38 -1
- package/lib/loaders/LoaderRunner.js +714 -0
- package/lib/loaders/loadLoader.js +100 -0
- package/lib/node/ReadFileCompileAsyncWasmPlugin.js +19 -0
- package/lib/node/ReadFileCompileWasmPlugin.js +14 -0
- package/lib/optimize/ConcatenatedModule.js +120 -16
- package/lib/optimize/FlagIncludedChunksPlugin.js +13 -3
- package/lib/optimize/InnerGraphPlugin.js +50 -30
- package/lib/optimize/ModuleConcatenationPlugin.js +69 -3
- package/lib/optimize/SideEffectsFlagPlugin.js +86 -43
- package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +15 -0
- package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +24 -13
- package/lib/prefetch/ResourceHintPlugin.js +663 -0
- package/lib/prefetch/ResourceHintRuntimeModule.js +149 -0
- package/lib/prefetch/StartupAssetHintRuntimeModule.js +210 -0
- package/lib/prefetch/parseResourceHintOptions.js +103 -0
- package/lib/rules/RuleSetCompiler.js +114 -0
- package/lib/runtime/AsyncModuleGeneratorRuntimeModule.js +56 -0
- package/lib/runtime/AsyncModuleRuntimeModule.js +24 -8
- package/lib/runtime/AutoPublicPathRuntimeModule.js +7 -1
- package/lib/runtime/CommonJsWrapRuntimeModule.js +37 -0
- package/lib/runtime/GetWorkletBootstrapRuntimeModule.js +59 -0
- package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +204 -8
- package/lib/runtime/SetAnonymousDefaultNameRuntimeModule.js +4 -1
- package/lib/schemes/HttpUriPlugin.js +40 -1
- package/lib/schemes/VirtualUrlPlugin.js +1 -2
- package/lib/serialization/FileMiddleware.js +29 -3
- package/lib/stats/DefaultStatsFactoryPlugin.js +32 -3
- package/lib/stats/DefaultStatsPresetPlugin.js +2 -0
- package/lib/stats/DefaultStatsPrinterPlugin.js +12 -2
- package/lib/stats/StatsFactory.js +15 -8
- package/lib/url/URLParserPlugin.js +66 -13
- package/lib/util/AsyncQueue.js +122 -72
- package/lib/util/SetHelpers.js +1 -1
- package/lib/util/StackedMap.js +122 -48
- package/lib/util/binarySearchBounds.js +2 -2
- package/lib/util/concatenate.js +40 -14
- package/lib/util/createHooksRegistry.js +13 -5
- package/lib/util/dataURL.js +2 -2
- package/lib/util/deterministicGrouping.js +7 -5
- package/lib/util/formatSize.js +6 -2
- package/lib/util/globUtils.js +710 -0
- package/lib/util/identifier.js +23 -6
- package/lib/util/implicitTypeLoaderFallback.js +62 -0
- package/lib/util/internalSerializables.js +88 -71
- package/lib/util/magicComment.js +121 -25
- package/lib/util/numberHash.js +2 -2
- package/lib/wasm-async/AsyncWasmCompileRuntimeModule.js +24 -18
- package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +33 -22
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +79 -16
- package/lib/web/FetchCompileAsyncWasmPlugin.js +19 -0
- package/lib/web/FetchCompileWasmPlugin.js +14 -0
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +2 -0
- package/lib/webpack.js +65 -0
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +3 -0
- package/module.d.ts +21 -0
- package/package.json +13 -12
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +759 -36
- package/schemas/plugins/HtmlParserOptions.check.js +1 -1
- package/schemas/plugins/ProgressPlugin.check.js +1 -1
- package/schemas/plugins/ProgressPlugin.json +17 -1
- package/schemas/plugins/container/ContainerReferencePlugin.check.js +1 -1
- package/schemas/plugins/container/ContainerReferencePlugin.json +1 -0
- package/schemas/plugins/container/ExternalsType.check.js +1 -1
- package/schemas/plugins/container/ModuleFederationPlugin.check.js +1 -1
- package/schemas/plugins/container/ModuleFederationPlugin.json +1 -0
- package/schemas/plugins/css/CssAutoOrModuleParserOptions.check.js +1 -1
- package/schemas/plugins/css/CssModuleParserOptions.check.js +1 -1
- package/schemas/plugins/css/CssParserOptions.check.js +1 -1
- package/types.d.ts +1213 -96
|
@@ -0,0 +1,130 @@
|
|
|
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
|
+
const { parse } = require("acorn");
|
|
9
|
+
const Parser = require("../Parser");
|
|
10
|
+
const HtmlSourceDependency = require("../dependencies/HtmlSourceDependency");
|
|
11
|
+
|
|
12
|
+
/** @typedef {import("estree").Expression} Expression */
|
|
13
|
+
/** @typedef {import("estree").ObjectExpression} ObjectExpression */
|
|
14
|
+
/** @typedef {import("estree").Program} Program */
|
|
15
|
+
/** @typedef {import("estree").Property} Property */
|
|
16
|
+
/** @typedef {import("../Module").BuildInfo} BuildInfo */
|
|
17
|
+
/** @typedef {import("../Parser").ParserState} ParserState */
|
|
18
|
+
/** @typedef {import("../Parser").PreparsedAst} PreparsedAst */
|
|
19
|
+
|
|
20
|
+
// acorn decorates every node with numeric source offsets (absent from the estree types).
|
|
21
|
+
/** @typedef {{ start: number, end: number }} Positioned */
|
|
22
|
+
|
|
23
|
+
// A URL carrying its own scheme (`https:`, `data:`, …) is external; it is only
|
|
24
|
+
// bundled when `experiments.buildHttp` is enabled (like an absolute URL in HTML).
|
|
25
|
+
const ABSOLUTE_URL_SCHEME_REGEXP = /^[a-zA-Z][a-zA-Z\d+\-.]*:/;
|
|
26
|
+
// Manifest members whose array items carry an asset `src` (`icons[].src`,
|
|
27
|
+
// `screenshots[].src`, and `shortcuts[].icons[].src` — the last nests under `icons`).
|
|
28
|
+
const ICON_CONTAINER_KEYS = new Set(["icons", "screenshots"]);
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Parses a Web App Manifest (`.webmanifest`) so its icon/screenshot `src`
|
|
32
|
+
* URLs are bundled as assets. Reuses acorn (JSON is a valid JS expression
|
|
33
|
+
* literal) to recover the exact source offsets, then emits an
|
|
34
|
+
* `HtmlSourceDependency` per URL so the generator can rewrite it in place.
|
|
35
|
+
*/
|
|
36
|
+
class WebManifestParser extends Parser {
|
|
37
|
+
/**
|
|
38
|
+
* Parses the provided source and updates the parser state.
|
|
39
|
+
* @param {string | Buffer | PreparsedAst} source the source to parse
|
|
40
|
+
* @param {ParserState} state the parser state
|
|
41
|
+
* @returns {ParserState} the parser state
|
|
42
|
+
*/
|
|
43
|
+
parse(source, state) {
|
|
44
|
+
if (Buffer.isBuffer(source)) {
|
|
45
|
+
source = source.toString("utf8");
|
|
46
|
+
} else if (typeof source === "object") {
|
|
47
|
+
throw new Error("webpackAst is unexpected for the WebManifestParser");
|
|
48
|
+
}
|
|
49
|
+
if (source[0] === "") {
|
|
50
|
+
source = source.slice(1);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const module = state.module;
|
|
54
|
+
// Without `buildHttp` there is no handler to fetch remote icons, so an
|
|
55
|
+
// absolute URL is left as-is rather than rewritten to an ignored asset.
|
|
56
|
+
const buildHttp = Boolean(state.options.experiments.buildHttp);
|
|
57
|
+
|
|
58
|
+
/** @type {Program | undefined} */
|
|
59
|
+
let ast;
|
|
60
|
+
try {
|
|
61
|
+
// Wrap in parens so the top-level object is an expression, not a block.
|
|
62
|
+
ast = /** @type {Program} */ (
|
|
63
|
+
/** @type {unknown} */ (parse(`(${source})`, { ecmaVersion: "latest" }))
|
|
64
|
+
);
|
|
65
|
+
} catch (_err) {
|
|
66
|
+
// Not valid JSON — leave the file untouched (still emitted as-is).
|
|
67
|
+
ast = undefined;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const statement = ast && ast.body[0];
|
|
71
|
+
if (
|
|
72
|
+
statement &&
|
|
73
|
+
statement.type === "ExpressionStatement" &&
|
|
74
|
+
statement.expression.type === "ObjectExpression"
|
|
75
|
+
) {
|
|
76
|
+
/**
|
|
77
|
+
* @param {ObjectExpression} obj object expression node
|
|
78
|
+
* @param {string | undefined} parentKey key of the array/object this node sits in
|
|
79
|
+
*/
|
|
80
|
+
const walk = (obj, parentKey) => {
|
|
81
|
+
for (const prop of obj.properties) {
|
|
82
|
+
if (prop.type !== "Property") continue;
|
|
83
|
+
const key =
|
|
84
|
+
prop.key.type === "Literal" && typeof prop.key.value === "string"
|
|
85
|
+
? prop.key.value
|
|
86
|
+
: prop.key.type === "Identifier"
|
|
87
|
+
? prop.key.name
|
|
88
|
+
: undefined;
|
|
89
|
+
const value = /** @type {Expression} */ (prop.value);
|
|
90
|
+
if (value.type === "ObjectExpression") {
|
|
91
|
+
walk(value, key);
|
|
92
|
+
} else if (value.type === "ArrayExpression") {
|
|
93
|
+
for (const element of value.elements) {
|
|
94
|
+
if (element && element.type === "ObjectExpression") {
|
|
95
|
+
walk(element, key);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
} else if (
|
|
99
|
+
key === "src" &&
|
|
100
|
+
value.type === "Literal" &&
|
|
101
|
+
typeof value.value === "string" &&
|
|
102
|
+
parentKey !== undefined &&
|
|
103
|
+
ICON_CONTAINER_KEYS.has(parentKey)
|
|
104
|
+
) {
|
|
105
|
+
const url = value.value;
|
|
106
|
+
// Fragment-only refs aren't assets; absolute URLs need `buildHttp`.
|
|
107
|
+
if (!url || url.startsWith("#")) continue;
|
|
108
|
+
if (!buildHttp && ABSOLUTE_URL_SCHEME_REGEXP.test(url)) continue;
|
|
109
|
+
// acorn offsets are into `(${source})`; the leading `(` and the
|
|
110
|
+
// opening quote cancel, so the inner span is [start, end - 2].
|
|
111
|
+
const { start, end } = /** @type {Positioned} */ (
|
|
112
|
+
/** @type {unknown} */ (value)
|
|
113
|
+
);
|
|
114
|
+
const dep = new HtmlSourceDependency(url, [start, end - 2]);
|
|
115
|
+
module.addDependency(dep);
|
|
116
|
+
module.addCodeGenerationDependency(dep);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
walk(statement.expression, undefined);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/** @type {BuildInfo} */
|
|
124
|
+
(state.module.buildInfo).strict = true;
|
|
125
|
+
|
|
126
|
+
return state;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
module.exports = WebManifestParser;
|
|
@@ -22,8 +22,9 @@ class AwaitDependenciesInitFragment extends InitFragment {
|
|
|
22
22
|
/**
|
|
23
23
|
* Creates an instance of AwaitDependenciesInitFragment.
|
|
24
24
|
* @param {Dependencies} dependencies maps an import var to an async module that needs to be awaited
|
|
25
|
+
* @param {boolean=} generatorLowered module is emitted as a generator, so use `yield` instead of `await`
|
|
25
26
|
*/
|
|
26
|
-
constructor(dependencies) {
|
|
27
|
+
constructor(dependencies, generatorLowered = false) {
|
|
27
28
|
super(
|
|
28
29
|
undefined,
|
|
29
30
|
InitFragment.STAGE_ASYNC_DEPENDENCIES,
|
|
@@ -32,6 +33,8 @@ class AwaitDependenciesInitFragment extends InitFragment {
|
|
|
32
33
|
);
|
|
33
34
|
/** @type {Dependencies} */
|
|
34
35
|
this.dependencies = dependencies;
|
|
36
|
+
/** @type {boolean} */
|
|
37
|
+
this.generatorLowered = generatorLowered;
|
|
35
38
|
}
|
|
36
39
|
|
|
37
40
|
/**
|
|
@@ -44,7 +47,10 @@ class AwaitDependenciesInitFragment extends InitFragment {
|
|
|
44
47
|
for (const [key, value] of this.dependencies) {
|
|
45
48
|
dependencies.set(key, value);
|
|
46
49
|
}
|
|
47
|
-
return new AwaitDependenciesInitFragment(
|
|
50
|
+
return new AwaitDependenciesInitFragment(
|
|
51
|
+
dependencies,
|
|
52
|
+
this.generatorLowered || other.generatorLowered
|
|
53
|
+
);
|
|
48
54
|
}
|
|
49
55
|
|
|
50
56
|
/**
|
|
@@ -61,6 +67,10 @@ class AwaitDependenciesInitFragment extends InitFragment {
|
|
|
61
67
|
const importVars = [...this.dependencies.keys()];
|
|
62
68
|
const asyncModuleValues = [...this.dependencies.values()].join(", ");
|
|
63
69
|
|
|
70
|
+
// In a generator-lowered module (no `async`/`await`, but generators) the
|
|
71
|
+
// dependency `await` becomes `yield`; the body stays a single scope.
|
|
72
|
+
const suspend = this.generatorLowered ? "yield" : "await";
|
|
73
|
+
|
|
64
74
|
const templateInput = [
|
|
65
75
|
`var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([${asyncModuleValues}]);`
|
|
66
76
|
];
|
|
@@ -70,7 +80,7 @@ class AwaitDependenciesInitFragment extends InitFragment {
|
|
|
70
80
|
!runtimeTemplate.supportsDestructuring()
|
|
71
81
|
) {
|
|
72
82
|
templateInput.push(
|
|
73
|
-
|
|
83
|
+
`var __webpack_async_dependencies_result__ = (__webpack_async_dependencies__.then ? (${suspend} __webpack_async_dependencies__)() : __webpack_async_dependencies__);`
|
|
74
84
|
);
|
|
75
85
|
for (const [index, importVar] of importVars.entries()) {
|
|
76
86
|
templateInput.push(
|
|
@@ -81,7 +91,7 @@ class AwaitDependenciesInitFragment extends InitFragment {
|
|
|
81
91
|
const importVarsStr = importVars.join(", ");
|
|
82
92
|
|
|
83
93
|
templateInput.push(
|
|
84
|
-
`([${importVarsStr}] = __webpack_async_dependencies__.then ? (
|
|
94
|
+
`([${importVarsStr}] = __webpack_async_dependencies__.then ? (${suspend} __webpack_async_dependencies__)() : __webpack_async_dependencies__);`
|
|
85
95
|
);
|
|
86
96
|
}
|
|
87
97
|
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/*
|
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
"use strict";
|
|
6
|
+
|
|
7
|
+
/** @typedef {import("../Module")} Module */
|
|
8
|
+
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
|
9
|
+
/** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Whether an async module is lowered to a generator: the target has no
|
|
13
|
+
* `async`/`await` but supports generators, and the module contains no
|
|
14
|
+
* top-level `for await…of` (which generators can't express).
|
|
15
|
+
* @param {Module} module module
|
|
16
|
+
* @param {ModuleGraph} moduleGraph module graph
|
|
17
|
+
* @param {RuntimeTemplate} runtimeTemplate runtime template
|
|
18
|
+
* @returns {boolean} true when the module should be emitted as a generator
|
|
19
|
+
*/
|
|
20
|
+
const isGeneratorLowered = (module, moduleGraph, runtimeTemplate) =>
|
|
21
|
+
moduleGraph.isAsync(module) &&
|
|
22
|
+
!runtimeTemplate.supportsAsyncFunction() &&
|
|
23
|
+
Boolean(runtimeTemplate.supportsGenerator()) &&
|
|
24
|
+
!(module.buildInfo && module.buildInfo.usesTopLevelAwaitForOf);
|
|
25
|
+
|
|
26
|
+
module.exports = isGeneratorLowered;
|
|
@@ -1134,7 +1134,7 @@ class PackFileCacheStrategy {
|
|
|
1134
1134
|
* @param {number} options.maxAge max age of cache items
|
|
1135
1135
|
* @param {boolean=} options.profile track and log detailed timing information for individual cache items
|
|
1136
1136
|
* @param {boolean=} options.allowCollectingMemory allow to collect unused memory created during deserialization
|
|
1137
|
-
* @param {false | "gzip" | "brotli"=} options.compression compression used
|
|
1137
|
+
* @param {false | "gzip" | "brotli" | "zstd"=} options.compression compression used
|
|
1138
1138
|
* @param {boolean=} options.readonly disable storing cache into filesystem
|
|
1139
1139
|
*/
|
|
1140
1140
|
constructor({
|
|
@@ -1182,15 +1182,21 @@ class PackFileCacheStrategy {
|
|
|
1182
1182
|
this.readonly = readonly;
|
|
1183
1183
|
/** @type {boolean | undefined} */
|
|
1184
1184
|
this.allowCollectingMemory = allowCollectingMemory;
|
|
1185
|
-
/** @type {false | "gzip" | "brotli" | undefined} */
|
|
1185
|
+
/** @type {false | "gzip" | "brotli" | "zstd" | undefined} */
|
|
1186
1186
|
this.compression = compression;
|
|
1187
|
+
// eslint-disable-next-line n/no-unsupported-features/node-builtins
|
|
1188
|
+
if (compression === "zstd" && !require("zlib").createZstdCompress) {
|
|
1189
|
+
throw new Error("cache.compression: 'zstd' requires Node.js >= 22.15.0");
|
|
1190
|
+
}
|
|
1187
1191
|
/** @type {string} */
|
|
1188
1192
|
this._extension =
|
|
1189
1193
|
compression === "brotli"
|
|
1190
1194
|
? ".pack.br"
|
|
1191
1195
|
: compression === "gzip"
|
|
1192
1196
|
? ".pack.gz"
|
|
1193
|
-
: "
|
|
1197
|
+
: compression === "zstd"
|
|
1198
|
+
? ".pack.zst"
|
|
1199
|
+
: ".pack";
|
|
1194
1200
|
/** @type {SnapshotOptions} */
|
|
1195
1201
|
this.snapshot = snapshot;
|
|
1196
1202
|
/** @type {BuildDependencies} */
|
|
@@ -449,6 +449,25 @@ const resolve = (browsers) => {
|
|
|
449
449
|
kaios: 3,
|
|
450
450
|
node: [7, 6]
|
|
451
451
|
}),
|
|
452
|
+
generator: rawChecker({
|
|
453
|
+
chrome: 39,
|
|
454
|
+
and_chr: 39,
|
|
455
|
+
edge: 13,
|
|
456
|
+
firefox: 26,
|
|
457
|
+
and_ff: 26,
|
|
458
|
+
// ie: Not supported,
|
|
459
|
+
opera: 26,
|
|
460
|
+
op_mob: 26,
|
|
461
|
+
safari: 10,
|
|
462
|
+
ios_saf: 10,
|
|
463
|
+
samsung: [3, 4],
|
|
464
|
+
android: 39,
|
|
465
|
+
and_qq: [10, 4],
|
|
466
|
+
baidu: [7, 12],
|
|
467
|
+
and_uc: [12, 12],
|
|
468
|
+
kaios: [2, 5],
|
|
469
|
+
node: 4
|
|
470
|
+
}),
|
|
452
471
|
/* eslint-enable camelcase */
|
|
453
472
|
browser: browserProperty,
|
|
454
473
|
electron: false,
|
|
@@ -458,6 +477,27 @@ const resolve = (browsers) => {
|
|
|
458
477
|
webworker: false,
|
|
459
478
|
|
|
460
479
|
document: browserProperty,
|
|
480
|
+
modulePreload:
|
|
481
|
+
browserProperty &&
|
|
482
|
+
/* eslint-disable camelcase */
|
|
483
|
+
rawChecker({
|
|
484
|
+
chrome: 66,
|
|
485
|
+
and_chr: 66,
|
|
486
|
+
edge: 79,
|
|
487
|
+
firefox: 115,
|
|
488
|
+
and_ff: 115,
|
|
489
|
+
opera: 53,
|
|
490
|
+
op_mob: 47,
|
|
491
|
+
safari: 17,
|
|
492
|
+
ios_saf: 17,
|
|
493
|
+
samsung: [9, 0],
|
|
494
|
+
android: 66,
|
|
495
|
+
and_qq: [13, 1],
|
|
496
|
+
baidu: [13, 18],
|
|
497
|
+
and_uc: [15, 5],
|
|
498
|
+
kaios: [3, 1]
|
|
499
|
+
}),
|
|
500
|
+
/* eslint-enable camelcase */
|
|
461
501
|
fetchWasm: browserProperty,
|
|
462
502
|
global: nodeProperty,
|
|
463
503
|
importScripts: false,
|