@module-federation/enhanced 0.2.0-canary.1 → 0.2.0-canary.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/enhanced",
3
- "version": "0.2.0-canary.1",
3
+ "version": "0.2.0-canary.2",
4
4
  "type": "commonjs",
5
5
  "main": "./src/index.js",
6
6
  "types": "src/index.d.ts",
@@ -7,7 +7,10 @@ interface Options {
7
7
  }
8
8
  declare class AsyncEntryStartupPlugin {
9
9
  private _options;
10
+ private _runtimeChunks;
10
11
  constructor(options?: Options);
11
12
  apply(compiler: Compiler): void;
13
+ private collectRuntimeChunks;
14
+ private handleRenderStartup;
12
15
  }
13
16
  export default AsyncEntryStartupPlugin;
@@ -15,77 +15,125 @@ function _interop_require_default(obj) {
15
15
  default: obj
16
16
  };
17
17
  }
18
- // Class to handle asynchronous entry startup
19
18
  let AsyncEntryStartupPlugin = class AsyncEntryStartupPlugin {
20
19
  apply(compiler) {
21
- const chunkRuntimes = new Map();
22
20
  compiler.hooks.thisCompilation.tap('AsyncEntryStartupPlugin', (compilation)=>{
23
- compiler.webpack.javascript.JavascriptModulesPlugin.getCompilationHooks(compilation).renderStartup.tap('AsyncEntryStartupPlugin', (source, renderContext, upperContext)=>{
24
- var _compiler_options_optimization, _compiler_options;
25
- // Check if single runtime chunk is enabled
26
- if (compiler == null ? void 0 : (_compiler_options = compiler.options) == null ? void 0 : (_compiler_options_optimization = _compiler_options.optimization) == null ? void 0 : _compiler_options_optimization.runtimeChunk) {
27
- if (upperContext == null ? void 0 : upperContext.chunk.hasRuntime()) {
28
- chunkRuntimes.set(upperContext.chunk.id, upperContext.chunk);
29
- return source;
21
+ this.collectRuntimeChunks(compilation);
22
+ this.handleRenderStartup(compiler, compilation);
23
+ });
24
+ }
25
+ collectRuntimeChunks(compilation) {
26
+ compilation.hooks.beforeChunkAssets.tap('CollectRuntimeChunksPlugin', ()=>{
27
+ for (const chunk of compilation.chunks){
28
+ if (chunk.hasRuntime() && chunk.id !== null) {
29
+ this._runtimeChunks.set(chunk.id, chunk);
30
+ for (const dependentChunk of compilation.chunkGraph.getChunkEntryDependentChunksIterable(chunk)){
31
+ if (dependentChunk.id !== null) {
32
+ this._runtimeChunks.set(dependentChunk.id, dependentChunk);
33
+ }
30
34
  }
31
35
  }
32
- // Check if excludeChunk is provided, use it to decide further processing
33
- if (this._options.excludeChunk && this._options.excludeChunk(upperContext.chunk)) {
36
+ }
37
+ });
38
+ }
39
+ handleRenderStartup(compiler, compilation) {
40
+ compiler.webpack.javascript.JavascriptModulesPlugin.getCompilationHooks(compilation).renderStartup.tap('AsyncEntryStartupPlugin', (source, renderContext, upperContext)=>{
41
+ var _compiler_options_optimization, _compiler_options, _compiler_options_experiments, _compiler_options1, _compiler_options_experiments1, _compiler_options2;
42
+ // Check if this._runtimeChunks contains any runtime chunks
43
+ const isSingleRuntime = (_compiler_options = compiler.options) == null ? void 0 : (_compiler_options_optimization = _compiler_options.optimization) == null ? void 0 : _compiler_options_optimization.runtimeChunk;
44
+ if ((upperContext == null ? void 0 : upperContext.chunk.id) && isSingleRuntime) {
45
+ if (upperContext == null ? void 0 : upperContext.chunk.hasRuntime()) {
46
+ this._runtimeChunks.set(upperContext.chunk.id, upperContext.chunk);
34
47
  return source;
35
48
  }
36
- const runtime = chunkRuntimes.get(upperContext.chunk.runtime);
37
- // Get the runtime requirements of the chunk
38
- const requirements = compilation.chunkGraph.getTreeRuntimeRequirements(runtime || upperContext.chunk);
39
- let remotes = '';
40
- let shared = '';
49
+ }
50
+ // Check if excludeChunk is provided, use it to decide further processing
51
+ if (this._options.excludeChunk && this._options.excludeChunk(upperContext.chunk)) {
52
+ return source;
53
+ }
54
+ const runtime = new Set();
55
+ if (typeof upperContext.chunk.runtime === 'string' || typeof upperContext.chunk.runtime === 'number') {
56
+ if (this._runtimeChunks.has(upperContext.chunk.runtime)) {
57
+ runtime.add(this._runtimeChunks.get(upperContext.chunk.runtime));
58
+ } else {
59
+ runtime.add(upperContext.chunk);
60
+ }
61
+ } else if (upperContext.chunk.runtime && typeof upperContext.chunk.runtime[Symbol.iterator] === 'function') {
62
+ for (const runtimeItem of upperContext.chunk.runtime){
63
+ if (this._runtimeChunks.has(runtimeItem)) {
64
+ runtime.add(this._runtimeChunks.get(runtimeItem));
65
+ }
66
+ }
67
+ }
68
+ if (runtime.size === 0) {
69
+ runtime.add(upperContext.chunk);
70
+ }
71
+ // Get the runtime requirements of the chunk
72
+ let remotes = '';
73
+ let shared = '';
74
+ for (const runtimeItem of runtime){
75
+ const requirements = compilation.chunkGraph.getTreeRuntimeRequirements(runtimeItem);
41
76
  const hasRemoteModules = compilation.chunkGraph.getChunkModulesIterableBySourceType(upperContext.chunk, 'remote');
77
+ const consumeShares = compilation.chunkGraph.getChunkModulesIterableBySourceType(upperContext.chunk, 'consume-shared');
42
78
  // Check if the chunk has remote get scope
43
79
  if (requirements.has(_RuntimeGlobals.default.currentRemoteGetScope) || hasRemoteModules || requirements.has('__webpack_require__.vmok')) {
44
80
  remotes = `if(__webpack_require__.f && __webpack_require__.f.remotes) __webpack_require__.f.remotes(${JSON.stringify(upperContext.chunk.id)}, promiseTrack);`;
45
81
  }
46
82
  // Check if the chunk has share scope map or initialize sharing
47
- if (requirements.has(_RuntimeGlobals.default.shareScopeMap) || requirements.has(_RuntimeGlobals.default.initializeSharing)) {
83
+ if (requirements.has(_RuntimeGlobals.default.shareScopeMap) || requirements.has(_RuntimeGlobals.default.initializeSharing) || consumeShares) {
48
84
  shared = `if(__webpack_require__.f && __webpack_require__.f.consumes) __webpack_require__.f.consumes(${JSON.stringify(upperContext.chunk.id)}, promiseTrack);`;
49
85
  }
50
- // If no remotes or shared, return the source
51
- if (!remotes && !shared) {
52
- return source;
53
- }
54
- // Get the entry modules of the chunk
55
- const entryModules = compilation.chunkGraph.getChunkEntryModulesIterable(upperContext.chunk);
56
- const initialEntryModules = [];
57
- // Iterate over the entry modules
58
- for (const entryModule of entryModules){
59
- if (entryModule.id) {
60
- let shouldInclude = false;
61
- // Check if eager is a function and call it
62
- if (typeof this._options.eager === 'function') {
63
- shouldInclude = this._options.eager(entryModule);
64
- } else if (this._options.eager && this._options.eager.test(entryModule.identifier())) {
65
- // Check if eager is a RegExp and test it
66
- shouldInclude = true;
67
- }
68
- // If shouldInclude is true, push the module to initialEntryModules
69
- if (shouldInclude) {
70
- initialEntryModules.push(`__webpack_require__(${JSON.stringify(entryModule.id)});`);
71
- }
86
+ }
87
+ // If no remotes or shared, return the source
88
+ if (!remotes && !shared) {
89
+ return source;
90
+ }
91
+ // Get the entry modules of the chunk
92
+ const entryModules = compilation.chunkGraph.getChunkEntryModulesIterable(upperContext.chunk);
93
+ const initialEntryModules = [];
94
+ // Iterate over the entry modules
95
+ for (const entryModule of entryModules){
96
+ const entryModuleID = compilation.chunkGraph.getModuleId(entryModule);
97
+ if (entryModuleID) {
98
+ let shouldInclude = false;
99
+ // Check if eager is a function and call it
100
+ if (typeof this._options.eager === 'function') {
101
+ shouldInclude = this._options.eager(entryModule);
102
+ } else if (this._options.eager && this._options.eager.test(entryModule.identifier())) {
103
+ // Check if eager is a RegExp and test it
104
+ shouldInclude = true;
105
+ }
106
+ // If shouldInclude is true, push the module to initialEntryModules
107
+ if (shouldInclude) {
108
+ initialEntryModules.push(`__webpack_require__(${JSON.stringify(entryModuleID)});`);
72
109
  }
73
110
  }
111
+ }
112
+ if (((_compiler_options1 = compiler.options) == null ? void 0 : (_compiler_options_experiments = _compiler_options1.experiments) == null ? void 0 : _compiler_options_experiments.topLevelAwait) && ((_compiler_options2 = compiler.options) == null ? void 0 : (_compiler_options_experiments1 = _compiler_options2.experiments) == null ? void 0 : _compiler_options_experiments1.outputModule)) {
74
113
  return _Template.default.asString([
75
114
  'var promiseTrack = [];',
76
115
  _Template.default.asString(initialEntryModules),
77
116
  shared,
78
117
  remotes,
79
- 'var __webpack_exports__ = Promise.all(promiseTrack).then(function() {',
80
- _Template.default.indent(source.source()),
81
- _Template.default.indent('return __webpack_exports__'),
82
- '});'
118
+ 'await Promise.all(promiseTrack)',
119
+ _Template.default.indent(source.source())
83
120
  ]);
84
- });
121
+ }
122
+ return _Template.default.asString([
123
+ 'var promiseTrack = [];',
124
+ _Template.default.asString(initialEntryModules),
125
+ shared,
126
+ remotes,
127
+ 'var __webpack_exports__ = Promise.all(promiseTrack).then(function() {',
128
+ _Template.default.indent(source.source()),
129
+ _Template.default.indent('return __webpack_exports__'),
130
+ '});'
131
+ ]);
85
132
  });
86
133
  }
87
134
  constructor(options){
88
135
  this._options = options || {};
136
+ this._runtimeChunks = new Map();
89
137
  }
90
138
  };
91
139
  const _default = AsyncEntryStartupPlugin;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../packages/enhanced/src/lib/container/AsyncBoundaryPlugin.ts"],"sourcesContent":["import Compiler from 'webpack/lib/Compiler';\nimport Compilation from 'webpack/lib/Compilation';\nimport Chunk from 'webpack/lib/Chunk';\nimport RuntimeGlobals from 'webpack/lib/RuntimeGlobals';\nimport Template from 'webpack/lib/Template';\nimport Module from 'webpack/lib/Module';\n\ninterface Options {\n eager?: RegExp | ((module: Module) => boolean);\n excludeChunk?: (chunk: Chunk) => boolean;\n}\n\n// Class to handle asynchronous entry startup\nclass AsyncEntryStartupPlugin {\n private _options: Options;\n\n constructor(options?: Options) {\n this._options = options || {};\n }\n\n apply(compiler: Compiler): void {\n const chunkRuntimes = new Map();\n compiler.hooks.thisCompilation.tap(\n 'AsyncEntryStartupPlugin',\n (compilation: Compilation) => {\n compiler.webpack.javascript.JavascriptModulesPlugin.getCompilationHooks(\n compilation,\n ).renderStartup.tap(\n 'AsyncEntryStartupPlugin',\n (\n source: any,\n renderContext: Module,\n upperContext: { chunk: Chunk },\n ) => {\n // Check if single runtime chunk is enabled\n if (compiler?.options?.optimization?.runtimeChunk) {\n if (upperContext?.chunk.hasRuntime()) {\n chunkRuntimes.set(upperContext.chunk.id, upperContext.chunk);\n return source;\n }\n }\n\n // Check if excludeChunk is provided, use it to decide further processing\n if (\n this._options.excludeChunk &&\n this._options.excludeChunk(upperContext.chunk)\n ) {\n return source;\n }\n\n const runtime = chunkRuntimes.get(upperContext.chunk.runtime);\n\n // Get the runtime requirements of the chunk\n const requirements =\n compilation.chunkGraph.getTreeRuntimeRequirements(\n runtime || upperContext.chunk,\n );\n\n let remotes = '';\n let shared = '';\n const hasRemoteModules =\n compilation.chunkGraph.getChunkModulesIterableBySourceType(\n upperContext.chunk,\n 'remote',\n );\n\n // Check if the chunk has remote get scope\n if (\n requirements.has(RuntimeGlobals.currentRemoteGetScope) ||\n hasRemoteModules ||\n requirements.has('__webpack_require__.vmok')\n ) {\n remotes = `if(__webpack_require__.f && __webpack_require__.f.remotes) __webpack_require__.f.remotes(${JSON.stringify(\n upperContext.chunk.id,\n )}, promiseTrack);`;\n }\n\n // Check if the chunk has share scope map or initialize sharing\n if (\n requirements.has(RuntimeGlobals.shareScopeMap) ||\n requirements.has(RuntimeGlobals.initializeSharing)\n ) {\n shared = `if(__webpack_require__.f && __webpack_require__.f.consumes) __webpack_require__.f.consumes(${JSON.stringify(\n upperContext.chunk.id,\n )}, promiseTrack);`;\n }\n\n // If no remotes or shared, return the source\n if (!remotes && !shared) {\n return source;\n }\n\n // Get the entry modules of the chunk\n const entryModules =\n compilation.chunkGraph.getChunkEntryModulesIterable(\n upperContext.chunk,\n );\n\n const initialEntryModules = [];\n\n // Iterate over the entry modules\n for (const entryModule of entryModules) {\n if (entryModule.id) {\n let shouldInclude = false;\n\n // Check if eager is a function and call it\n if (typeof this._options.eager === 'function') {\n shouldInclude = this._options.eager(entryModule);\n } else if (\n this._options.eager &&\n this._options.eager.test(entryModule.identifier())\n ) {\n // Check if eager is a RegExp and test it\n shouldInclude = true;\n }\n\n // If shouldInclude is true, push the module to initialEntryModules\n if (shouldInclude) {\n initialEntryModules.push(\n `__webpack_require__(${JSON.stringify(entryModule.id)});`,\n );\n }\n }\n }\n\n return Template.asString([\n 'var promiseTrack = [];',\n Template.asString(initialEntryModules),\n shared,\n remotes,\n 'var __webpack_exports__ = Promise.all(promiseTrack).then(function() {',\n Template.indent(source.source()),\n Template.indent('return __webpack_exports__'),\n '});',\n ]);\n },\n );\n },\n );\n }\n}\n\nexport default AsyncEntryStartupPlugin;\n"],"names":["AsyncEntryStartupPlugin","apply","compiler","chunkRuntimes","Map","hooks","thisCompilation","tap","compilation","webpack","javascript","JavascriptModulesPlugin","getCompilationHooks","renderStartup","source","renderContext","upperContext","options","optimization","runtimeChunk","chunk","hasRuntime","set","id","_options","excludeChunk","runtime","get","requirements","chunkGraph","getTreeRuntimeRequirements","remotes","shared","hasRemoteModules","getChunkModulesIterableBySourceType","has","RuntimeGlobals","currentRemoteGetScope","JSON","stringify","shareScopeMap","initializeSharing","entryModules","getChunkEntryModulesIterable","initialEntryModules","entryModule","shouldInclude","eager","test","identifier","push","Template","asString","indent","constructor"],"mappings":";;;;+BA8IA;;;eAAA;;;uEA3I2B;iEACN;;;;;;AAQrB,6CAA6C;AAC7C,IAAA,AAAMA,0BAAN,MAAMA;IAOJC,MAAMC,QAAkB,EAAQ;QAC9B,MAAMC,gBAAgB,IAAIC;QAC1BF,SAASG,KAAK,CAACC,eAAe,CAACC,GAAG,CAChC,2BACA,CAACC;YACCN,SAASO,OAAO,CAACC,UAAU,CAACC,uBAAuB,CAACC,mBAAmB,CACrEJ,aACAK,aAAa,CAACN,GAAG,CACjB,2BACA,CACEO,QACAC,eACAC;oBAGId,gCAAAA;gBADJ,2CAA2C;gBAC3C,IAAIA,6BAAAA,oBAAAA,SAAUe,OAAO,sBAAjBf,iCAAAA,kBAAmBgB,YAAY,qBAA/BhB,+BAAiCiB,YAAY,EAAE;oBACjD,IAAIH,gCAAAA,aAAcI,KAAK,CAACC,UAAU,IAAI;wBACpClB,cAAcmB,GAAG,CAACN,aAAaI,KAAK,CAACG,EAAE,EAAEP,aAAaI,KAAK;wBAC3D,OAAON;oBACT;gB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AAO,IAAI,CAACtB,QAAQ,CAACuB,KAAK,KAAK,YAAY;4BAC7CD,gBAAgB,IAAI,CAACtB,QAAQ,CAACuB,KAAK,CAACF;wBACtC,OAAO,IACL,IAAI,CAACrB,QAAQ,CAACuB,KAAK,IACnB,IAAI,CAACvB,QAAQ,CAACuB,KAAK,CAACC,IAAI,CAACH,YAAYI,UAAU,KAC/C;4BACA,yCAAyC;4BACzCH,gBAAgB;wBAClB;wBAEA,mEAAmE;wBACnE,IAAIA,eAAe;4BACjBF,oBAAoBM,IAAI,CACtB,CAAC,oBAAoB,EAAEZ,KAAKC,SAAS,CAACM,YAAYtB,EAAE,EAAE,EAAE,CAAC;wBAE7D;oBACF;gBACF;gBAEA,OAAO4B,iBAAQ,CAACC,QAAQ,CAAC;oBACvB;oBACAD,iBAAQ,CAACC,QAAQ,CAACR;oBAClBZ;oBACAD;oBACA;oBACAoB,iBAAQ,CAACE,MAAM,CAACvC,OAAOA,MAAM;oBAC7BqC,iBAAQ,CAACE,MAAM,CAAC;oBAChB;iBACD;YACH;QAEJ;IAEJ;IA3HAC,YAAYrC,OAAiB,CAAE;QAC7B,IAAI,CAACO,QAAQ,GAAGP,WAAW,CAAC;IAC9B;AA0HF;MAEA,WAAejB"}
1
+ {"version":3,"sources":["../../../../../../packages/enhanced/src/lib/container/AsyncBoundaryPlugin.ts"],"sourcesContent":["import Compiler from 'webpack/lib/Compiler';\nimport Compilation from 'webpack/lib/Compilation';\nimport Chunk from 'webpack/lib/Chunk';\nimport RuntimeGlobals from 'webpack/lib/RuntimeGlobals';\nimport Template from 'webpack/lib/Template';\nimport Module from 'webpack/lib/Module';\n\ninterface Options {\n eager?: RegExp | ((module: Module) => boolean);\n excludeChunk?: (chunk: Chunk) => boolean;\n}\n\nclass AsyncEntryStartupPlugin {\n private _options: Options;\n private _runtimeChunks: Map<string | number, Chunk>;\n\n constructor(options?: Options) {\n this._options = options || {};\n this._runtimeChunks = new Map<string | number, Chunk>();\n }\n\n apply(compiler: Compiler): void {\n compiler.hooks.thisCompilation.tap(\n 'AsyncEntryStartupPlugin',\n (compilation: Compilation) => {\n this.collectRuntimeChunks(compilation);\n this.handleRenderStartup(compiler, compilation);\n },\n );\n }\n\n private collectRuntimeChunks(compilation: Compilation): void {\n compilation.hooks.beforeChunkAssets.tap(\n 'CollectRuntimeChunksPlugin',\n () => {\n for (const chunk of compilation.chunks) {\n if (chunk.hasRuntime() && chunk.id !== null) {\n this._runtimeChunks.set(chunk.id, chunk);\n for (const dependentChunk of compilation.chunkGraph.getChunkEntryDependentChunksIterable(\n chunk,\n )) {\n if (dependentChunk.id !== null) {\n this._runtimeChunks.set(dependentChunk.id, dependentChunk);\n }\n }\n }\n }\n },\n );\n }\n\n private handleRenderStartup(\n compiler: Compiler,\n compilation: Compilation,\n ): void {\n compiler.webpack.javascript.JavascriptModulesPlugin.getCompilationHooks(\n compilation,\n ).renderStartup.tap(\n 'AsyncEntryStartupPlugin',\n (source: any, renderContext: Module, upperContext: { chunk: Chunk }) => {\n // Check if this._runtimeChunks contains any runtime chunks\n const isSingleRuntime = compiler.options?.optimization?.runtimeChunk;\n if (upperContext?.chunk.id && isSingleRuntime) {\n if (upperContext?.chunk.hasRuntime()) {\n this._runtimeChunks.set(upperContext.chunk.id, upperContext.chunk);\n return source;\n }\n }\n\n // Check if excludeChunk is provided, use it to decide further processing\n if (\n this._options.excludeChunk &&\n this._options.excludeChunk(upperContext.chunk)\n ) {\n return source;\n }\n\n const runtime = new Set();\n if (\n typeof upperContext.chunk.runtime === 'string' ||\n typeof upperContext.chunk.runtime === 'number'\n ) {\n if (this._runtimeChunks.has(upperContext.chunk.runtime)) {\n runtime.add(this._runtimeChunks.get(upperContext.chunk.runtime));\n } else {\n runtime.add(upperContext.chunk);\n }\n } else if (\n upperContext.chunk.runtime &&\n typeof upperContext.chunk.runtime[Symbol.iterator] === 'function'\n ) {\n for (const runtimeItem of upperContext.chunk.runtime) {\n if (this._runtimeChunks.has(runtimeItem)) {\n runtime.add(this._runtimeChunks.get(runtimeItem));\n }\n }\n }\n if (runtime.size === 0) {\n runtime.add(upperContext.chunk);\n }\n // Get the runtime requirements of the chunk\n let remotes = '';\n let shared = '';\n\n for (const runtimeItem of runtime) {\n const requirements =\n compilation.chunkGraph.getTreeRuntimeRequirements(\n runtimeItem as Chunk,\n );\n\n const hasRemoteModules =\n compilation.chunkGraph.getChunkModulesIterableBySourceType(\n upperContext.chunk,\n 'remote',\n );\n\n const consumeShares =\n compilation.chunkGraph.getChunkModulesIterableBySourceType(\n upperContext.chunk,\n 'consume-shared',\n );\n\n // Check if the chunk has remote get scope\n if (\n requirements.has(RuntimeGlobals.currentRemoteGetScope) ||\n hasRemoteModules ||\n requirements.has('__webpack_require__.vmok')\n ) {\n remotes = `if(__webpack_require__.f && __webpack_require__.f.remotes) __webpack_require__.f.remotes(${JSON.stringify(\n upperContext.chunk.id,\n )}, promiseTrack);`;\n }\n\n // Check if the chunk has share scope map or initialize sharing\n if (\n requirements.has(RuntimeGlobals.shareScopeMap) ||\n requirements.has(RuntimeGlobals.initializeSharing) ||\n consumeShares\n ) {\n shared = `if(__webpack_require__.f && __webpack_require__.f.consumes) __webpack_require__.f.consumes(${JSON.stringify(\n upperContext.chunk.id,\n )}, promiseTrack);`;\n }\n }\n\n // If no remotes or shared, return the source\n if (!remotes && !shared) {\n return source;\n }\n\n // Get the entry modules of the chunk\n const entryModules =\n compilation.chunkGraph.getChunkEntryModulesIterable(\n upperContext.chunk,\n );\n\n const initialEntryModules = [];\n\n // Iterate over the entry modules\n for (const entryModule of entryModules) {\n const entryModuleID = compilation.chunkGraph.getModuleId(entryModule);\n if (entryModuleID) {\n let shouldInclude = false;\n\n // Check if eager is a function and call it\n if (typeof this._options.eager === 'function') {\n shouldInclude = this._options.eager(entryModule);\n } else if (\n this._options.eager &&\n this._options.eager.test(entryModule.identifier())\n ) {\n // Check if eager is a RegExp and test it\n shouldInclude = true;\n }\n\n // If shouldInclude is true, push the module to initialEntryModules\n if (shouldInclude) {\n initialEntryModules.push(\n `__webpack_require__(${JSON.stringify(entryModuleID)});`,\n );\n }\n }\n }\n if (\n compiler.options?.experiments?.topLevelAwait &&\n compiler.options?.experiments?.outputModule\n ) {\n return Template.asString([\n 'var promiseTrack = [];',\n Template.asString(initialEntryModules),\n shared,\n remotes,\n 'await Promise.all(promiseTrack)',\n Template.indent(source.source()),\n ]);\n }\n return Template.asString([\n 'var promiseTrack = [];',\n Template.asString(initialEntryModules),\n shared,\n remotes,\n 'var __webpack_exports__ = Promise.all(promiseTrack).then(function() {',\n Template.indent(source.source()),\n Template.indent('return __webpack_exports__'),\n '});',\n ]);\n },\n );\n }\n}\n\nexport default AsyncEntryStartupPlugin;\n"],"names":["AsyncEntryStartupPlugin","apply","compiler","hooks","thisCompilation","tap","compilation","collectRuntimeChunks","handleRenderStartup","beforeChunkAssets","chunk","chunks","hasRuntime","id","_runtimeChunks","set","dependentChunk","chunkGraph","getChunkEntryDependentChunksIterable","webpack","javascript","JavascriptModulesPlugin","getCompilationHooks","renderStartup","source","renderContext","upperContext","isSingleRuntime","options","optimization","runtimeChunk","_options","excludeChunk","runtime","Set","has","add","get","Symbol","iterator","runtimeItem","size","remotes","shared","requirements","getTreeRuntimeRequirements","hasRemoteModules","getChunkModulesIterableBySourceType","consumeShares","RuntimeGlobals","currentRemoteGetScope","JSON","stringify","shareScopeMap","initializeSharing","entryModules","getChunkEntryModulesIterable","initialEntryModules","entryModule","entryModuleID","getModuleId","shouldInclude","eager","test","identifier","push","experiments","topLevelAwait","outputModule","Template","asString","indent","constructor","Map"],"mappings":";;;;+BAmNA;;;eAAA;;;uEAhN2B;iEACN;;;;;;AAQrB,IAAA,AAAMA,0BAAN,MAAMA;IASJC,MAAMC,QAAkB,EAAQ;QAC9BA,SAASC,KAAK,CAACC,eAAe,CAACC,GAAG,CAChC,2BACA,CAACC;YACC,IAAI,CAACC,oBAAoB,CAACD;YAC1B,IAAI,CAACE,mBAAmB,CAACN,UAAUI;QACrC;IAEJ;IAEQ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