Merge pull request #17192 from burhanuday/feat/enable-top-level-await

feat: enable topLevelAwait by default
This commit is contained in:
Sean Larkin 2023-05-16 08:04:56 -07:00 committed by GitHub
commit 944403f99d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 13 deletions

View File

@ -289,7 +289,6 @@ const applyExperimentsDefaults = (
) => {
D(experiments, "futureDefaults", false);
D(experiments, "backCompat", !experiments.futureDefaults);
D(experiments, "topLevelAwait", experiments.futureDefaults);
D(experiments, "syncWebAssembly", false);
D(experiments, "asyncWebAssembly", experiments.futureDefaults);
D(experiments, "outputModule", false);
@ -299,6 +298,13 @@ const applyExperimentsDefaults = (
D(experiments, "cacheUnaffected", experiments.futureDefaults);
F(experiments, "css", () => (experiments.futureDefaults ? {} : undefined));
// TODO webpack 6: remove this. topLevelAwait should be enabled by default
let shouldEnableTopLevelAwait = true;
if (typeof experiments.topLevelAwait === "boolean") {
shouldEnableTopLevelAwait = experiments.topLevelAwait;
}
D(experiments, "topLevelAwait", shouldEnableTopLevelAwait);
if (typeof experiments.buildHttp === "object") {
D(experiments.buildHttp, "frozen", production);
D(experiments.buildHttp, "upgrade", false);

View File

@ -101,7 +101,7 @@ describe("snapshots", () => {
"lazyCompilation": undefined,
"outputModule": false,
"syncWebAssembly": false,
"topLevelAwait": false,
"topLevelAwait": true,
},
"externals": undefined,
"externalsPresets": Object {
@ -2146,9 +2146,6 @@ describe("snapshots", () => {
+ },
+ "futureDefaults": true,
@@ ... @@
- "topLevelAwait": false,
+ "topLevelAwait": true,
@@ ... @@
+ },
+ Object {
+ "rules": Array [
@ -2203,14 +2200,15 @@ describe("snapshots", () => {
+ "fullySpecified": true,
+ },
+ "type": "css/module",
+ },
+ Object {
@@ ... @@
+ "mimetype": "text/css",
+ "resolve": Object {
+ "fullySpecified": true,
+ "preferRelative": true,
+ },
+ "type": "css",
+ },
+ Object {
@@ ... @@
+ "exportsPresence": "error",
@@ ... @@
@ -2259,13 +2257,9 @@ describe("snapshots", () => {
+ "css": false,
+ "futureDefaults": true,
@@ ... @@
- "topLevelAwait": false,
+ "topLevelAwait": true,
@@ ... @@
+ },
+ Object {
+ "rules": Array [
+ Object {
@@ ... @@
+ "descriptionData": Object {
+ "type": "module",
+ },
@ -2276,7 +2270,8 @@ describe("snapshots", () => {
+ ],
+ "test": /\\.wasm$/i,
+ "type": "webassembly/async",
@@ ... @@
+ },
+ Object {
+ "mimetype": "application/wasm",
+ "rules": Array [
+ Object {