@module-federation/enhanced 0.2.0-canary.3 → 0.2.0-canary.5

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.3",
3
+ "version": "0.2.0-canary.5",
4
4
  "type": "commonjs",
5
5
  "main": "./src/index.js",
6
6
  "types": "src/index.d.ts",
@@ -10,7 +10,12 @@ declare class AsyncEntryStartupPlugin {
10
10
  private _runtimeChunks;
11
11
  constructor(options?: Options);
12
12
  apply(compiler: Compiler): void;
13
- private collectRuntimeChunks;
14
- private handleRenderStartup;
13
+ private _collectRuntimeChunks;
14
+ private _handleRenderStartup;
15
+ private _getChunkRuntime;
16
+ private _getRemotes;
17
+ private _getShared;
18
+ private _getInitialEntryModules;
19
+ private _getTemplateString;
15
20
  }
16
21
  export default AsyncEntryStartupPlugin;
@@ -10,6 +10,7 @@ Object.defineProperty(exports, "default", {
10
10
  });
11
11
  const _RuntimeGlobals = /*#__PURE__*/ _interop_require_default(require("webpack/lib/RuntimeGlobals"));
12
12
  const _Template = /*#__PURE__*/ _interop_require_default(require("webpack/lib/Template"));
13
+ const _SortableSet = /*#__PURE__*/ _interop_require_default(require("webpack/lib/util/SortableSet"));
13
14
  function _interop_require_default(obj) {
14
15
  return obj && obj.__esModule ? obj : {
15
16
  default: obj
@@ -18,12 +19,12 @@ function _interop_require_default(obj) {
18
19
  let AsyncEntryStartupPlugin = class AsyncEntryStartupPlugin {
19
20
  apply(compiler) {
20
21
  compiler.hooks.thisCompilation.tap('AsyncEntryStartupPlugin', (compilation)=>{
21
- this.collectRuntimeChunks(compilation);
22
- this.handleRenderStartup(compiler, compilation);
22
+ this._collectRuntimeChunks(compilation);
23
+ this._handleRenderStartup(compiler, compilation);
23
24
  });
24
25
  }
25
- collectRuntimeChunks(compilation) {
26
- compilation.hooks.beforeChunkAssets.tap('CollectRuntimeChunksPlugin', ()=>{
26
+ _collectRuntimeChunks(compilation) {
27
+ compilation.hooks.beforeChunkAssets.tap('AsyncEntryStartupPlugin', ()=>{
27
28
  for (const chunk of compilation.chunks){
28
29
  if (chunk.hasRuntime() && chunk.id !== null) {
29
30
  this._runtimeChunks.set(chunk.id, chunk);
@@ -36,10 +37,9 @@ let AsyncEntryStartupPlugin = class AsyncEntryStartupPlugin {
36
37
  }
37
38
  });
38
39
  }
39
- handleRenderStartup(compiler, compilation) {
40
+ _handleRenderStartup(compiler, compilation) {
40
41
  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
42
+ var _compiler_options_optimization, _compiler_options;
43
43
  const isSingleRuntime = (_compiler_options = compiler.options) == null ? void 0 : (_compiler_options_optimization = _compiler_options.optimization) == null ? void 0 : _compiler_options_optimization.runtimeChunk;
44
44
  if ((upperContext == null ? void 0 : upperContext.chunk.id) && isSingleRuntime) {
45
45
  if (upperContext == null ? void 0 : upperContext.chunk.hasRuntime()) {
@@ -47,93 +47,136 @@ let AsyncEntryStartupPlugin = class AsyncEntryStartupPlugin {
47
47
  return source;
48
48
  }
49
49
  }
50
- // Check if excludeChunk is provided, use it to decide further processing
51
50
  if (this._options.excludeChunk && this._options.excludeChunk(upperContext.chunk)) {
52
51
  return source;
53
52
  }
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
53
+ const runtime = this._getChunkRuntime(upperContext);
72
54
  let remotes = '';
73
55
  let shared = '';
74
56
  for (const runtimeItem of runtime){
57
+ if (!runtimeItem) {
58
+ continue;
59
+ }
75
60
  const requirements = compilation.chunkGraph.getTreeRuntimeRequirements(runtimeItem);
76
61
  const hasRemoteModules = compilation.chunkGraph.getChunkModulesIterableBySourceType(upperContext.chunk, 'remote');
77
62
  const consumeShares = compilation.chunkGraph.getChunkModulesIterableBySourceType(upperContext.chunk, 'consume-shared');
78
- // Check if the chunk has remote get scope
79
- if (requirements.has(_RuntimeGlobals.default.currentRemoteGetScope) || hasRemoteModules || requirements.has('__webpack_require__.vmok')) {
80
- remotes = `if(__webpack_require__.f && __webpack_require__.f.remotes) __webpack_require__.f.remotes(${JSON.stringify(upperContext.chunk.id)}, promiseTrack);`;
81
- }
82
- // Check if the chunk has share scope map or initialize sharing
83
- if (requirements.has(_RuntimeGlobals.default.shareScopeMap) || requirements.has(_RuntimeGlobals.default.initializeSharing) || consumeShares) {
84
- shared = `if(__webpack_require__.f && __webpack_require__.f.consumes) __webpack_require__.f.consumes(${JSON.stringify(upperContext.chunk.id)}, promiseTrack);`;
85
- }
63
+ const entryOptions = upperContext.chunk.getEntryOptions();
64
+ const chunksToRef = (entryOptions == null ? void 0 : entryOptions.dependOn) ? [
65
+ ...entryOptions.dependOn,
66
+ upperContext.chunk.id
67
+ ] : [
68
+ upperContext.chunk.id
69
+ ];
70
+ remotes = this._getRemotes(requirements, Boolean(hasRemoteModules), chunksToRef, remotes);
71
+ shared = this._getShared(requirements, Boolean(consumeShares), chunksToRef, shared);
86
72
  }
87
- // If no remotes or shared, return the source
88
73
  if (!remotes && !shared) {
89
74
  return source;
90
75
  }
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)});`);
109
- }
76
+ const initialEntryModules = this._getInitialEntryModules(compilation, upperContext);
77
+ return this._getTemplateString(compiler, initialEntryModules, shared, remotes, source);
78
+ });
79
+ }
80
+ _getChunkRuntime(upperContext) {
81
+ const runtime = new Set();
82
+ const chunkRuntime = upperContext.chunk.runtime;
83
+ if (chunkRuntime) {
84
+ const runtimeItems = chunkRuntime instanceof _SortableSet.default ? chunkRuntime : [
85
+ chunkRuntime
86
+ ];
87
+ for (const runtimeItem of runtimeItems){
88
+ const chunk = this._runtimeChunks.get(runtimeItem);
89
+ if (chunk) {
90
+ runtime.add(chunk);
110
91
  }
111
92
  }
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)) {
113
- return _Template.default.asString([
114
- 'var promiseTrack = [];',
115
- _Template.default.asString(initialEntryModules),
116
- shared,
117
- remotes,
118
- 'await Promise.all(promiseTrack)',
119
- _Template.default.indent(source.source())
120
- ]);
93
+ }
94
+ if (runtime.size === 0) {
95
+ runtime.add(upperContext.chunk);
96
+ }
97
+ return runtime;
98
+ }
99
+ _getRemotes(requirements, hasRemoteModules, chunksToRef, remotes) {
100
+ if (!requirements.has(_RuntimeGlobals.default.currentRemoteGetScope) && !hasRemoteModules && !requirements.has('__webpack_require__.vmok')) {
101
+ return remotes;
102
+ }
103
+ const remotesParts = remotes.startsWith('if(__webpack_require__.f && __webpack_require__.f.remotes) {') ? [
104
+ remotes
105
+ ] : [
106
+ remotes,
107
+ 'if(__webpack_require__.f && __webpack_require__.f.remotes) {'
108
+ ];
109
+ for (const chunkId of chunksToRef){
110
+ if (chunkId !== null) {
111
+ remotesParts.push(` __webpack_require__.f.remotes(${JSON.stringify(chunkId)}, promiseTrack);`);
112
+ }
113
+ }
114
+ remotesParts.push('}');
115
+ return remotesParts.join('');
116
+ }
117
+ _getShared(requirements, consumeShares, chunksToRef, shared) {
118
+ if (!requirements.has(_RuntimeGlobals.default.shareScopeMap) && !consumeShares && !requirements.has(_RuntimeGlobals.default.initializeSharing)) {
119
+ return shared;
120
+ }
121
+ const sharedParts = shared.startsWith('if(__webpack_require__.f && __webpack_require__.f.consumes) {') ? [
122
+ shared
123
+ ] : [
124
+ shared,
125
+ 'if(__webpack_require__.f && __webpack_require__.f.consumes) {'
126
+ ];
127
+ for (const chunkId of chunksToRef){
128
+ if (chunkId !== null) {
129
+ sharedParts.push(` __webpack_require__.f.consumes(${JSON.stringify(chunkId)}, promiseTrack);`);
121
130
  }
131
+ }
132
+ sharedParts.push('}');
133
+ return sharedParts.join('');
134
+ }
135
+ _getInitialEntryModules(compilation, upperContext) {
136
+ const entryModules = compilation.chunkGraph.getChunkEntryModulesIterable(upperContext.chunk);
137
+ const initialEntryModules = [];
138
+ for (const entryModule of entryModules){
139
+ const entryModuleID = compilation.chunkGraph.getModuleId(entryModule);
140
+ if (entryModuleID) {
141
+ let shouldInclude = false;
142
+ if (typeof this._options.eager === 'function') {
143
+ shouldInclude = this._options.eager(entryModule);
144
+ } else if (this._options.eager && this._options.eager.test(entryModule.identifier())) {
145
+ shouldInclude = true;
146
+ }
147
+ if (shouldInclude) {
148
+ initialEntryModules.push(`__webpack_require__(${JSON.stringify(entryModuleID)});`);
149
+ }
150
+ }
151
+ }
152
+ return initialEntryModules;
153
+ }
154
+ _getTemplateString(compiler, initialEntryModules, shared, remotes, source) {
155
+ var _compiler_options_experiments, _compiler_options, _compiler_options_experiments1, _compiler_options1;
156
+ if (((_compiler_options = compiler.options) == null ? void 0 : (_compiler_options_experiments = _compiler_options.experiments) == null ? void 0 : _compiler_options_experiments.topLevelAwait) && ((_compiler_options1 = compiler.options) == null ? void 0 : (_compiler_options_experiments1 = _compiler_options1.experiments) == null ? void 0 : _compiler_options_experiments1.outputModule)) {
122
157
  return _Template.default.asString([
123
158
  'var promiseTrack = [];',
124
159
  _Template.default.asString(initialEntryModules),
125
160
  shared,
126
161
  remotes,
127
- 'var __webpack_exports__ = Promise.all(promiseTrack).then(function() {',
128
- _Template.default.indent(source.source()),
129
- _Template.default.indent('return __webpack_exports__'),
130
- '});'
162
+ 'await Promise.all(promiseTrack)',
163
+ _Template.default.indent(source.source())
131
164
  ]);
132
- });
165
+ }
166
+ return _Template.default.asString([
167
+ 'var promiseTrack = [];',
168
+ _Template.default.asString(initialEntryModules),
169
+ shared,
170
+ remotes,
171
+ 'var __webpack_exports__ = Promise.all(promiseTrack).then(function() {',
172
+ _Template.default.indent(source.source()),
173
+ _Template.default.indent('return __webpack_exports__'),
174
+ '});'
175
+ ]);
133
176
  }
134
177
  constructor(options){
135
- this._options = options || {};
136
178
  this._runtimeChunks = new Map();
179
+ this._options = options || {};
137
180
  }
138
181
  };
139
182
  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\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","const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AEA,mEAAmE;oBACnE,IAAIA,eAAe;wBACjBJ,oBAAoBQ,IAAI,CACtB,CAAC,oBAAoB,EAAEd,KAAKC,SAAS,CAACO,eAAe,EAAE,CAAC;oBAE5D;gBACF;YACF;YACA,IACEzD,EAAAA,qBAAAA,SAAS0B,OAAO,sBAAhB1B,gCAAAA,mBAAkBgE,WAAW,qBAA7BhE,8BAA+BiE,aAAa,OAC5CjE,qBAAAA,SAAS0B,OAAO,sBAAhB1B,iCAAAA,mBAAkBgE,WAAW,qBAA7BhE,+BAA+BkE,YAAY,GAC3C;gBACA,OAAOC,iBAAQ,CAACC,QAAQ,CAAC;oBACvB;oBACAD,iBAAQ,CAACC,QAAQ,CAACb;oBAClBd;oBACAD;oBACA;oBACA2B,iBAAQ,CAACE,MAAM,CAAC/C,OAAOA,MAAM;iBAC9B;YACH;YACA,OAAO6C,iBAAQ,CAACC,QAAQ,CAAC;gBACvB;gBACAD,iBAAQ,CAACC,QAAQ,CAACb;gBAClBd;gBACAD;gBACA;gBACA2B,iBAAQ,CAACE,MAAM,CAAC/C,OAAOA,MAAM;gBAC7B6C,iBAAQ,CAACE,MAAM,CAAC;gBAChB;aACD;QACH;IAEJ;IAhMAC,YAAY5C,OAAiB,CAAE;QAC7B,IAAI,CAACG,QAAQ,GAAGH,WAAW,CAAC;QAC5B,IAAI,CAACd,cAAc,GAAG,IAAI2D;IAC5B;AA8LF;MAEA,WAAezE"}
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, { Source } from 'webpack/lib/Chunk';\nimport RuntimeGlobals from 'webpack/lib/RuntimeGlobals';\nimport Template from 'webpack/lib/Template';\nimport SortableSet from 'webpack/lib/util/SortableSet';\nimport Module from 'webpack/lib/Module';\nimport { StartupRenderContext } from 'webpack/lib/javascript/JavascriptModulesPlugin';\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 = new Map<string | number, Chunk | undefined>();\n\n constructor(options?: Options) {\n this._options = options || {};\n }\n\n apply(compiler: Compiler) {\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) {\n compilation.hooks.beforeChunkAssets.tap('AsyncEntryStartupPlugin', () => {\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 private _handleRenderStartup(compiler: Compiler, compilation: Compilation) {\n compiler.webpack.javascript.JavascriptModulesPlugin.getCompilationHooks(\n compilation,\n ).renderStartup.tap(\n 'AsyncEntryStartupPlugin',\n (\n source: Source,\n renderContext: Module,\n upperContext: StartupRenderContext,\n ) => {\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 if (\n this._options.excludeChunk &&\n this._options.excludeChunk(upperContext.chunk)\n ) {\n return source;\n }\n\n const runtime = this._getChunkRuntime(upperContext);\n\n let remotes = '';\n let shared = '';\n\n for (const runtimeItem of runtime) {\n if (!runtimeItem) {\n continue;\n }\n const requirements =\n compilation.chunkGraph.getTreeRuntimeRequirements(runtimeItem);\n const hasRemoteModules =\n compilation.chunkGraph.getChunkModulesIterableBySourceType(\n upperContext.chunk,\n 'remote',\n );\n const consumeShares =\n compilation.chunkGraph.getChunkModulesIterableBySourceType(\n upperContext.chunk,\n 'consume-shared',\n );\n const entryOptions = upperContext.chunk.getEntryOptions();\n const chunksToRef = entryOptions?.dependOn\n ? [...entryOptions.dependOn, upperContext.chunk.id]\n : [upperContext.chunk.id];\n\n remotes = this._getRemotes(\n requirements,\n Boolean(hasRemoteModules),\n chunksToRef,\n remotes,\n );\n shared = this._getShared(\n requirements,\n Boolean(consumeShares),\n chunksToRef,\n shared,\n );\n }\n\n if (!remotes && !shared) {\n return source;\n }\n\n const initialEntryModules = this._getInitialEntryModules(\n compilation,\n upperContext,\n );\n return this._getTemplateString(\n compiler,\n initialEntryModules,\n shared,\n remotes,\n source,\n );\n },\n );\n }\n\n private _getChunkRuntime(upperContext: StartupRenderContext) {\n const runtime = new Set<Chunk>();\n const chunkRuntime = upperContext.chunk.runtime;\n if (chunkRuntime) {\n const runtimeItems =\n chunkRuntime instanceof SortableSet ? chunkRuntime : [chunkRuntime];\n for (const runtimeItem of runtimeItems) {\n const chunk = this._runtimeChunks.get(runtimeItem);\n if (chunk) {\n runtime.add(chunk);\n }\n }\n }\n if (runtime.size === 0) {\n runtime.add(upperContext.chunk);\n }\n return runtime;\n }\n private _getRemotes(\n requirements: ReadonlySet<string>,\n hasRemoteModules: boolean,\n chunksToRef: (Chunk.ChunkId | null)[],\n remotes: string,\n ): string {\n if (\n !requirements.has(RuntimeGlobals.currentRemoteGetScope) &&\n !hasRemoteModules &&\n !requirements.has('__webpack_require__.vmok')\n ) {\n return remotes;\n }\n\n const remotesParts = remotes.startsWith(\n 'if(__webpack_require__.f && __webpack_require__.f.remotes) {',\n )\n ? [remotes]\n : [\n remotes,\n 'if(__webpack_require__.f && __webpack_require__.f.remotes) {',\n ];\n\n for (const chunkId of chunksToRef) {\n if (chunkId !== null) {\n remotesParts.push(\n ` __webpack_require__.f.remotes(${JSON.stringify(\n chunkId,\n )}, promiseTrack);`,\n );\n }\n }\n\n remotesParts.push('}');\n return remotesParts.join('');\n }\n\n private _getShared(\n requirements: ReadonlySet<string>,\n consumeShares: boolean,\n chunksToRef: (Chunk.ChunkId | null)[],\n shared: string,\n ): string {\n if (\n !requirements.has(RuntimeGlobals.shareScopeMap) &&\n !consumeShares &&\n !requirements.has(RuntimeGlobals.initializeSharing)\n ) {\n return shared;\n }\n\n const sharedParts = shared.startsWith(\n 'if(__webpack_require__.f && __webpack_require__.f.consumes) {',\n )\n ? [shared]\n : [\n shared,\n 'if(__webpack_require__.f && __webpack_require__.f.consumes) {',\n ];\n\n for (const chunkId of chunksToRef) {\n if (chunkId !== null) {\n sharedParts.push(\n ` __webpack_require__.f.consumes(${JSON.stringify(\n chunkId,\n )}, promiseTrack);`,\n );\n }\n }\n\n sharedParts.push('}');\n return sharedParts.join('');\n }\n\n private _getInitialEntryModules(\n compilation: Compilation,\n upperContext: { chunk: Chunk },\n ): string[] {\n const entryModules = compilation.chunkGraph.getChunkEntryModulesIterable(\n upperContext.chunk,\n );\n const initialEntryModules = [];\n\n for (const entryModule of entryModules) {\n const entryModuleID = compilation.chunkGraph.getModuleId(entryModule);\n if (entryModuleID) {\n let shouldInclude = false;\n\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 shouldInclude = true;\n }\n\n if (shouldInclude) {\n initialEntryModules.push(\n `__webpack_require__(${JSON.stringify(entryModuleID)});`,\n );\n }\n }\n }\n return initialEntryModules;\n }\n\n private _getTemplateString(\n compiler: Compiler,\n initialEntryModules: string[],\n shared: string,\n remotes: string,\n source: Source,\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\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","_getChunkRuntime","remotes","shared","runtimeItem","requirements","getTreeRuntimeRequirements","hasRemoteModules","getChunkModulesIterableBySourceType","consumeShares","entryOptions","getEntryOptions","chunksToRef","dependOn","_getRemotes","Boolean","_getShared","initialEntryModules","_getInitialEntryModules","_getTemplateString","Set","chunkRuntime","runtimeItems","SortableSet","get","add","size","has","RuntimeGlobals","currentRemoteGetScope","remotesParts","startsWith","chunkId","push","JSON","stringify","join","shareScopeMap","initializeSharing","sharedParts","entryModules","getChunkEntryModulesIterable","entryModule","entryModuleID","getModuleId","shouldInclude","eager","test","identifier","experiments","topLevelAwait","outputModule","Template","asString","indent","constructor","Map"],"mappings":";;;;+BAmSA;;;eAAA;;;uEAhS2B;iEACN;oEACG;;;;;;AASxB,IAAA,AAAMA,0BAAN,MAAMA;IAQJC,MAAMC,QAAkB,EAAE;QACxBA,SAASC,KAAK,CAACC,eAAe,CAACC,GAAG,CAChC,2BACA,CAACC;YACC,IAAI,CAACC,qBAAqB,CAACD;YAC3B,IAAI,CAACE,oBAAoB,CAACN,UAAUI;QACtC;IAEJ;IAEQC,sBAAsBD,WAAwB,EAAE;QACtDA,YAAYH,KAAK,CAACM,iBAAiB,CAACJ,GAAG,CAAC,2BAA2B;YACjE,KAAK,MAAMK,SAASJ,YAAYK,MAAM,CAAE;gBACtC,IAAID,MAAME,UAAU,MAAMF,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F;MAEA,WAAe5B"}
@@ -0,0 +1,19 @@
1
+ import Compiler from 'webpack/lib/Compiler';
2
+ /**
3
+ * @typedef {import("webpack").Compiler} Compiler
4
+ * @typedef {import("webpack").Compilation} Compilation
5
+ * @typedef {import("webpack").Chunk} Chunk
6
+ * @typedef {import("webpack").Module} Module
7
+ */
8
+ /**
9
+ * This class is used to hoist container references in the code.
10
+ * @constructor
11
+ */
12
+ export declare class HoistContainerReferences {
13
+ /**
14
+ * @function apply
15
+ * @param {Compiler} compiler The webpack compiler object
16
+ */
17
+ apply(compiler: Compiler): void;
18
+ }
19
+ export default HoistContainerReferences;
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ HoistContainerReferences: function() {
13
+ return HoistContainerReferences;
14
+ },
15
+ default: function() {
16
+ return _default;
17
+ }
18
+ });
19
+ let HoistContainerReferences = class HoistContainerReferences {
20
+ /**
21
+ * @function apply
22
+ * @param {Compiler} compiler The webpack compiler object
23
+ */ apply(compiler) {
24
+ // Hook into the compilation process
25
+ compiler.hooks.thisCompilation.tap('HoistContainerReferences', (compilation)=>{
26
+ // After chunks are optimized, perform the hoisting
27
+ compilation.hooks.afterOptimizeChunks.tap('HoistContainerReferences', (chunks, chunkGroups)=>{
28
+ // Create a map to store chunks by their id or name
29
+ /** @type {Map<(string|number), Chunk>} */ const chunkSet = new Map();
30
+ // Create a set to store external module requests
31
+ /** @type {Set<Module>} */ const externalRequests = new Set();
32
+ // Populate the chunkSet with chunks
33
+ for (const chunk of chunks){
34
+ const ident = chunk.id || chunk.name;
35
+ if (ident) {
36
+ chunkSet.set(ident, chunk);
37
+ }
38
+ }
39
+ // Iterate over chunks again to handle remote modules
40
+ for (const chunk of chunks){
41
+ // Get iterable of remote modules for the chunk
42
+ const remoteModules = compilation.chunkGraph.getChunkModulesIterableBySourceType(chunk, 'remote');
43
+ if (!remoteModules) continue;
44
+ // Iterate over remote modules
45
+ for (const remoteModule of remoteModules){
46
+ // Iterate over dependencies of the remote module
47
+ for (const dep of remoteModule.dependencies){
48
+ // Get the module associated with the dependency
49
+ const mod = compilation.moduleGraph.getModule(dep);
50
+ // If the module exists and the chunk has a runtime, add the module to externalRequests
51
+ if (mod !== null && chunk.runtime) {
52
+ externalRequests.add(mod);
53
+ // Get the runtime chunk(s) associated with the chunk
54
+ const runtimeChunk = typeof chunk.runtime === 'string' || typeof chunk.runtime === 'number' ? [
55
+ chunk.runtime
56
+ ] : [
57
+ ...chunk.runtime
58
+ ];
59
+ // Iterate over runtime chunks
60
+ for (const runtimeChunkId of runtimeChunk){
61
+ // Get the runtime chunk from the chunkSet
62
+ const runtimeChunk = chunkSet.get(runtimeChunkId);
63
+ // If the runtime chunk exists, connect it with the module in the chunk graph
64
+ if (runtimeChunk) {
65
+ compilation.chunkGraph.connectChunkAndModule(runtimeChunk, mod);
66
+ }
67
+ }
68
+ }
69
+ }
70
+ }
71
+ }
72
+ });
73
+ });
74
+ }
75
+ };
76
+ const _default = HoistContainerReferences;
77
+
78
+ //# sourceMappingURL=HoistContainerReferencesPlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../packages/enhanced/src/lib/container/HoistContainerReferencesPlugin.ts"],"sourcesContent":["import Compiler from 'webpack/lib/Compiler';\nimport Module from 'webpack/lib/Module';\nimport Chunk from 'webpack/lib/Chunk';\nimport Compilation from 'webpack/lib/Compilation';\nimport ChunkGroup from 'webpack/lib/ChunkGroup';\n\n/**\n * @typedef {import(\"webpack\").Compiler} Compiler\n * @typedef {import(\"webpack\").Compilation} Compilation\n * @typedef {import(\"webpack\").Chunk} Chunk\n * @typedef {import(\"webpack\").Module} Module\n */\n\n/**\n * This class is used to hoist container references in the code.\n * @constructor\n */\nexport class HoistContainerReferences {\n /**\n * @function apply\n * @param {Compiler} compiler The webpack compiler object\n */\n apply(compiler: Compiler): void {\n // Hook into the compilation process\n compiler.hooks.thisCompilation.tap(\n 'HoistContainerReferences',\n (compilation: Compilation) => {\n // After chunks are optimized, perform the hoisting\n compilation.hooks.afterOptimizeChunks.tap(\n 'HoistContainerReferences',\n (chunks: Iterable<Chunk>, chunkGroups: ChunkGroup[]) => {\n // Create a map to store chunks by their id or name\n /** @type {Map<(string|number), Chunk>} */\n const chunkSet = new Map<string | number, Chunk>();\n // Create a set to store external module requests\n /** @type {Set<Module>} */\n const externalRequests = new Set<Module>();\n // Populate the chunkSet with chunks\n for (const chunk of chunks) {\n const ident = chunk.id || chunk.name;\n if (ident) {\n chunkSet.set(ident, chunk);\n }\n }\n // Iterate over chunks again to handle remote modules\n for (const chunk of chunks) {\n // Get iterable of remote modules for the chunk\n const remoteModules =\n compilation.chunkGraph.getChunkModulesIterableBySourceType(\n chunk,\n 'remote',\n );\n if (!remoteModules) continue;\n // Iterate over remote modules\n for (const remoteModule of remoteModules) {\n // Iterate over dependencies of the remote module\n for (const dep of remoteModule.dependencies) {\n // Get the module associated with the dependency\n const mod = compilation.moduleGraph.getModule(dep);\n // If the module exists and the chunk has a runtime, add the module to externalRequests\n if (mod !== null && chunk.runtime) {\n externalRequests.add(mod);\n // Get the runtime chunk(s) associated with the chunk\n const runtimeChunk =\n typeof chunk.runtime === 'string' ||\n typeof chunk.runtime === 'number'\n ? [chunk.runtime]\n : [...chunk.runtime];\n // Iterate over runtime chunks\n for (const runtimeChunkId of runtimeChunk) {\n // Get the runtime chunk from the chunkSet\n const runtimeChunk = chunkSet.get(runtimeChunkId);\n // If the runtime chunk exists, connect it with the module in the chunk graph\n if (runtimeChunk) {\n compilation.chunkGraph.connectChunkAndModule(\n runtimeChunk,\n mod,\n );\n }\n }\n }\n }\n }\n }\n },\n );\n },\n );\n }\n}\nexport default HoistContainerReferences;\n"],"names":["HoistContainerReferences","apply","compiler","hooks","thisCompilation","tap","compilation","afterOptimizeChunks","chunks","chunkGroups","chunkSet","Map","externalRequests","Set","chunk","ident","id","name","set","remoteModules","chunkGraph","getChunkModulesIterableBySourceType","remoteModule","dep","dependencies","mod","moduleGraph","getModule","runtime","add","runtimeChunk","runtimeChunkId","get","connectChunkAndModule"],"mappings":";;;;;;;;;;;IAiBaA,wBAAwB;eAAxBA;;IAyEb,OAAwC;eAAxC;;;AAzEO,IAAA,AAAMA,2BAAN,MAAMA;IACX;;;GAGC,GACDC,MAAMC,QAAkB,EAAQ;QAC9B,oCAAoC;QACpCA,SAASC,KAAK,CAACC,eAAe,CAACC,GAAG,CAChC,4BACA,CAACC;YACC,mDAAmD;YACnDA,YAAYH,KAAK,CAACI,mBAAmB,CAACF,GAAG,CACvC,4BACA,CAACG,QAAyBC;gBACxB,mDAAmD;gBACnD,wCAAwC,GACxC,MAAMC,WAAW,IAAIC;gBACrB,iDAAiD;gBACjD,wBAAwB,GACxB,MAAMC,mBAAmB,IAAIC;gBAC7B,oCAAoC;gBACpC,KAAK,MAAMC,SAASN,OAAQ;oBAC1B,MAAMO,QAAQD,MAAME,EAAE,IAAIF,MAAMG,IAAI;oBACpC,IAAIF,OAAO;wBACTL,SAASQ,GAAG,CAACH,OAAOD;oBACtB;gBACF;gBACA,qDAAqD;gBACrD,KAAK,MAAMA,SAASN,OAAQ;oBAC1B,+CAA+C;oBAC/C,MAAMW,gBACJb,YAAYc,UAAU,CAACC,mCAAmC,CACxDP,OACA;oBAEJ,IAAI,CAACK,eAAe;oBACpB,8BAA8B;oBAC9B,KAAK,MAAMG,gBAAgBH,cAAe;wBACxC,iDAAiD;wBACjD,KAAK,MAAMI,OAAOD,aAAaE,YAAY,CAAE;4BAC3C,gDAAgD;4BAChD,MAAMC,MAAMnB,YAAYoB,WAAW,CAACC,SAAS,CAACJ;4BAC9C,uFAAuF;4BACvF,IAAIE,QAAQ,QAAQX,MAAMc,OAAO,EAAE;gCACjChB,iBAAiBiB,GAAG,CAACJ;gCACrB,qDAAqD;gCACrD,MAAMK,eACJ,OAAOhB,MAAMc,OAAO,KAAK,YACzB,OAAOd,MAAMc,OAAO,KAAK,WACrB;oCAACd,MAAMc,OAAO;iCAAC,GACf;uCAAId,MAAMc,OAAO;iCAAC;gCACxB,8BAA8B;gCAC9B,KAAK,MAAMG,kBAAkBD,aAAc;oCACzC,0CAA0C;oCAC1C,MAAMA,eAAepB,SAASsB,GAAG,CAACD;oCAClC,6EAA6E;oCAC7E,IAAID,cAAc;wCAChBxB,YAAYc,UAAU,CAACa,qBAAqB,CAC1CH,cACAL;oCAEJ;gCACF;4BACF;wBACF;oBACF;gBACF;YACF;QAEJ;IAEJ;AACF;MACA,WAAezB"}
@@ -23,14 +23,13 @@ let RemoteRuntimeModule = class RemoteRuntimeModule extends _RuntimeModule.defau
23
23
  /**
24
24
  * @returns {string | null} runtime code
25
25
  */ generate() {
26
- var _this_chunk, _this_chunk1;
26
+ var _this_chunk;
27
27
  const { compilation, chunkGraph } = this;
28
28
  const { runtimeTemplate, moduleGraph } = compilation;
29
29
  const chunkToRemotesMapping = {};
30
30
  const idToExternalAndNameMapping = {};
31
31
  const allChunks = [
32
- ...Array.from(((_this_chunk = this.chunk) == null ? void 0 : _this_chunk.getAllAsyncChunks()) || []),
33
- ...Array.from(((_this_chunk1 = this.chunk) == null ? void 0 : _this_chunk1.getAllInitialChunks()) || [])
32
+ ...Array.from(((_this_chunk = this.chunk) == null ? void 0 : _this_chunk.getAllReferencedChunks()) || [])
34
33
  ];
35
34
  for (const chunk of allChunks){
36
35
  const modules = chunkGraph == null ? void 0 : chunkGraph.getChunkModulesIterableBySourceType(chunk, 'remote');
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../packages/enhanced/src/lib/container/RemoteRuntimeModule.ts"],"sourcesContent":["/*\n\tMIT License http://www.opensource.org/licenses/mit-license.php\n\tAuthor Tobias Koppers @sokra, Zackary Jackson @ScriptedAlchemy\n*/\nimport RuntimeGlobals from 'webpack/lib/RuntimeGlobals';\nimport type Compilation from 'webpack/lib/Compilation';\nimport RemoteModule from './RemoteModule';\nimport RuntimeModule from 'webpack/lib/RuntimeModule';\nimport Template from 'webpack/lib/Template';\n\nclass RemoteRuntimeModule extends RuntimeModule {\n constructor() {\n super('remotes loading');\n }\n\n /**\n * @returns {string | null} runtime code\n */\n override generate(): string | null {\n const { compilation, chunkGraph } = this;\n const { runtimeTemplate, moduleGraph } = compilation as Compilation;\n const chunkToRemotesMapping: Record<string, any> = {};\n const idToExternalAndNameMapping: Record<string | number, any> = {};\n const allChunks = [\n ...Array.from(this.chunk?.getAllAsyncChunks() || []),\n ...Array.from(this.chunk?.getAllInitialChunks() || []),\n ];\n\n for (const chunk of allChunks) {\n const modules = chunkGraph?.getChunkModulesIterableBySourceType(\n chunk,\n 'remote',\n );\n if (!modules) {\n continue;\n }\n // @ts-ignore\n const remotes = (chunkToRemotesMapping[chunk.id] = []);\n for (const m of modules) {\n const module: RemoteModule = m as RemoteModule;\n const name = module.internalRequest;\n const id = chunkGraph ? chunkGraph.getModuleId(module) : undefined;\n const { shareScope } = module;\n const dep = module.dependencies[0];\n const externalModule = moduleGraph.getModule(dep);\n const externalModuleId =\n chunkGraph && externalModule\n ? chunkGraph.getModuleId(externalModule)\n : undefined;\n if (id !== undefined) {\n //@ts-ignore\n remotes.push(id);\n idToExternalAndNameMapping[id] = [shareScope, name, externalModuleId];\n }\n }\n }\n return Template.asString([\n `var chunkMapping = ${JSON.stringify(\n chunkToRemotesMapping,\n null,\n '\\t',\n )};`,\n `var idToExternalAndNameMapping = ${JSON.stringify(\n idToExternalAndNameMapping,\n null,\n '\\t',\n )};`,\n `${\n RuntimeGlobals.ensureChunkHandlers\n }.remotes = ${runtimeTemplate.basicFunction('chunkId, promises', [\n `if(${RuntimeGlobals.hasOwnProperty}(chunkMapping, chunkId)) {`,\n Template.indent([\n `chunkMapping[chunkId].forEach(${runtimeTemplate.basicFunction('id', [\n `var getScope = ${RuntimeGlobals.currentRemoteGetScope};`,\n 'if(!getScope) getScope = [];',\n 'var data = idToExternalAndNameMapping[id];',\n 'if(getScope.indexOf(data) >= 0) return;',\n 'getScope.push(data);',\n `if(data.p) return promises.push(data.p);`,\n `var onError = ${runtimeTemplate.basicFunction('error', [\n 'if(!error) error = new Error(\"Container missing\");',\n 'if(typeof error.message === \"string\")',\n Template.indent(\n `error.message += '\\\\nwhile loading \"' + data[1] + '\" from ' + data[2];`,\n ),\n `${\n RuntimeGlobals.moduleFactories\n }[id] = ${runtimeTemplate.basicFunction('', ['throw error;'])}`,\n 'data.p = 0;',\n ])};`,\n `var handleFunction = ${runtimeTemplate.basicFunction(\n 'fn, arg1, arg2, d, next, first',\n [\n 'try {',\n Template.indent([\n 'var promise = fn(arg1, arg2);',\n 'if(promise && promise.then) {',\n Template.indent([\n `var p = promise.then(${runtimeTemplate.returningFunction(\n 'next(result, d)',\n 'result',\n )}, onError);`,\n `if(first) promises.push(data.p = p); else return p;`,\n ]),\n '} else {',\n Template.indent(['return next(promise, d, first);']),\n '}',\n ]),\n '} catch(error) {',\n Template.indent(['onError(error);']),\n '}',\n ],\n )}`,\n `var onExternal = ${runtimeTemplate.returningFunction(\n `external ? handleFunction(${RuntimeGlobals.initializeSharing}, data[0], 0, external, onInitialized, first) : onError()`,\n 'external, _, first',\n )};`,\n `var onInitialized = ${runtimeTemplate.returningFunction(\n `handleFunction(external.get, data[1], getScope, 0, onFactory, first)`,\n '_, external, first',\n )};`,\n `var onFactory = ${runtimeTemplate.basicFunction('factory', [\n 'data.p = 1;',\n `${\n RuntimeGlobals.moduleFactories\n }[id] = ${runtimeTemplate.basicFunction('module', [\n 'module.exports = factory();',\n ])}`,\n ])};`,\n `handleFunction(${RuntimeGlobals.require}, data[2], 0, 0, onExternal, 1);`,\n ])});`,\n ]),\n '}',\n ])}`,\n ]);\n }\n}\n\nexport default RemoteRuntimeModule;\n"],"names":["RemoteRuntimeModule","RuntimeModule","generate","compilation","chunkGraph","runtimeTemplate","moduleGraph","chunkToRemotesMapping","idToExternalAndNameMapping","allChunks","Array","from","chunk","getAllAsyncChunks","getAllInitialChunks","modules","getChunkModulesIterableBySourceType","remotes","id","m","module","name","internalRequest","getModuleId","undefined","shareScope","dep","dependencies","externalModule","getModule","externalModuleId","push","Template","asString","JSON","stringify","RuntimeGlobals","ensureChunkHandlers","basicFunction","hasOwnProperty","indent","currentRemoteGetScope","moduleFactories","returningFunction","initializeSharing","require","constructor"],"mappings":"AAAA;;;AAGA;;;;+BAuIA;;;eAAA;;;uEAtI2B;sEAGD;iEACL;;;;;;AAErB,IAAA,AAAMA,sBAAN,MAAMA,4BAA4BC,sBAAa;IAK7C;;GAEC,GACD,AAASC,WAA0B;YAMjB,aACA;QANhB,MAAM,EAAEC,WAAW,EAAEC,UAAU,EAAE,GAAG,IAAI;QACxC,MAAM,EAAEC,eAAe,EAAEC,WAAW,EAAE,GAAGH;QACzC,MAAMI,wBAA6C,CAAC;QACpD,MAAMC,6BAA2D,CAAC;QAClE,MAAMC,YAAY;eACbC,MAAMC,IAAI,CAAC,EAAA,cAAA,IAAI,CAACC,KAAK,qBAAV,YAAYC,iBAAiB,OAAM,EAAE;eAChDH,MAAMC,IAAI,CAAC,EAAA,eAAA,IAAI,CAACC,KAAK,qBAAV,aAAYE,mBAAmB,OAAM,EAAE;SACtD;QAED,KAAK,MAAMF,SAASH,UAAW;YAC7B,MAAMM,UAAUX,8BAAAA,WAAYY,mCAAmC,CAC7DJ,OACA;YAEF,IAAI,CAACG,SAAS;gBACZ;YACF;YACA,aAAa;YACb,MAAME,UAAWV,qBAAqB,CAACK,MAAMM,EAAE,CAAC,GAAG,EAAE;YACrD,KAAK,MAAMC,KAAKJ,QAAS;gBACvB,MAAMK,SAAuBD;gBAC7B,MAAME,OAAOD,OAAOE,eAAe;gBACnC,MAAMJ,KAAKd,aAAaA,WAAWmB,WAAW,CAACH,UAAUI;gBACzD,MAAM,EAAEC,UAAU,EAAE,GAAGL;gBACvB,MAAMM,MAAMN,OAAOO,YAAY,CAAC,EAAE;gBAClC,MAAMC,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AM,CAAC;oCACd,CAAC,qBAAqB,EAAEnC,gBAAgBsC,iBAAiB,CACvD,mBACA,UACA,WAAW,CAAC;oCACd,CAAC,mDAAmD,CAAC;iCACtD;gCACD;gCACAX,iBAAQ,CAACQ,MAAM,CAAC;oCAAC;iCAAkC;gCACnD;6BACD;4BACD;4BACAR,iBAAQ,CAACQ,MAAM,CAAC;gCAAC;6BAAkB;4BACnC;yBACD,EACD,CAAC;wBACH,CAAC,iBAAiB,EAAEnC,gBAAgBsC,iBAAiB,CACnD,CAAC,0BAA0B,EAAEP,uBAAc,CAACQ,iBAAiB,CAAC,yDAAyD,CAAC,EACxH,sBACA,CAAC,CAAC;wBACJ,CAAC,oBAAoB,EAAEvC,gBAAgBsC,iBAAiB,CACtD,CAAC,oEAAoE,CAAC,EACtE,sBACA,CAAC,CAAC;wBACJ,CAAC,gBAAgB,EAAEtC,gBAAgBiC,aAAa,CAAC,WAAW;4BAC1D;4BACA,CAAC,EACCF,uBAAc,CAACM,eAAe,CAC/B,OAAO,EAAErC,gBAAgBiC,aAAa,CAAC,UAAU;gCAChD;6BACD,EAAE,CAAC;yBACL,EAAE,CAAC,CAAC;wBACL,CAAC,eAAe,EAAEF,uBAAc,CAACS,OAAO,CAAC,gCAAgC,CAAC;qBAC3E,EAAE,EAAE,CAAC;iBACP;gBACD;aACD,EAAE,CAAC;SACL;IACH;IA5HAC,aAAc;QACZ,KAAK,CAAC;IACR;AA2HF;MAEA,WAAe9C"}
1
+ {"version":3,"sources":["../../../../../../packages/enhanced/src/lib/container/RemoteRuntimeModule.ts"],"sourcesContent":["/*\n\tMIT License http://www.opensource.org/licenses/mit-license.php\n\tAuthor Tobias Koppers @sokra, Zackary Jackson @ScriptedAlchemy\n*/\nimport RuntimeGlobals from 'webpack/lib/RuntimeGlobals';\nimport type Compilation from 'webpack/lib/Compilation';\nimport RemoteModule from './RemoteModule';\nimport RuntimeModule from 'webpack/lib/RuntimeModule';\nimport Template from 'webpack/lib/Template';\n\nclass RemoteRuntimeModule extends RuntimeModule {\n constructor() {\n super('remotes loading');\n }\n\n /**\n * @returns {string | null} runtime code\n */\n override generate(): string | null {\n const { compilation, chunkGraph } = this;\n const { runtimeTemplate, moduleGraph } = compilation as Compilation;\n const chunkToRemotesMapping: Record<string, any> = {};\n const idToExternalAndNameMapping: Record<string | number, any> = {};\n const allChunks = [\n ...Array.from(this.chunk?.getAllReferencedChunks() || []),\n ];\n\n for (const chunk of allChunks) {\n const modules = chunkGraph?.getChunkModulesIterableBySourceType(\n chunk,\n 'remote',\n );\n if (!modules) {\n continue;\n }\n // @ts-ignore\n const remotes = (chunkToRemotesMapping[chunk.id] = []);\n for (const m of modules) {\n const module: RemoteModule = m as RemoteModule;\n const name = module.internalRequest;\n const id = chunkGraph ? chunkGraph.getModuleId(module) : undefined;\n const { shareScope } = module;\n const dep = module.dependencies[0];\n const externalModule = moduleGraph.getModule(dep);\n const externalModuleId =\n chunkGraph && externalModule\n ? chunkGraph.getModuleId(externalModule)\n : undefined;\n if (id !== undefined) {\n //@ts-ignore\n remotes.push(id);\n idToExternalAndNameMapping[id] = [shareScope, name, externalModuleId];\n }\n }\n }\n return Template.asString([\n `var chunkMapping = ${JSON.stringify(\n chunkToRemotesMapping,\n null,\n '\\t',\n )};`,\n `var idToExternalAndNameMapping = ${JSON.stringify(\n idToExternalAndNameMapping,\n null,\n '\\t',\n )};`,\n `${\n RuntimeGlobals.ensureChunkHandlers\n }.remotes = ${runtimeTemplate.basicFunction('chunkId, promises', [\n `if(${RuntimeGlobals.hasOwnProperty}(chunkMapping, chunkId)) {`,\n Template.indent([\n `chunkMapping[chunkId].forEach(${runtimeTemplate.basicFunction('id', [\n `var getScope = ${RuntimeGlobals.currentRemoteGetScope};`,\n 'if(!getScope) getScope = [];',\n 'var data = idToExternalAndNameMapping[id];',\n 'if(getScope.indexOf(data) >= 0) return;',\n 'getScope.push(data);',\n `if(data.p) return promises.push(data.p);`,\n `var onError = ${runtimeTemplate.basicFunction('error', [\n 'if(!error) error = new Error(\"Container missing\");',\n 'if(typeof error.message === \"string\")',\n Template.indent(\n `error.message += '\\\\nwhile loading \"' + data[1] + '\" from ' + data[2];`,\n ),\n `${\n RuntimeGlobals.moduleFactories\n }[id] = ${runtimeTemplate.basicFunction('', ['throw error;'])}`,\n 'data.p = 0;',\n ])};`,\n `var handleFunction = ${runtimeTemplate.basicFunction(\n 'fn, arg1, arg2, d, next, first',\n [\n 'try {',\n Template.indent([\n 'var promise = fn(arg1, arg2);',\n 'if(promise && promise.then) {',\n Template.indent([\n `var p = promise.then(${runtimeTemplate.returningFunction(\n 'next(result, d)',\n 'result',\n )}, onError);`,\n `if(first) promises.push(data.p = p); else return p;`,\n ]),\n '} else {',\n Template.indent(['return next(promise, d, first);']),\n '}',\n ]),\n '} catch(error) {',\n Template.indent(['onError(error);']),\n '}',\n ],\n )}`,\n `var onExternal = ${runtimeTemplate.returningFunction(\n `external ? handleFunction(${RuntimeGlobals.initializeSharing}, data[0], 0, external, onInitialized, first) : onError()`,\n 'external, _, first',\n )};`,\n `var onInitialized = ${runtimeTemplate.returningFunction(\n `handleFunction(external.get, data[1], getScope, 0, onFactory, first)`,\n '_, external, first',\n )};`,\n `var onFactory = ${runtimeTemplate.basicFunction('factory', [\n 'data.p = 1;',\n `${\n RuntimeGlobals.moduleFactories\n }[id] = ${runtimeTemplate.basicFunction('module', [\n 'module.exports = factory();',\n ])}`,\n ])};`,\n `handleFunction(${RuntimeGlobals.require}, data[2], 0, 0, onExternal, 1);`,\n ])});`,\n ]),\n '}',\n ])}`,\n ]);\n }\n}\n\nexport default RemoteRuntimeModule;\n"],"names":["RemoteRuntimeModule","RuntimeModule","generate","compilation","chunkGraph","runtimeTemplate","moduleGraph","chunkToRemotesMapping","idToExternalAndNameMapping","allChunks","Array","from","chunk","getAllReferencedChunks","modules","getChunkModulesIterableBySourceType","remotes","id","m","module","name","internalRequest","getModuleId","undefined","shareScope","dep","dependencies","externalModule","getModule","externalModuleId","push","Template","asString","JSON","stringify","RuntimeGlobals","ensureChunkHandlers","basicFunction","hasOwnProperty","indent","currentRemoteGetScope","moduleFactories","returningFunction","initializeSharing","require","constructor"],"mappings":"AAAA;;;AAGA;;;;+BAsIA;;;eAAA;;;uEArI2B;sEAGD;iEACL;;;;;;AAErB,IAAA,AAAMA,sBAAN,MAAMA,4BAA4BC,sBAAa;IAK7C;;GAEC,GACD,AAASC,WAA0B;YAMjB;QALhB,MAAM,EAAEC,WAAW,EAAEC,UAAU,EAAE,GAAG,IAAI;QACxC,MAAM,EAAEC,eAAe,EAAEC,WAAW,EAAE,GAAGH;QACzC,MAAMI,wBAA6C,CAAC;QACpD,MAAMC,6BAA2D,CAAC;QAClE,MAAMC,YAAY;eACbC,MAAMC,IAAI,CAAC,EAAA,cAAA,IAAI,CAACC,KAAK,qBAAV,YAAYC,sBAAsB,OAAM,EAAE;SACzD;QAED,KAAK,MAAMD,SAASH,UAAW;YAC7B,MAAMK,UAAUV,8BAAAA,WAAYW,mCAAmC,CAC7DH,OACA;YAEF,IAAI,CAACE,SAAS;gBACZ;YACF;YACA,aAAa;YACb,MAAME,UAAWT,qBAAqB,CAACK,MAAMK,EAAE,CAAC,GAAG,EAAE;YACrD,KAAK,MAAMC,KAAKJ,QAAS;gBACvB,MAAMK,SAAuBD;gBAC7B,MAAME,OAAOD,OAAOE,eAAe;gBACnC,MAAMJ,KAAKb,aAAaA,WAAWkB,WAAW,CAACH,UAAUI;gBACzD,MAAM,EAAEC,UAAU,EAAE,GAAGL;gBACvB,MAAMM,MAAMN,OAAOO,YAAY,CAAC,EAAE;gBAClC,MAAMC,iBAAiBrB,YAAYsB,SAAS,CAACH;gBAC7C,MAAMI,mBACJzB,cAAcuB,iBACVvB,WAAWkB,WAAW,CAACK,kBACvBJ;gBACN,IAAIN,OAAOM,WAAW;oBACpB,YAAY;oBACZP,QAAQc,IAAI,CAACb;oBACbT,0BAA0B,CAACS,GAAG,GAAG;wBAACO;wBAAYJ;wBAAMS;qBAAiB;gBACvE;YACF;Q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C;yBACD,EACD,CAAC;wBACH,CAAC,iBAAiB,EAAElC,gBAAgBqC,iBAAiB,CACnD,CAAC,0BAA0B,EAAEP,uBAAc,CAACQ,iBAAiB,CAAC,yDAAyD,CAAC,EACxH,sBACA,CAAC,CAAC;wBACJ,CAAC,oBAAoB,EAAEtC,gBAAgBqC,iBAAiB,CACtD,CAAC,oEAAoE,CAAC,EACtE,sBACA,CAAC,CAAC;wBACJ,CAAC,gBAAgB,EAAErC,gBAAgBgC,aAAa,CAAC,WAAW;4BAC1D;4BACA,CAAC,EACCF,uBAAc,CAACM,eAAe,CAC/B,OAAO,EAAEpC,gBAAgBgC,aAAa,CAAC,UAAU;gCAChD;6BACD,EAAE,CAAC;yBACL,EAAE,CAAC,CAAC;wBACL,CAAC,eAAe,EAAEF,uBAAc,CAACS,OAAO,CAAC,gCAAgC,CAAC;qBAC3E,EAAE,EAAE,CAAC;iBACP;gBACD;aACD,EAAE,CAAC;SACL;IACH;IA3HAC,aAAc;QACZ,KAAK,CAAC;IACR;AA0HF;MAEA,WAAe7C"}
@@ -65,7 +65,7 @@ let ConsumeSharedRuntimeModule = class ConsumeSharedRuntimeModule extends _Runti
65
65
  /**
66
66
  * @returns {string | null} runtime code
67
67
  */ generate() {
68
- var _this_chunk, _this_chunk1, _this_chunk2;
68
+ var _this_chunk, _this_chunk1;
69
69
  const compilation = this.compilation;
70
70
  const chunkGraph = this.chunkGraph;
71
71
  const { runtimeTemplate, codeGenerationResults } = compilation;
@@ -86,8 +86,7 @@ let ConsumeSharedRuntimeModule = class ConsumeSharedRuntimeModule extends _Runti
86
86
  }
87
87
  };
88
88
  const allChunks = [
89
- ...((_this_chunk = this.chunk) == null ? void 0 : _this_chunk.getAllAsyncChunks()) || [],
90
- ...((_this_chunk1 = this.chunk) == null ? void 0 : _this_chunk1.getAllInitialChunks()) || []
89
+ ...((_this_chunk = this.chunk) == null ? void 0 : _this_chunk.getAllReferencedChunks()) || []
91
90
  ];
92
91
  for (const chunk of allChunks){
93
92
  const modules = chunkGraph.getChunkModulesIterableBySourceType(chunk, 'consume-shared');
@@ -96,7 +95,7 @@ let ConsumeSharedRuntimeModule = class ConsumeSharedRuntimeModule extends _Runti
96
95
  addModules(modules, chunk, chunkToModuleMapping[chunk.id.toString()] = []);
97
96
  }
98
97
  for (const chunk of [
99
- ...((_this_chunk2 = this.chunk) == null ? void 0 : _this_chunk2.getAllInitialChunks()) || []
98
+ ...((_this_chunk1 = this.chunk) == null ? void 0 : _this_chunk1.getAllInitialChunks()) || []
100
99
  ]){
101
100
  const modules = chunkGraph.getChunkModulesIterableBySourceType(chunk, 'consume-shared');
102
101
  if (!modules) continue;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../packages/enhanced/src/lib/sharing/ConsumeSharedRuntimeModule.ts"],"sourcesContent":["/*\n\tMIT License http://www.opensource.org/licenses/mit-license.php\n\tAuthor Tobias Koppers @sokra, Zackary Jackson @ScriptedAlchemy\n*/\n\nimport * as RuntimeGlobals from 'webpack/lib/RuntimeGlobals';\nimport Template from 'webpack/lib/Template';\nimport {\n parseVersionRuntimeCode,\n versionLtRuntimeCode,\n rangeToStringRuntimeCode,\n satisfyRuntimeCode,\n} from 'webpack/lib/util/semver';\nimport RuntimeModule from 'webpack/lib/RuntimeModule';\nimport Module from 'webpack/lib/Module';\nimport ConsumeSharedModule from './ConsumeSharedModule';\nimport type ChunkGraph from 'webpack/lib/ChunkGraph';\nimport type Compilation from 'webpack/lib/Compilation';\nimport type Chunk from 'webpack/lib/Chunk';\nimport { Source } from 'webpack-sources';\n\nclass ConsumeSharedRuntimeModule extends RuntimeModule {\n private _runtimeRequirements: ReadonlySet<string>;\n\n /**\n * @param {ReadonlySet<string>} runtimeRequirements runtime requirements\n */\n constructor(runtimeRequirements: ReadonlySet<string>) {\n super('consumes', RuntimeModule.STAGE_ATTACH);\n this._runtimeRequirements = runtimeRequirements;\n }\n\n /**\n * @returns {string | null} runtime code\n */\n override generate(): string | null {\n const compilation: Compilation = this.compilation!;\n const chunkGraph: ChunkGraph = this.chunkGraph!;\n const { runtimeTemplate, codeGenerationResults } = compilation;\n const chunkToModuleMapping: Record<string, any> = {};\n const moduleIdToSourceMapping: Map<string | number, Source> = new Map();\n const initialConsumes: (string | number)[] = [];\n /**\n *\n * @param {Iterable<Module>} modules modules\n * @param {Chunk} chunk the chunk\n * @param {(string | number)[]} list list of ids\n */\n const addModules = (\n modules: Iterable<Module>,\n chunk: Chunk,\n list: (string | number)[],\n ) => {\n for (const m of modules) {\n const module: ConsumeSharedModule = m as ConsumeSharedModule;\n const id = chunkGraph.getModuleId(module);\n list.push(id);\n moduleIdToSourceMapping.set(\n id,\n codeGenerationResults.getSource(\n module,\n chunk.runtime,\n 'consume-shared',\n ),\n );\n }\n };\n const allChunks = [\n ...(this.chunk?.getAllAsyncChunks() || []),\n ...(this.chunk?.getAllInitialChunks() || []),\n ];\n for (const chunk of allChunks) {\n const modules = chunkGraph.getChunkModulesIterableBySourceType(\n chunk,\n 'consume-shared',\n );\n if (!modules) continue;\n if (!chunk.id) continue;\n\n addModules(\n modules,\n chunk,\n (chunkToModuleMapping[chunk.id.toString()] = []),\n );\n }\n for (const chunk of [...(this.chunk?.getAllInitialChunks() || [])]) {\n const modules = chunkGraph.getChunkModulesIterableBySourceType(\n chunk,\n 'consume-shared',\n );\n if (!modules) continue;\n addModules(modules, chunk, initialConsumes);\n }\n\n if (moduleIdToSourceMapping.size === 0) return null;\n\n return Template.asString([\n parseVersionRuntimeCode(runtimeTemplate),\n versionLtRuntimeCode(runtimeTemplate),\n rangeToStringRuntimeCode(runtimeTemplate),\n satisfyRuntimeCode(runtimeTemplate),\n `var ensureExistence = ${runtimeTemplate.basicFunction('scopeName, key', [\n `var scope = ${RuntimeGlobals.shareScopeMap}[scopeName];`,\n `if(!scope || !${RuntimeGlobals.hasOwnProperty}(scope, key)) throw new Error(\"Shared module \" + key + \" doesn't exist in shared scope \" + scopeName);`,\n 'return scope;',\n ])};`,\n `var findVersion = ${runtimeTemplate.basicFunction('scope, key', [\n 'var versions = scope[key];',\n `var key = Object.keys(versions).reduce(${runtimeTemplate.basicFunction(\n 'a, b',\n ['return !a || versionLt(a, b) ? b : a;'],\n )}, 0);`,\n 'return key && versions[key]',\n ])};`,\n `var findSingletonVersionKey = ${runtimeTemplate.basicFunction(\n 'scope, key',\n [\n 'var versions = scope[key];',\n `return Object.keys(versions).reduce(${runtimeTemplate.basicFunction(\n 'a, b',\n ['return !a || (!versions[a].loaded && versionLt(a, b)) ? b : a;'],\n )}, 0);`,\n ],\n )};`,\n `var getInvalidSingletonVersionMessage = ${runtimeTemplate.basicFunction(\n 'scope, key, version, requiredVersion',\n [\n `return \"Unsatisfied version \" + version + \" from \" + (version && scope[key][version].from) + \" of shared singleton module \" + key + \" (required \" + rangeToString(requiredVersion) + \")\"`,\n ],\n )};`,\n `var getSingleton = ${runtimeTemplate.basicFunction(\n 'scope, scopeName, key, requiredVersion',\n [\n 'var version = findSingletonVersionKey(scope, key);',\n 'return get(scope[key][version]);',\n ],\n )};`,\n `var getSingletonVersion = ${runtimeTemplate.basicFunction(\n 'scope, scopeName, key, requiredVersion',\n [\n 'var version = findSingletonVersionKey(scope, key);',\n 'if (!satisfy(requiredVersion, version)) warn(getInvalidSingletonVersionMessage(scope, key, version, requiredVersion));',\n 'return get(scope[key][version]);',\n ],\n )};`,\n `var getStrictSingletonVersion = ${runtimeTemplate.basicFunction(\n 'scope, scopeName, key, requiredVersion',\n [\n 'var version = findSingletonVersionKey(scope, key);',\n 'if (!satisfy(requiredVersion, version)) ' +\n 'throw new Error(getInvalidSingletonVersionMessage(scope, key, version, requiredVersion));',\n 'return get(scope[key][version]);',\n ],\n )};`,\n `var findValidVersion = ${runtimeTemplate.basicFunction(\n 'scope, key, requiredVersion',\n [\n 'var versions = scope[key];',\n `var key = Object.keys(versions).reduce(${runtimeTemplate.basicFunction(\n 'a, b',\n [\n 'if (!satisfy(requiredVersion, b)) return a;',\n 'return !a || versionLt(a, b) ? b : a;',\n ],\n )}, 0);`,\n 'return key && versions[key]',\n ],\n )};`,\n `var getInvalidVersionMessage = ${runtimeTemplate.basicFunction(\n 'scope, scopeName, key, requiredVersion',\n [\n 'var versions = scope[key];',\n 'return \"No satisfying version (\" + rangeToString(requiredVersion) + \") of shared module \" + key + \" found in shared scope \" + scopeName + \".\\\\n\" +',\n `\\t\"Available versions: \" + Object.keys(versions).map(${runtimeTemplate.basicFunction(\n 'key',\n ['return key + \" from \" + versions[key].from;'],\n )}).join(\", \");`,\n ],\n )};`,\n `var getValidVersion = ${runtimeTemplate.basicFunction(\n 'scope, scopeName, key, requiredVersion',\n [\n 'var entry = findValidVersion(scope, key, requiredVersion);',\n 'if(entry) return get(entry);',\n 'throw new Error(getInvalidVersionMessage(scope, scopeName, key, requiredVersion));',\n ],\n )};`,\n `var warn = ${\n compilation.outputOptions.ignoreBrowserWarnings\n ? runtimeTemplate.basicFunction('', '')\n : runtimeTemplate.basicFunction('msg', [\n 'if (typeof console !== \"undefined\" && console.warn) console.warn(msg);',\n ])\n };`,\n `var warnInvalidVersion = ${runtimeTemplate.basicFunction(\n 'scope, scopeName, key, requiredVersion',\n [\n 'warn(getInvalidVersionMessage(scope, scopeName, key, requiredVersion));',\n ],\n )};`,\n `var get = ${runtimeTemplate.basicFunction('entry', [\n 'entry.loaded = 1;',\n 'return entry.get()',\n ])};`,\n `var init = ${runtimeTemplate.returningFunction(\n Template.asString([\n 'function(scopeName, a, b, c) {',\n Template.indent([\n `var promise = ${RuntimeGlobals.initializeSharing}(scopeName);`,\n `if (promise && promise.then) return promise.then(fn.bind(fn, scopeName, ${RuntimeGlobals.shareScopeMap}[scopeName], a, b, c));`,\n `return fn(scopeName, ${RuntimeGlobals.shareScopeMap}[scopeName], a, b, c);`,\n ]),\n '}',\n ]),\n 'fn',\n )};`,\n '',\n `var load = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(\n 'scopeName, scope, key',\n [\n 'ensureExistence(scopeName, key);',\n 'return get(findVersion(scope, key));',\n ],\n )});`,\n `var loadFallback = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(\n 'scopeName, scope, key, fallback',\n [\n `return scope && ${RuntimeGlobals.hasOwnProperty}(scope, key) ? get(findVersion(scope, key)) : fallback();`,\n ],\n )});`,\n `var loadVersionCheck = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(\n 'scopeName, scope, key, version',\n [\n 'ensureExistence(scopeName, key);',\n 'return get(findValidVersion(scope, key, version) || warnInvalidVersion(scope, scopeName, key, version) || findVersion(scope, key));',\n ],\n )});`,\n `var loadSingleton = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(\n 'scopeName, scope, key',\n [\n 'ensureExistence(scopeName, key);',\n 'return getSingleton(scope, scopeName, key);',\n ],\n )});`,\n `var loadSingletonVersionCheck = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(\n 'scopeName, scope, key, version',\n [\n 'ensureExistence(scopeName, key);',\n 'return getSingletonVersion(scope, scopeName, key, version);',\n ],\n )});`,\n `var loadStrictVersionCheck = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(\n 'scopeName, scope, key, version',\n [\n 'ensureExistence(scopeName, key);',\n 'return getValidVersion(scope, scopeName, key, version);',\n ],\n )});`,\n `var loadStrictSingletonVersionCheck = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(\n 'scopeName, scope, key, version',\n [\n 'ensureExistence(scopeName, key);',\n 'return getStrictSingletonVersion(scope, scopeName, key, version);',\n ],\n )});`,\n `var loadVersionCheckFallback = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(\n 'scopeName, scope, key, version, fallback',\n [\n `if(!scope || !${RuntimeGlobals.hasOwnProperty}(scope, key)) return fallback();`,\n 'return get(findValidVersion(scope, key, version) || warnInvalidVersion(scope, scopeName, key, version) || findVersion(scope, key));',\n ],\n )});`,\n `var loadSingletonFallback = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(\n 'scopeName, scope, key, fallback',\n [\n `if(!scope || !${RuntimeGlobals.hasOwnProperty}(scope, key)) return fallback();`,\n 'return getSingleton(scope, scopeName, key);',\n ],\n )});`,\n `var loadSingletonVersionCheckFallback = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(\n 'scopeName, scope, key, version, fallback',\n [\n `if(!scope || !${RuntimeGlobals.hasOwnProperty}(scope, key)) return fallback();`,\n 'return getSingletonVersion(scope, scopeName, key, version);',\n ],\n )});`,\n `var loadStrictVersionCheckFallback = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(\n 'scopeName, scope, key, version, fallback',\n [\n `var entry = scope && ${RuntimeGlobals.hasOwnProperty}(scope, key) && findValidVersion(scope, key, version);`,\n `return entry ? get(entry) : fallback();`,\n ],\n )});`,\n `var loadStrictSingletonVersionCheckFallback = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(\n 'scopeName, scope, key, version, fallback',\n [\n `if(!scope || !${RuntimeGlobals.hasOwnProperty}(scope, key)) return fallback();`,\n 'return getStrictSingletonVersion(scope, scopeName, key, version);',\n ],\n )});`,\n 'var installedModules = {};',\n 'var moduleToHandlerMapping = {',\n Template.indent(\n Array.from(\n moduleIdToSourceMapping,\n ([key, source]) => `${JSON.stringify(key)}: ${source.source()}`,\n ).join(',\\n'),\n ),\n '};',\n\n initialConsumes.length > 0\n ? Template.asString([\n `var initialConsumes = ${JSON.stringify(initialConsumes)};`,\n `initialConsumes.forEach(${runtimeTemplate.basicFunction('id', [\n `${\n RuntimeGlobals.moduleFactories\n }[id] = ${runtimeTemplate.basicFunction('module', [\n '// Handle case when module is used sync',\n 'installedModules[id] = 0;',\n `delete ${RuntimeGlobals.moduleCache}[id];`,\n 'var factory = moduleToHandlerMapping[id]();',\n 'if(typeof factory !== \"function\") throw new Error(\"Shared module is not available for eager consumption: \" + id);',\n `module.exports = factory();`,\n ])}`,\n ])});`,\n ])\n : '// no consumes in initial chunks',\n this._runtimeRequirements.has(RuntimeGlobals.ensureChunkHandlers)\n ? Template.asString([\n `var chunkMapping = ${JSON.stringify(\n chunkToModuleMapping,\n null,\n '\\t',\n )};`,\n `${\n RuntimeGlobals.ensureChunkHandlers\n }.consumes = ${runtimeTemplate.basicFunction('chunkId, promises', [\n `if(${RuntimeGlobals.hasOwnProperty}(chunkMapping, chunkId)) {`,\n Template.indent([\n `chunkMapping[chunkId].forEach(${runtimeTemplate.basicFunction(\n 'id',\n [\n `if(${RuntimeGlobals.hasOwnProperty}(installedModules, id)) return promises.push(installedModules[id]);`,\n `var onFactory = ${runtimeTemplate.basicFunction(\n 'factory',\n [\n 'installedModules[id] = 0;',\n `${\n RuntimeGlobals.moduleFactories\n }[id] = ${runtimeTemplate.basicFunction('module', [\n `delete ${RuntimeGlobals.moduleCache}[id];`,\n 'module.exports = factory();',\n ])}`,\n ],\n )};`,\n `var onError = ${runtimeTemplate.basicFunction('error', [\n 'delete installedModules[id];',\n `${\n RuntimeGlobals.moduleFactories\n }[id] = ${runtimeTemplate.basicFunction('module', [\n `delete ${RuntimeGlobals.moduleCache}[id];`,\n 'throw error;',\n ])}`,\n ])};`,\n 'try {',\n Template.indent([\n 'var promise = moduleToHandlerMapping[id]();',\n 'if(promise.then) {',\n Template.indent(\n \"promises.push(installedModules[id] = promise.then(onFactory)['catch'](onError));\",\n ),\n '} else onFactory(promise);',\n ]),\n '} catch(e) { onError(e); }',\n ],\n )});`,\n ]),\n '}',\n ])}`,\n ])\n : '// no chunk loading of consumes',\n ]);\n }\n}\n\nexport default ConsumeSharedRuntimeModule;\n"],"names":["ConsumeSharedRuntimeModule","RuntimeModule","generate","compilation","chunkGraph","runtimeTemplate","codeGenerationResults","chunkToModuleMapping","moduleIdToSourceMapping","Map","initialConsumes","addModules","modules","chunk","list","m","module","id","getModuleId","push","set","getSource","runtime","allChunks","getAllAsyncChunks","getAllInitialChunks","getChunkModulesIterableBySourceType","toString","size","Template","asString","parseVersionRuntimeCode","versionLtRuntimeCode","rangeToStringRuntimeCode","satisfyRuntimeCode","basicFunction","RuntimeGlobals","shareScopeMap","hasOwnProperty","outputOptions","ignoreBrowserWarnings","returningFunction","indent","initializeSharing","Array","from","key","source","JSON","stringify","join","length","moduleFactories","moduleCache","_runtimeRequirements","has","ensureChunkHandlers","constructor","runtimeRequirements","STAGE_ATTACH"],"mappings":"AAAA;;;AAGA;;;;+BA8XA;;;eAAA;;;wEA5XgC;iEACX;wBAMd;sEACmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQ1B,IAAA,AAAMA,6BAAN,MAAMA,mCAAmCC,sBAAa;IAWpD;;GAEC,GACD,AAASC,WAA0B;YAiC3B,aACA,cAgBmB;QAjDzB,MAAMC,cAA2B,IAAI,CAACA,WAAW;QACjD,MAAMC,aAAyB,IAAI,CAACA,UAAU;QAC9C,MAAM,EAAEC,eAAe,EAAEC,qBAAqB,EAAE,GAAGH;QACnD,MAAMI,uBAA4C,CAAC;QACnD,MAAMC,0BAAwD,IAAIC;QAClE,MAAMC,kBAAuC,EAAE;QAC/C;;;;;KAKC,GACD,MAAMC,aAAa,CACjBC,SACAC,OACAC;YAEA,KAAK,MAAMC,KAAKH,QAAS;gBACvB,MAAMI,SAA8BD;gBACpC,MAAME,KAAKb,WAAWc,WAAW,CAACF;gBAClCF,KAAKK,IAAI,CAACF;gBACVT,wBAAwBY,GAAG,CACzBH,IACAX,sBAAsBe,SAAS,CAC7BL,QACAH,MAAMS,OAAO,EACb;YAGN;QACF;QACA,MAAMC,YAAY;eACZ,EAAA,cAAA,IAAI,CAACV,KAAK,qBAAV,YAAYW,iBAAiB,OAAM,EAAE;eACrC,EAAA,eAAA,IAAI,CAACX,KAAK,qBAAV,aAAYY,mBAAmB,OAAM,EAAE;SAC5C;QACD,KAAK,MAAMZ,SAASU,UAAW;YAC7B,MAAMX,UAAUR,WAAWsB,mCAAmC,CAC5Db,OACA;YAEF,IAAI,CAACD,SAAS;YACd,IAAI,CAACC,MAAMI,EAAE,EAAE;YAEfN,WACEC,SACAC,OACCN,oBAAoB,CAACM,MAAMI,EAAE,CAACU,QAAQ,G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8B,aAAa,CAAC,qBAAqB;oBAChE,CAAC,GAAG,EAAEC,gBAAeE,cAAc,CAAC,0BAA0B,CAAC;oBAC/DT,iBAAQ,CAACa,MAAM,CAAC;wBACd,CAAC,8BAA8B,EAAErC,gBAAgB8B,aAAa,CAC5D,MACA;4BACE,CAAC,GAAG,EAAEC,gBAAeE,cAAc,CAAC,mEAAmE,CAAC;4BACxG,CAAC,gBAAgB,EAAEjC,gBAAgB8B,aAAa,CAC9C,WACA;gCACE;gCACA,CAAC,EACCC,gBAAegB,eAAe,CAC/B,OAAO,EAAE/C,gBAAgB8B,aAAa,CAAC,UAAU;oCAChD,CAAC,OAAO,EAAEC,gBAAeiB,WAAW,CAAC,KAAK,CAAC;oCAC3C;iCACD,EAAE,CAAC;6BACL,EACD,CAAC,CAAC;4BACJ,CAAC,cAAc,EAAEhD,gBAAgB8B,aAAa,CAAC,SAAS;gCACtD;gCACA,CAAC,EACCC,gBAAegB,eAAe,CAC/B,OAAO,EAAE/C,gBAAgB8B,aAAa,CAAC,UAAU;oCAChD,CAAC,OAAO,EAAEC,gBAAeiB,WAAW,CAAC,KAAK,CAAC;oCAC3C;iCACD,EAAE,CAAC;6BACL,EAAE,CAAC,CAAC;4BACL;4BACAxB,iBAAQ,CAACa,MAAM,CAAC;gCACd;gCACA;gCACAb,iBAAQ,CAACa,MAAM,CACb;gCAEF;6BACD;4BACD;yBACD,EACD,EAAE,CAAC;qBACN;oBACD;iBACD,EAAE,CAAC;aACL,IACD;SACL;IACH;IAtWA;;GAEC,GACDe,YAAYC,mBAAwC,CAAE;QACpD,KAAK,CAAC,YAAYzD,sBAAa,CAAC0D,YAAY;QAC5C,IAAI,CAACL,oBAAoB,GAAGI;IAC9B;AAiWF;MAEA,WAAe1D"}
1
+ {"version":3,"sources":["../../../../../../packages/enhanced/src/lib/sharing/ConsumeSharedRuntimeModule.ts"],"sourcesContent":["/*\n\tMIT License http://www.opensource.org/licenses/mit-license.php\n\tAuthor Tobias Koppers @sokra, Zackary Jackson @ScriptedAlchemy\n*/\n\nimport * as RuntimeGlobals from 'webpack/lib/RuntimeGlobals';\nimport Template from 'webpack/lib/Template';\nimport {\n parseVersionRuntimeCode,\n versionLtRuntimeCode,\n rangeToStringRuntimeCode,\n satisfyRuntimeCode,\n} from 'webpack/lib/util/semver';\nimport RuntimeModule from 'webpack/lib/RuntimeModule';\nimport Module from 'webpack/lib/Module';\nimport ConsumeSharedModule from './ConsumeSharedModule';\nimport type ChunkGraph from 'webpack/lib/ChunkGraph';\nimport type Compilation from 'webpack/lib/Compilation';\nimport type Chunk from 'webpack/lib/Chunk';\nimport { Source } from 'webpack-sources';\n\nclass ConsumeSharedRuntimeModule extends RuntimeModule {\n private _runtimeRequirements: ReadonlySet<string>;\n\n /**\n * @param {ReadonlySet<string>} runtimeRequirements runtime requirements\n */\n constructor(runtimeRequirements: ReadonlySet<string>) {\n super('consumes', RuntimeModule.STAGE_ATTACH);\n this._runtimeRequirements = runtimeRequirements;\n }\n\n /**\n * @returns {string | null} runtime code\n */\n override generate(): string | null {\n const compilation: Compilation = this.compilation!;\n const chunkGraph: ChunkGraph = this.chunkGraph!;\n const { runtimeTemplate, codeGenerationResults } = compilation;\n const chunkToModuleMapping: Record<string, any> = {};\n const moduleIdToSourceMapping: Map<string | number, Source> = new Map();\n const initialConsumes: (string | number)[] = [];\n /**\n *\n * @param {Iterable<Module>} modules modules\n * @param {Chunk} chunk the chunk\n * @param {(string | number)[]} list list of ids\n */\n const addModules = (\n modules: Iterable<Module>,\n chunk: Chunk,\n list: (string | number)[],\n ) => {\n for (const m of modules) {\n const module: ConsumeSharedModule = m as ConsumeSharedModule;\n const id = chunkGraph.getModuleId(module);\n list.push(id);\n moduleIdToSourceMapping.set(\n id,\n codeGenerationResults.getSource(\n module,\n chunk.runtime,\n 'consume-shared',\n ),\n );\n }\n };\n const allChunks = [...(this.chunk?.getAllReferencedChunks() || [])];\n for (const chunk of allChunks) {\n const modules = chunkGraph.getChunkModulesIterableBySourceType(\n chunk,\n 'consume-shared',\n );\n if (!modules) continue;\n if (!chunk.id) continue;\n\n addModules(\n modules,\n chunk,\n (chunkToModuleMapping[chunk.id.toString()] = []),\n );\n }\n for (const chunk of [...(this.chunk?.getAllInitialChunks() || [])]) {\n const modules = chunkGraph.getChunkModulesIterableBySourceType(\n chunk,\n 'consume-shared',\n );\n if (!modules) continue;\n addModules(modules, chunk, initialConsumes);\n }\n\n if (moduleIdToSourceMapping.size === 0) return null;\n\n return Template.asString([\n parseVersionRuntimeCode(runtimeTemplate),\n versionLtRuntimeCode(runtimeTemplate),\n rangeToStringRuntimeCode(runtimeTemplate),\n satisfyRuntimeCode(runtimeTemplate),\n `var ensureExistence = ${runtimeTemplate.basicFunction('scopeName, key', [\n `var scope = ${RuntimeGlobals.shareScopeMap}[scopeName];`,\n `if(!scope || !${RuntimeGlobals.hasOwnProperty}(scope, key)) throw new Error(\"Shared module \" + key + \" doesn't exist in shared scope \" + scopeName);`,\n 'return scope;',\n ])};`,\n `var findVersion = ${runtimeTemplate.basicFunction('scope, key', [\n 'var versions = scope[key];',\n `var key = Object.keys(versions).reduce(${runtimeTemplate.basicFunction(\n 'a, b',\n ['return !a || versionLt(a, b) ? b : a;'],\n )}, 0);`,\n 'return key && versions[key]',\n ])};`,\n `var findSingletonVersionKey = ${runtimeTemplate.basicFunction(\n 'scope, key',\n [\n 'var versions = scope[key];',\n `return Object.keys(versions).reduce(${runtimeTemplate.basicFunction(\n 'a, b',\n ['return !a || (!versions[a].loaded && versionLt(a, b)) ? b : a;'],\n )}, 0);`,\n ],\n )};`,\n `var getInvalidSingletonVersionMessage = ${runtimeTemplate.basicFunction(\n 'scope, key, version, requiredVersion',\n [\n `return \"Unsatisfied version \" + version + \" from \" + (version && scope[key][version].from) + \" of shared singleton module \" + key + \" (required \" + rangeToString(requiredVersion) + \")\"`,\n ],\n )};`,\n `var getSingleton = ${runtimeTemplate.basicFunction(\n 'scope, scopeName, key, requiredVersion',\n [\n 'var version = findSingletonVersionKey(scope, key);',\n 'return get(scope[key][version]);',\n ],\n )};`,\n `var getSingletonVersion = ${runtimeTemplate.basicFunction(\n 'scope, scopeName, key, requiredVersion',\n [\n 'var version = findSingletonVersionKey(scope, key);',\n 'if (!satisfy(requiredVersion, version)) warn(getInvalidSingletonVersionMessage(scope, key, version, requiredVersion));',\n 'return get(scope[key][version]);',\n ],\n )};`,\n `var getStrictSingletonVersion = ${runtimeTemplate.basicFunction(\n 'scope, scopeName, key, requiredVersion',\n [\n 'var version = findSingletonVersionKey(scope, key);',\n 'if (!satisfy(requiredVersion, version)) ' +\n 'throw new Error(getInvalidSingletonVersionMessage(scope, key, version, requiredVersion));',\n 'return get(scope[key][version]);',\n ],\n )};`,\n `var findValidVersion = ${runtimeTemplate.basicFunction(\n 'scope, key, requiredVersion',\n [\n 'var versions = scope[key];',\n `var key = Object.keys(versions).reduce(${runtimeTemplate.basicFunction(\n 'a, b',\n [\n 'if (!satisfy(requiredVersion, b)) return a;',\n 'return !a || versionLt(a, b) ? b : a;',\n ],\n )}, 0);`,\n 'return key && versions[key]',\n ],\n )};`,\n `var getInvalidVersionMessage = ${runtimeTemplate.basicFunction(\n 'scope, scopeName, key, requiredVersion',\n [\n 'var versions = scope[key];',\n 'return \"No satisfying version (\" + rangeToString(requiredVersion) + \") of shared module \" + key + \" found in shared scope \" + scopeName + \".\\\\n\" +',\n `\\t\"Available versions: \" + Object.keys(versions).map(${runtimeTemplate.basicFunction(\n 'key',\n ['return key + \" from \" + versions[key].from;'],\n )}).join(\", \");`,\n ],\n )};`,\n `var getValidVersion = ${runtimeTemplate.basicFunction(\n 'scope, scopeName, key, requiredVersion',\n [\n 'var entry = findValidVersion(scope, key, requiredVersion);',\n 'if(entry) return get(entry);',\n 'throw new Error(getInvalidVersionMessage(scope, scopeName, key, requiredVersion));',\n ],\n )};`,\n `var warn = ${\n compilation.outputOptions.ignoreBrowserWarnings\n ? runtimeTemplate.basicFunction('', '')\n : runtimeTemplate.basicFunction('msg', [\n 'if (typeof console !== \"undefined\" && console.warn) console.warn(msg);',\n ])\n };`,\n `var warnInvalidVersion = ${runtimeTemplate.basicFunction(\n 'scope, scopeName, key, requiredVersion',\n [\n 'warn(getInvalidVersionMessage(scope, scopeName, key, requiredVersion));',\n ],\n )};`,\n `var get = ${runtimeTemplate.basicFunction('entry', [\n 'entry.loaded = 1;',\n 'return entry.get()',\n ])};`,\n `var init = ${runtimeTemplate.returningFunction(\n Template.asString([\n 'function(scopeName, a, b, c) {',\n Template.indent([\n `var promise = ${RuntimeGlobals.initializeSharing}(scopeName);`,\n `if (promise && promise.then) return promise.then(fn.bind(fn, scopeName, ${RuntimeGlobals.shareScopeMap}[scopeName], a, b, c));`,\n `return fn(scopeName, ${RuntimeGlobals.shareScopeMap}[scopeName], a, b, c);`,\n ]),\n '}',\n ]),\n 'fn',\n )};`,\n '',\n `var load = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(\n 'scopeName, scope, key',\n [\n 'ensureExistence(scopeName, key);',\n 'return get(findVersion(scope, key));',\n ],\n )});`,\n `var loadFallback = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(\n 'scopeName, scope, key, fallback',\n [\n `return scope && ${RuntimeGlobals.hasOwnProperty}(scope, key) ? get(findVersion(scope, key)) : fallback();`,\n ],\n )});`,\n `var loadVersionCheck = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(\n 'scopeName, scope, key, version',\n [\n 'ensureExistence(scopeName, key);',\n 'return get(findValidVersion(scope, key, version) || warnInvalidVersion(scope, scopeName, key, version) || findVersion(scope, key));',\n ],\n )});`,\n `var loadSingleton = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(\n 'scopeName, scope, key',\n [\n 'ensureExistence(scopeName, key);',\n 'return getSingleton(scope, scopeName, key);',\n ],\n )});`,\n `var loadSingletonVersionCheck = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(\n 'scopeName, scope, key, version',\n [\n 'ensureExistence(scopeName, key);',\n 'return getSingletonVersion(scope, scopeName, key, version);',\n ],\n )});`,\n `var loadStrictVersionCheck = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(\n 'scopeName, scope, key, version',\n [\n 'ensureExistence(scopeName, key);',\n 'return getValidVersion(scope, scopeName, key, version);',\n ],\n )});`,\n `var loadStrictSingletonVersionCheck = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(\n 'scopeName, scope, key, version',\n [\n 'ensureExistence(scopeName, key);',\n 'return getStrictSingletonVersion(scope, scopeName, key, version);',\n ],\n )});`,\n `var loadVersionCheckFallback = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(\n 'scopeName, scope, key, version, fallback',\n [\n `if(!scope || !${RuntimeGlobals.hasOwnProperty}(scope, key)) return fallback();`,\n 'return get(findValidVersion(scope, key, version) || warnInvalidVersion(scope, scopeName, key, version) || findVersion(scope, key));',\n ],\n )});`,\n `var loadSingletonFallback = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(\n 'scopeName, scope, key, fallback',\n [\n `if(!scope || !${RuntimeGlobals.hasOwnProperty}(scope, key)) return fallback();`,\n 'return getSingleton(scope, scopeName, key);',\n ],\n )});`,\n `var loadSingletonVersionCheckFallback = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(\n 'scopeName, scope, key, version, fallback',\n [\n `if(!scope || !${RuntimeGlobals.hasOwnProperty}(scope, key)) return fallback();`,\n 'return getSingletonVersion(scope, scopeName, key, version);',\n ],\n )});`,\n `var loadStrictVersionCheckFallback = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(\n 'scopeName, scope, key, version, fallback',\n [\n `var entry = scope && ${RuntimeGlobals.hasOwnProperty}(scope, key) && findValidVersion(scope, key, version);`,\n `return entry ? get(entry) : fallback();`,\n ],\n )});`,\n `var loadStrictSingletonVersionCheckFallback = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(\n 'scopeName, scope, key, version, fallback',\n [\n `if(!scope || !${RuntimeGlobals.hasOwnProperty}(scope, key)) return fallback();`,\n 'return getStrictSingletonVersion(scope, scopeName, key, version);',\n ],\n )});`,\n 'var installedModules = {};',\n 'var moduleToHandlerMapping = {',\n Template.indent(\n Array.from(\n moduleIdToSourceMapping,\n ([key, source]) => `${JSON.stringify(key)}: ${source.source()}`,\n ).join(',\\n'),\n ),\n '};',\n\n initialConsumes.length > 0\n ? Template.asString([\n `var initialConsumes = ${JSON.stringify(initialConsumes)};`,\n `initialConsumes.forEach(${runtimeTemplate.basicFunction('id', [\n `${\n RuntimeGlobals.moduleFactories\n }[id] = ${runtimeTemplate.basicFunction('module', [\n '// Handle case when module is used sync',\n 'installedModules[id] = 0;',\n `delete ${RuntimeGlobals.moduleCache}[id];`,\n 'var factory = moduleToHandlerMapping[id]();',\n 'if(typeof factory !== \"function\") throw new Error(\"Shared module is not available for eager consumption: \" + id);',\n `module.exports = factory();`,\n ])}`,\n ])});`,\n ])\n : '// no consumes in initial chunks',\n this._runtimeRequirements.has(RuntimeGlobals.ensureChunkHandlers)\n ? Template.asString([\n `var chunkMapping = ${JSON.stringify(\n chunkToModuleMapping,\n null,\n '\\t',\n )};`,\n `${\n RuntimeGlobals.ensureChunkHandlers\n }.consumes = ${runtimeTemplate.basicFunction('chunkId, promises', [\n `if(${RuntimeGlobals.hasOwnProperty}(chunkMapping, chunkId)) {`,\n Template.indent([\n `chunkMapping[chunkId].forEach(${runtimeTemplate.basicFunction(\n 'id',\n [\n `if(${RuntimeGlobals.hasOwnProperty}(installedModules, id)) return promises.push(installedModules[id]);`,\n `var onFactory = ${runtimeTemplate.basicFunction(\n 'factory',\n [\n 'installedModules[id] = 0;',\n `${\n RuntimeGlobals.moduleFactories\n }[id] = ${runtimeTemplate.basicFunction('module', [\n `delete ${RuntimeGlobals.moduleCache}[id];`,\n 'module.exports = factory();',\n ])}`,\n ],\n )};`,\n `var onError = ${runtimeTemplate.basicFunction('error', [\n 'delete installedModules[id];',\n `${\n RuntimeGlobals.moduleFactories\n }[id] = ${runtimeTemplate.basicFunction('module', [\n `delete ${RuntimeGlobals.moduleCache}[id];`,\n 'throw error;',\n ])}`,\n ])};`,\n 'try {',\n Template.indent([\n 'var promise = moduleToHandlerMapping[id]();',\n 'if(promise.then) {',\n Template.indent(\n \"promises.push(installedModules[id] = promise.then(onFactory)['catch'](onError));\",\n ),\n '} else onFactory(promise);',\n ]),\n '} catch(e) { onError(e); }',\n ],\n )});`,\n ]),\n '}',\n ])}`,\n ])\n : '// no chunk loading of consumes',\n ]);\n }\n}\n\nexport default ConsumeSharedRuntimeModule;\n"],"names":["ConsumeSharedRuntimeModule","RuntimeModule","generate","compilation","chunkGraph","runtimeTemplate","codeGenerationResults","chunkToModuleMapping","moduleIdToSourceMapping","Map","initialConsumes","addModules","modules","chunk","list","m","module","id","getModuleId","push","set","getSource","runtime","allChunks","getAllReferencedChunks","getChunkModulesIterableBySourceType","toString","getAllInitialChunks","size","Template","asString","parseVersionRuntimeCode","versionLtRuntimeCode","rangeToStringRuntimeCode","satisfyRuntimeCode","basicFunction","RuntimeGlobals","shareScopeMap","hasOwnProperty","outputOptions","ignoreBrowserWarnings","returningFunction","indent","initializeSharing","Array","from","key","source","JSON","stringify","join","length","moduleFactories","moduleCache","_runtimeRequirements","has","ensureChunkHandlers","constructor","runtimeRequirements","STAGE_ATTACH"],"mappings":"AAAA;;;AAGA;;;;+BA2XA;;;eAAA;;;wEAzXgC;iEACX;wBAMd;sEACmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQ1B,IAAA,AAAMA,6BAAN,MAAMA,mCAAmCC,sBAAa;IAWpD;;GAEC,GACD,AAASC,WAA0B;YAgCV,aAeE;QA9CzB,MAAMC,cAA2B,IAAI,CAACA,WAAW;QACjD,MAAMC,aAAyB,IAAI,CAACA,UAAU;QAC9C,MAAM,EAAEC,eAAe,EAAEC,qBAAqB,EAAE,GAAGH;QACnD,MAAMI,uBAA4C,CAAC;QACnD,MAAMC,0BAAwD,IAAIC;QAClE,MAAMC,kBAAuC,EAAE;QAC/C;;;;;KAKC,GACD,MAAM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