@@ -1680,29 +1680,8 @@ class JavascriptModulesPlugin {
16801680 continue ;
16811681 }
16821682 }
1683- // Held back for the patch release, reapply with `output.environment.topLevelAwait`.
1684- // const entryOptions = chunk.getEntryOptions();
1685- // const library =
1686- // entryOptions && entryOptions.library !== undefined
1687- // ? entryOptions.library
1688- // : runtimeTemplate.outputOptions.library;
1689- // // A module library awaits the entry itself, in `ModuleLibraryPlugin`.
1690- // const awaitedByLibrary =
1691- // library !== undefined && library.type === "module";
1692- // // `await` is only legal at the top level of an ESM chunk, never in
1693- // // the startup function rendered below, and only where the target
1694- // // can parse it (`target: "node14"` reads ESM but not top-level await).
1695- // const canAwaitEntry =
1696- // runtimeTemplate.isModule() &&
1697- // runtimeTemplate.supportsTopLevelAwait() &&
1698- // !awaitedByLibrary &&
1699- // !runtimeRequirements.has(RuntimeGlobals.startup) &&
1700- // !(
1701- // runtimeRequirements.has(RuntimeGlobals.startupOnlyBefore) &&
1702- // runtimeRequirements.has(RuntimeGlobals.startupOnlyAfter)
1703- // );
1704- // /** @type {string[] } */
1705- // const awaitedEntries = [];
1683+ // An async entry is not awaited here: that needs top-level `await`,
1684+ // gated on an option held back from the patch release (revert #21881).
17061685 let i = jsEntries . length ;
17071686 for ( const [ entryModule , entrypoint ] of jsEntries ) {
17081687 const chunks =
@@ -1829,20 +1808,6 @@ class JavascriptModulesPlugin {
18291808 ) } )`
18301809 ) ;
18311810 } else if ( useRequire ) {
1832- // Held back for the patch release, reapply with `output.environment.topLevelAwait`:
1833- // an async entry nobody awaits settles after the bundle did, which
1834- // orphans its rejection.
1835- // const awaitEntry =
1836- // canAwaitEntry && moduleGraph.isAsync(entryModule);
1837- // const target =
1838- // i === 0
1839- // ? RuntimeGlobals.exports
1840- // : `${RuntimeGlobals.exports}_${i}`;
1841- // const needsDecl = i === 0 || awaitEntry;
1842- // buf2.push(
1843- // `${needsDecl ? `${exportsDecl} ${target} = ` : ""}${RuntimeGlobals.require}(${moduleIdExpr});`
1844- // );
1845- // if (awaitEntry) awaitedEntries.push(target);
18461811 buf2 . push (
18471812 `${ i === 0 ? `${ exportsDecl } ${ RuntimeGlobals . exports } = ` : "" } ${
18481813 RuntimeGlobals . require
@@ -1890,15 +1855,6 @@ class JavascriptModulesPlugin {
18901855 `${ RuntimeGlobals . exports } = ${ RuntimeGlobals . onChunksLoaded } (${ RuntimeGlobals . exports } );`
18911856 ) ;
18921857 }
1893- // Held back for the patch release, reapply with `output.environment.topLevelAwait`:
1894- // several need one `Promise.all`, so an entry rejecting first still
1895- // leaves the others observed. A single one has nothing to orphan.
1896- // if (awaitedEntries.length === 1) {
1897- // buf2.push(`${awaitedEntries[0]} = await ${awaitedEntries[0]};`);
1898- // } else if (awaitedEntries.length > 1) {
1899- // const list = awaitedEntries.join(", ");
1900- // buf2.push(`[${list}] = await Promise.all([${list}]);`);
1901- // }
19021858 if (
19031859 runtimeRequirements . has ( RuntimeGlobals . startup ) ||
19041860 ( runtimeRequirements . has ( RuntimeGlobals . startupOnlyBefore ) &&
0 commit comments