@module-federation/node 2.1.0-canary.6 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +191 -0
  3. package/dist/jest.config.js.map +1 -0
  4. package/dist/package.json +78 -0
  5. package/dist/src/filesystem/stratagies.d.ts +18 -0
  6. package/{src → dist/src}/filesystem/stratagies.js +22 -9
  7. package/dist/src/filesystem/stratagies.js.map +1 -0
  8. package/{src → dist/src}/index.d.ts +0 -2
  9. package/{src → dist/src}/index.js +1 -5
  10. package/dist/src/index.js.map +1 -0
  11. package/{src → dist/src}/plugins/AutomaticPublicPathPlugin.d.ts +1 -1
  12. package/{src → dist/src}/plugins/AutomaticPublicPathPlugin.js +3 -3
  13. package/dist/src/plugins/AutomaticPublicPathPlugin.js.map +1 -0
  14. package/dist/src/plugins/ChunkCorrelationPlugin.js.map +1 -0
  15. package/{src → dist/src}/plugins/CommonJsChunkLoadingPlugin.js +24 -23
  16. package/dist/src/plugins/CommonJsChunkLoadingPlugin.js.map +1 -0
  17. package/{src → dist/src}/plugins/DynamicFilesystemChunkLoadingRuntimeModule.d.ts +1 -1
  18. package/{src → dist/src}/plugins/DynamicFilesystemChunkLoadingRuntimeModule.js +28 -56
  19. package/dist/src/plugins/DynamicFilesystemChunkLoadingRuntimeModule.js.map +1 -0
  20. package/dist/src/plugins/EntryChunkTrackerPlugin.d.ts +13 -0
  21. package/dist/src/plugins/EntryChunkTrackerPlugin.js +41 -0
  22. package/dist/src/plugins/EntryChunkTrackerPlugin.js.map +1 -0
  23. package/{src → dist/src}/plugins/NodeFederationPlugin.d.ts +0 -20
  24. package/dist/src/plugins/NodeFederationPlugin.js +79 -0
  25. package/dist/src/plugins/NodeFederationPlugin.js.map +1 -0
  26. package/{src → dist/src}/plugins/RemotePublicPathRuntimeModule.d.ts +1 -1
  27. package/dist/src/plugins/RemotePublicPathRuntimeModule.js +132 -0
  28. package/dist/src/plugins/RemotePublicPathRuntimeModule.js.map +1 -0
  29. package/{src → dist/src}/plugins/StreamingTargetPlugin.d.ts +2 -2
  30. package/{src → dist/src}/plugins/StreamingTargetPlugin.js.map +1 -1
  31. package/{src → dist/src}/plugins/UniversalFederationPlugin.d.ts +1 -0
  32. package/{src → dist/src}/plugins/UniversalFederationPlugin.js +7 -3
  33. package/dist/src/plugins/UniversalFederationPlugin.js.map +1 -0
  34. package/{src → dist/src}/plugins/webpackChunkUtilities.d.ts +1 -1
  35. package/{src → dist/src}/plugins/webpackChunkUtilities.js +70 -89
  36. package/dist/src/plugins/webpackChunkUtilities.js.map +1 -0
  37. package/dist/src/types/index.js.map +1 -0
  38. package/{src → dist/src}/utils/flush-chunks.d.ts +2 -1
  39. package/{src → dist/src}/utils/flush-chunks.js +43 -33
  40. package/dist/src/utils/flush-chunks.js.map +1 -0
  41. package/{src → dist/src}/utils/hot-reload.d.ts +3 -3
  42. package/{src → dist/src}/utils/hot-reload.js +59 -17
  43. package/dist/src/utils/hot-reload.js.map +1 -0
  44. package/dist/src/utils/index.js.map +1 -0
  45. package/package.json +22 -18
  46. package/jest.config.js.map +0 -1
  47. package/src/filesystem/stratagies.d.ts +0 -11
  48. package/src/filesystem/stratagies.js.map +0 -1
  49. package/src/index.js.map +0 -1
  50. package/src/plugins/AutomaticPublicPathPlugin.js.map +0 -1
  51. package/src/plugins/ChunkCorrelationPlugin.js.map +0 -1
  52. package/src/plugins/CommonJsChunkLoadingPlugin.js.map +0 -1
  53. package/src/plugins/DynamicFilesystemChunkLoadingRuntimeModule.js.map +0 -1
  54. package/src/plugins/NodeContainerPlugin.d.ts +0 -57
  55. package/src/plugins/NodeContainerPlugin.js +0 -105
  56. package/src/plugins/NodeContainerPlugin.js.map +0 -1
  57. package/src/plugins/NodeFederationPlugin.js +0 -127
  58. package/src/plugins/NodeFederationPlugin.js.map +0 -1
  59. package/src/plugins/RemotePublicPathRuntimeModule.js +0 -109
  60. package/src/plugins/RemotePublicPathRuntimeModule.js.map +0 -1
  61. package/src/plugins/UniversalFederationPlugin.js.map +0 -1
  62. package/src/plugins/webpackChunkUtilities.js.map +0 -1
  63. package/src/types/index.js.map +0 -1
  64. package/src/utils/flush-chunks.js.map +0 -1
  65. package/src/utils/hot-reload.js.map +0 -1
  66. package/src/utils/index.js.map +0 -1
  67. package/{jest.config.d.ts → dist/jest.config.d.ts} +0 -0
  68. package/{jest.config.js → dist/jest.config.js} +0 -0
  69. package/{src → dist/src}/plugins/ChunkCorrelationPlugin.d.ts +6 -6
  70. /package/{src → dist/src}/plugins/ChunkCorrelationPlugin.js +0 -0
  71. /package/{src → dist/src}/plugins/CommonJsChunkLoadingPlugin.d.ts +0 -0
  72. /package/{src → dist/src}/plugins/StreamingTargetPlugin.js +0 -0
  73. /package/{src → dist/src}/types/index.d.ts +0 -0
  74. /package/{src → dist/src}/types/index.js +0 -0
  75. /package/{src → dist/src}/utils/index.d.ts +0 -0
  76. /package/{src → dist/src}/utils/index.js +0 -0
@@ -1,31 +1,15 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const webpack_1 = require("webpack");
7
- const identifier_1 = require("webpack/lib/util/identifier");
3
+ const normalize_webpack_path_1 = require("@module-federation/sdk/normalize-webpack-path");
4
+ const { RuntimeGlobals, RuntimeModule } = require((0, normalize_webpack_path_1.normalizeWebpackPath)('webpack'));
5
+ const { getUndoPath } = require((0, normalize_webpack_path_1.normalizeWebpackPath)('webpack/lib/util/identifier'));
8
6
  const tapable_1 = require("tapable");
9
- const compileBooleanMatcher_1 = __importDefault(require("webpack/lib/util/compileBooleanMatcher"));
7
+ const compileBooleanMatcher = require((0, normalize_webpack_path_1.normalizeWebpackPath)('webpack/lib/util/compileBooleanMatcher'));
10
8
  const webpackChunkUtilities_1 = require("./webpackChunkUtilities");
11
9
  const stratagies_1 = require("../filesystem/stratagies");
12
- //hook can be tapped with
13
- // class MyPlugin {
14
- // apply(compiler: Compiler) {
15
- // compiler.hooks.thisCompilation.tap('MyPlugin', (compilation: Compilation) => {
16
- // compilation.hooks.runtimeModule.tap('MyPlugin', (module: RuntimeModule) => {
17
- // if (module instanceof DynamicFilesystemChunkLoadingRuntimeModule) {
18
- // module.hooks.strategyCase.tap('MyPlugin', (source: string) => {
19
- // return source + '\ncase "my-strategy": return myStrategy(chunkId,rootOutputDir, remotes, callback);';
20
- // });
21
- // }
22
- // });
23
- // });
24
- // }
25
- // }
26
- class DynamicFilesystemChunkLoadingRuntimeModule extends webpack_1.RuntimeModule {
10
+ class DynamicFilesystemChunkLoadingRuntimeModule extends RuntimeModule {
27
11
  constructor(runtimeRequirements, options, chunkLoadingContext) {
28
- super('readFile chunk loading', webpack_1.RuntimeModule.STAGE_ATTACH + 1);
12
+ super('readFile chunk loading', RuntimeModule.STAGE_ATTACH + 1);
29
13
  this.hooks = {
30
14
  strategyCase: new tapable_1.SyncWaterfallHook(['source']),
31
15
  };
@@ -42,9 +26,9 @@ class DynamicFilesystemChunkLoadingRuntimeModule extends webpack_1.RuntimeModule
42
26
  _generateBaseUri(chunk, rootOutputDir) {
43
27
  const options = chunk.getEntryOptions();
44
28
  if (options && options.baseUri) {
45
- return `${webpack_1.RuntimeGlobals.baseURI} = ${JSON.stringify(options.baseUri)};`;
29
+ return `${RuntimeGlobals.baseURI} = ${JSON.stringify(options.baseUri)};`;
46
30
  }
47
- return `${webpack_1.RuntimeGlobals.baseURI} = require("url").pathToFileURL(${rootOutputDir
31
+ return `${RuntimeGlobals.baseURI} = require("url").pathToFileURL(${rootOutputDir
48
32
  ? `__dirname + ${JSON.stringify('/' + rootOutputDir)}`
49
33
  : '__filename'});`;
50
34
  }
@@ -65,6 +49,7 @@ class DynamicFilesystemChunkLoadingRuntimeModule extends webpack_1.RuntimeModule
65
49
  const { remotes = {}, name } = this.options;
66
50
  const { webpack } = this.chunkLoadingContext;
67
51
  const { chunkGraph, chunk, compilation } = this;
52
+ const { Template } = webpack;
68
53
  if (!chunkGraph || !chunk || !compilation) {
69
54
  console.warn('Missing required properties. Returning empty string.');
70
55
  return '';
@@ -73,23 +58,23 @@ class DynamicFilesystemChunkLoadingRuntimeModule extends webpack_1.RuntimeModule
73
58
  const jsModulePlugin = webpack?.javascript?.JavascriptModulesPlugin ||
74
59
  require('webpack/lib/javascript/JavascriptModulesPlugin');
75
60
  const { chunkHasJs } = jsModulePlugin;
76
- const fn = webpack_1.RuntimeGlobals.ensureChunkHandlers;
61
+ const fn = RuntimeGlobals.ensureChunkHandlers;
77
62
  const conditionMap = chunkGraph.getChunkConditionMap(chunk, chunkHasJs);
78
- const hasJsMatcher = (0, compileBooleanMatcher_1.default)(conditionMap);
63
+ const hasJsMatcher = compileBooleanMatcher(conditionMap);
79
64
  const initialChunkIds = (0, webpackChunkUtilities_1.getInitialChunkIds)(chunk, chunkGraph, chunkHasJs);
80
65
  const outputName = compilation.getPath(jsModulePlugin.getChunkFilenameTemplate(chunk, compilation.outputOptions), { chunk, contentHashType: 'javascript' });
81
- const rootOutputDir = (0, identifier_1.getUndoPath)(outputName, compilation.outputOptions.path, false);
82
- const stateExpression = this.runtimeRequirements.has(webpack_1.RuntimeGlobals.hmrDownloadUpdateHandlers)
83
- ? `${webpack_1.RuntimeGlobals.hmrRuntimeStatePrefix}_readFileVm`
66
+ const rootOutputDir = getUndoPath(outputName, compilation.outputOptions.path || '', false);
67
+ const stateExpression = this.runtimeRequirements.has(RuntimeGlobals.hmrDownloadUpdateHandlers)
68
+ ? `${RuntimeGlobals.hmrRuntimeStatePrefix}_readFileVm`
84
69
  : undefined;
85
- const dynamicFilesystemChunkLoadingPluginCode = webpack_1.Template.asString([
70
+ const dynamicFilesystemChunkLoadingPluginCode = Template.asString([
86
71
  stratagies_1.fileSystemRunInContextStrategy.toString(),
87
72
  stratagies_1.httpEvalStrategy.toString(),
88
73
  stratagies_1.httpVmStrategy.toString(),
89
74
  'const loadChunkStrategy = async (strategyType,chunkId,rootOutputDir, remotes, callback) => {',
90
- webpack_1.Template.indent([
75
+ Template.indent([
91
76
  'switch (strategyType) {',
92
- webpack_1.Template.indent([
77
+ Template.indent([
93
78
  'case "filesystem": return await fileSystemRunInContextStrategy(chunkId,rootOutputDir, remotes, callback);',
94
79
  'case "http-eval": return await httpEvalStrategy(chunkId,rootOutputDir, remotes, callback);',
95
80
  'case "http-vm": return await httpVmStrategy(chunkId,rootOutputDir, remotes, callback);',
@@ -99,47 +84,34 @@ class DynamicFilesystemChunkLoadingRuntimeModule extends webpack_1.RuntimeModule
99
84
  ]),
100
85
  '};',
101
86
  ]);
102
- const remoteRegistry = webpack_1.Template.asString([
103
- `var remotes = ${JSON.stringify(Object.values(remotes).reduce((acc, remote) => {
104
- const [global, url] = remote.split('@');
105
- acc[global] = url;
106
- return acc;
107
- }, {}))};`,
108
- webpack_1.Template.asString([
109
- 'Object.keys(remotes).forEach(function(remote) {',
110
- webpack_1.Template.indent('globalThis.__remote_scope__._config[remote] = remotes[remote];'),
111
- '});',
112
- ]),
113
- ]);
114
- return webpack_1.Template.asString([
115
- remoteRegistry,
87
+ return Template.asString([
116
88
  dynamicFilesystemChunkLoadingPluginCode,
117
- this.runtimeRequirements.has(webpack_1.RuntimeGlobals.baseURI)
89
+ this.runtimeRequirements.has(RuntimeGlobals.baseURI)
118
90
  ? this._generateBaseUri(chunk, rootOutputDir)
119
91
  : '// no baseURI',
120
92
  '',
121
93
  '// object to store loaded chunks',
122
94
  '// "0" means "already loaded", Promise means loading',
123
95
  `var installedChunks = ${stateExpression ? `${stateExpression} = ${stateExpression} || ` : ''}{`,
124
- webpack_1.Template.indent(Array.from(initialChunkIds, (id) => `${JSON.stringify(id)}: 0`).join(',\n')),
96
+ Template.indent(Array.from(initialChunkIds, (id) => `${JSON.stringify(id)}: 0`).join(',\n')),
125
97
  '};',
126
98
  '',
127
- (0, webpackChunkUtilities_1.handleOnChunkLoad)(this.runtimeRequirements.has(webpack_1.RuntimeGlobals.onChunksLoaded), runtimeTemplate),
99
+ (0, webpackChunkUtilities_1.handleOnChunkLoad)(this.runtimeRequirements.has(RuntimeGlobals.onChunksLoaded), runtimeTemplate),
128
100
  '',
129
- (0, webpackChunkUtilities_1.generateInstallChunk)(runtimeTemplate, this.runtimeRequirements.has(webpack_1.RuntimeGlobals.onChunksLoaded)),
101
+ (0, webpackChunkUtilities_1.generateInstallChunk)(runtimeTemplate, this.runtimeRequirements.has(RuntimeGlobals.onChunksLoaded)),
130
102
  '',
131
- this.runtimeRequirements.has(webpack_1.RuntimeGlobals.ensureChunkHandlers)
103
+ this.runtimeRequirements.has(RuntimeGlobals.ensureChunkHandlers)
132
104
  ? (0, webpackChunkUtilities_1.generateLoadScript)(runtimeTemplate)
133
105
  : '// no remote script loader needed',
134
- this.runtimeRequirements.has(webpack_1.RuntimeGlobals.ensureChunkHandlers)
135
- ? (0, webpackChunkUtilities_1.generateLoadingCode)(this.runtimeRequirements.has(webpack_1.RuntimeGlobals.ensureChunkHandlers), fn, hasJsMatcher, rootOutputDir, remotes, name)
106
+ this.runtimeRequirements.has(RuntimeGlobals.ensureChunkHandlers)
107
+ ? (0, webpackChunkUtilities_1.generateLoadingCode)(this.runtimeRequirements.has(RuntimeGlobals.ensureChunkHandlers), fn, hasJsMatcher, rootOutputDir, remotes, name)
136
108
  : '// no chunk loading',
137
109
  '',
138
- (0, webpackChunkUtilities_1.generateExternalInstallChunkCode)(this.runtimeRequirements.has(webpack_1.RuntimeGlobals.externalInstallChunk), this.options.debug),
110
+ (0, webpackChunkUtilities_1.generateExternalInstallChunkCode)(this.runtimeRequirements.has(RuntimeGlobals.externalInstallChunk), this.options.debug),
139
111
  '',
140
- (0, webpackChunkUtilities_1.generateHmrCode)(this.runtimeRequirements.has(webpack_1.RuntimeGlobals.hmrDownloadUpdateHandlers), rootOutputDir),
112
+ (0, webpackChunkUtilities_1.generateHmrCode)(this.runtimeRequirements.has(RuntimeGlobals.hmrDownloadUpdateHandlers), rootOutputDir),
141
113
  '',
142
- (0, webpackChunkUtilities_1.generateHmrManifestCode)(this.runtimeRequirements.has(webpack_1.RuntimeGlobals.hmrDownloadManifest), rootOutputDir),
114
+ (0, webpackChunkUtilities_1.generateHmrManifestCode)(this.runtimeRequirements.has(RuntimeGlobals.hmrDownloadManifest), rootOutputDir),
143
115
  ]);
144
116
  }
145
117
  }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DynamicFilesystemChunkLoadingRuntimeModule.js","sourceRoot":"","sources":["../../../src/plugins/DynamicFilesystemChunkLoadingRuntimeModule.ts"],"names":[],"mappings":";;AAIA,0FAAqF;AACrF,MAAM,EAAE,cAAc,EAAE,aAAa,EAAE,GAAG,OAAO,CAC/C,IAAA,6CAAoB,EAAC,SAAS,CAAC,CACJ,CAAC;AAC9B,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAC7B,IAAA,6CAAoB,EAAC,6BAA6B,CAAC,CACJ,CAAC;AAClD,qCAA4C;AAC5C,MAAM,qBAAqB,GAAG,OAAO,CACnC,IAAA,6CAAoB,EAAC,wCAAwC,CAAC,CACJ,CAAC;AAC7D,mEASiC;AACjC,yDAIkC;AAmBlC,MAAM,0CAA2C,SAAQ,aAAa;IAQpE,YACE,mBAAgC,EAChC,OAA0D,EAC1D,mBAAwC;QAExC,KAAK,CAAC,wBAAwB,EAAE,aAAa,CAAC,YAAY,GAAG,CAAC,CAAC,CAAC;QATlE,UAAK,GAAG;YACN,YAAY,EAAE,IAAI,2BAAiB,CAAC,CAAC,QAAQ,CAAC,CAAC;SAChD,CAAC;QAQA,IAAI,CAAC,mBAAmB,GAAG,mBAAmB,CAAC;QAE/C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,mBAAmB,GAAG,mBAAmB,CAAC;IACjD,CAAC;IAED;;;;;OAKG;IACH,gBAAgB,CAAC,KAAY,EAAE,aAAqB;QAClD,MAAM,OAAO,GAAG,KAAK,CAAC,eAAe,E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,IAAI,CAAC,OAAO,CAAC,KAAK,CACnB;YACD,EAAE;YACF,IAAA,uCAAe,EACb,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,cAAc,CAAC,yBAAyB,CAAC,EACtE,aAAa,CACd;YACD,EAAE;YACF,IAAA,+CAAuB,EACrB,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,cAAc,CAAC,mBAAmB,CAAC,EAChE,aAAa,CACd;SACF,CAAC,CAAC;IACL,CAAC;CACF;AAED,kBAAe,0CAA0C,CAAC"}
@@ -0,0 +1,13 @@
1
+ import type { Compiler, Chunk, Module } from 'webpack';
2
+ export interface Options {
3
+ eager?: RegExp | ((module: Module) => boolean);
4
+ excludeChunk?: (chunk: Chunk) => boolean;
5
+ }
6
+ declare class EntryChunkTrackerPlugin {
7
+ private _options;
8
+ constructor(options?: Options);
9
+ apply(compiler: Compiler): void;
10
+ private _handleRenderStartup;
11
+ private _getTemplateString;
12
+ }
13
+ export default EntryChunkTrackerPlugin;
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const normalize_webpack_path_1 = require("@module-federation/sdk/normalize-webpack-path");
4
+ const SortableSet = require((0, normalize_webpack_path_1.normalizeWebpackPath)('webpack/lib/util/SortableSet'));
5
+ class EntryChunkTrackerPlugin {
6
+ constructor(options) {
7
+ this._options = options || {};
8
+ }
9
+ apply(compiler) {
10
+ compiler.hooks.thisCompilation.tap('EntryChunkTrackerPlugin', (compilation) => {
11
+ this._handleRenderStartup(compiler, compilation);
12
+ });
13
+ }
14
+ _handleRenderStartup(compiler, compilation) {
15
+ compiler.webpack.javascript.JavascriptModulesPlugin.getCompilationHooks(compilation).renderStartup.tap('EntryChunkTrackerPlugin', (source, _renderContext, upperContext) => {
16
+ if (this._options.excludeChunk &&
17
+ this._options.excludeChunk(upperContext.chunk)) {
18
+ return source;
19
+ }
20
+ const templateString = this._getTemplateString(compiler, source);
21
+ return new compiler.webpack.sources.ConcatSource(templateString);
22
+ });
23
+ }
24
+ _getTemplateString(compiler, source) {
25
+ const { Template } = compiler.webpack;
26
+ return Template.asString([
27
+ `if(typeof module !== 'undefined') {
28
+ globalThis.entryChunkCache = globalThis.entryChunkCache || new Set();
29
+ globalThis.entryChunkCache.add(module.filename);
30
+ if(module.children) {
31
+ module.children.forEach(function(c) {
32
+ globalThis.entryChunkCache.add(c.filename);
33
+ })
34
+ }
35
+ }`,
36
+ Template.indent(source.source().toString()),
37
+ ]);
38
+ }
39
+ }
40
+ exports.default = EntryChunkTrackerPlugin;
41
+ //# sourceMappingURL=EntryChunkTrackerPlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EntryChunkTrackerPlugin.js","sourceRoot":"","sources":["../../../src/plugins/EntryChunkTrackerPlugin.ts"],"names":[],"mappings":";;AAAA,0FAAqF;AAYrF,MAAM,WAAW,GAAG,OAAO,CACzB,IAAA,6CAAoB,EAAC,8BAA8B,CAAC,CACJ,CAAC;AAoBnD,MAAM,uBAAuB;IAG3B,YAAY,OAAiB;QAC3B,IAAI,CAAC,QAAQ,GAAG,OAAO,IAAI,EAAE,CAAC;IAChC,CAAC;IAED,KAAK,CAAC,QAAkB;QACtB,QAAQ,CAAC,KAAK,CAAC,eAAe,CAAC,GAAG,CAChC,yBAAyB,EACzB,CAAC,WAAwB,EAAE,EAAE;YAC3B,IAAI,CAAC,oBAAoB,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;QACnD,CAAC,CACF,CAAC;IACJ,CAAC;IACO,oBAAoB,CAAC,QAAkB,EAAE,WAAwB;QACvE,QAAQ,CAAC,OAAO,CAAC,UAAU,CAAC,uBAAuB,CAAC,mBAAmB,CACrE,WAAW,CACZ,CAAC,aAAa,CAAC,GAAG,CACjB,yBAAyB,EACzB,CACE,MAAsB,EACtB,cAAsB,EACtB,YAAkC,EAClC,EAAE;YACF,IACE,IAAI,CAAC,QAAQ,CAAC,YAAY;gBAC1B,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,YAAY,CAAC,KAAK,CAAC,EAC9C,CAAC;gBACD,OAAO,MAAM,CAAC;YAChB,CAAC;YAED,MAAM,cAAc,GAAG,IAAI,CAAC,kBAAkB,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;YAEjE,OAAO,IAAI,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC;QACnE,CAAC,CACF,CAAC;IACJ,CAAC;IAEO,kBAAkB,CAAC,QAAkB,EAAE,MAAsB;QACnE,MAAM,EAAE,QAAQ,EAAE,GAAG,QAAQ,CAAC,OAAO,CAAC;QACtC,OAAO,QAAQ,CAAC,QAAQ,CAAC;YACvB;;;;;;;;QAQE;YACF,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC;SAC5C,CAAC,CAAC;IACL,CAAC;CACF;AAED,kBAAe,uBAAuB,CAAC"}
@@ -18,25 +18,6 @@ interface NodeFederationOptions extends ModuleFederationPluginOptions {
18
18
  interface Context {
19
19
  ModuleFederationPlugin?: typeof container.ModuleFederationPlugin;
20
20
  }
21
- /**
22
- * This function iterates over all remotes and checks if they
23
- * are internal or not. If it's an internal remote then we add it to our new object
24
- * with a key of the name of the remote and value as internal. If it's not an internal
25
- * remote then we check if there is a '@' in that string which likely means it is a global @ url
26
- *
27
- * @param {Record<string, any>} remotes - The remotes to parse.
28
- * @returns {Record<string, string>} - The parsed remotes.
29
- * */
30
- export declare const parseRemotes: (remotes: Record<string, any>) => Record<string, string>;
31
- /**
32
- * Parses the remote syntax and returns a formatted string if the remote includes '@' and does not start with 'window', 'global', or 'globalThis'.
33
- * Otherwise, it returns the original remote string.
34
- *
35
- * @param {string} remote - The remote string to parse.
36
- * @returns {string} - The parsed remote string or the original remote string.
37
- * @throws {Error} - Throws an error if the remote is not a string.
38
- */
39
- export declare const parseRemoteSyntax: (remote: any) => string;
40
21
  /**
41
22
  * Class representing a NodeFederationPlugin.
42
23
  * @class
@@ -61,6 +42,5 @@ declare class NodeFederationPlugin {
61
42
  private preparePluginOptions;
62
43
  private updateCompilerOptions;
63
44
  private getModuleFederationPlugin;
64
- private loadModuleFederationPlugin;
65
45
  }
66
46
  export default NodeFederationPlugin;
@@ -0,0 +1,79 @@
1
+ 'use strict';
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const EntryChunkTrackerPlugin_1 = __importDefault(require("./EntryChunkTrackerPlugin"));
7
+ /**
8
+ * Class representing a NodeFederationPlugin.
9
+ * @class
10
+ */
11
+ class NodeFederationPlugin {
12
+ /**
13
+ * Create a NodeFederationPlugin.
14
+ * @constructor
15
+ * @param {NodeFederationOptions} options - The options for the NodeFederationPlugin
16
+ * @param {Context} context - The context for the NodeFederationPlugin
17
+ */
18
+ constructor({ experiments, debug, ...options }, context) {
19
+ this._options = options || {};
20
+ this.context = context || {};
21
+ this.experiments = experiments || {};
22
+ }
23
+ /**
24
+ * Apply method for the NodeFederationPlugin class.
25
+ * @method
26
+ * @param {Compiler} compiler - The webpack compiler.
27
+ */
28
+ apply(compiler) {
29
+ const { webpack } = compiler;
30
+ const pluginOptions = this.preparePluginOptions();
31
+ this.updateCompilerOptions(compiler);
32
+ const ModuleFederationPlugin = this.getModuleFederationPlugin(compiler, webpack);
33
+ new ModuleFederationPlugin(pluginOptions).apply(compiler);
34
+ new EntryChunkTrackerPlugin_1.default({}).apply(compiler);
35
+ }
36
+ preparePluginOptions() {
37
+ return {
38
+ ...this._options,
39
+ remotes: this._options.remotes || {},
40
+ };
41
+ }
42
+ updateCompilerOptions(compiler) {
43
+ if (compiler.options && compiler.options.output) {
44
+ //todo, need to change / remove
45
+ compiler.options.output.importMetaName = 'remoteContainerRegistry';
46
+ }
47
+ const chunkFileName = compiler.options?.output?.chunkFilename;
48
+ const uniqueName = compiler?.options?.output?.uniqueName || this._options.name;
49
+ if (typeof chunkFileName === 'string' &&
50
+ uniqueName &&
51
+ !chunkFileName.includes(uniqueName)) {
52
+ const suffix = `-[chunkhash].js`;
53
+ compiler.options.output.chunkFilename = chunkFileName.replace('.js', suffix);
54
+ }
55
+ }
56
+ getModuleFederationPlugin(compiler, webpack) {
57
+ let ModuleFederationPlugin;
58
+ try {
59
+ return require('@module-federation/enhanced').ModuleFederationPlugin;
60
+ }
61
+ catch (e) {
62
+ console.error("Can't find @module-federation/enhanced, falling back to webpack ModuleFederationPlugin, this may not work");
63
+ if (this.context.ModuleFederationPlugin) {
64
+ ModuleFederationPlugin = this.context.ModuleFederationPlugin;
65
+ }
66
+ else if (webpack &&
67
+ webpack.container &&
68
+ webpack.container.ModuleFederationPlugin) {
69
+ ModuleFederationPlugin = webpack.container.ModuleFederationPlugin;
70
+ }
71
+ else {
72
+ ModuleFederationPlugin = require('webpack/lib/container/ModuleFederationPlugin');
73
+ }
74
+ return ModuleFederationPlugin;
75
+ }
76
+ }
77
+ }
78
+ exports.default = NodeFederationPlugin;
79
+ //# sourceMappingURL=NodeFederationPlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NodeFederationPlugin.js","sourceRoot":"","sources":["../../../src/plugins/NodeFederationPlugin.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;AAIb,wFAAgE;AAqBhE;;;GAGG;AACH,MAAM,oBAAoB;IAKxB;;;;;OAKG;IACH,YACE,EAAE,WAAW,EAAE,KAAK,EAAE,GAAG,OAAO,EAAyB,EACzD,OAAgB;QAEhB,IAAI,CAAC,QAAQ,GAAG,OAAO,IAAK,EAAoC,CAAC;QACjE,IAAI,CAAC,OAAO,GAAG,OAAO,IAAK,EAAc,CAAC;QAC1C,IAAI,CAAC,WAAW,GAAG,WAAW,IAAI,EAAE,CAAC;IACvC,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,QAAkB;QACtB,MAAM,EAAE,OAAO,EAAE,GAAG,QAAQ,CAAC;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;QAC3B,IAAI,CAAC;YACH,OAAO,OAAO,CAAC,6BAA6B,CAAC,CAAC,sBAAsB,CAAC;QACvE,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,OAAO,CAAC,KAAK,CACX,2GAA2G,CAC5G,CAAC;YACF,IAAI,IAAI,CAAC,OAAO,CAAC,sBAAsB,EAAE,CAAC;gBACxC,sBAAsB,GAAG,IAAI,CAAC,OAAO,CAAC,sBAAsB,CAAC;YAC/D,CAAC;iBAAM,IACL,OAAO;gBACP,OAAO,CAAC,SAAS;gBACjB,OAAO,CAAC,SAAS,CAAC,sBAAsB,EACxC,CAAC;gBACD,sBAAsB,GAAG,OAAO,CAAC,SAAS,CAAC,sBAAsB,CAAC;YACpE,CAAC;iBAAM,CAAC;gBACN,sBAAsB,GAAG,OAAO,CAAC,8CAA8C,CAAC,CAAC;YACnF,CAAC;YACD,OAAO,sBAAsB,CAAC;QAChC,CAAC;IACH,CAAC;CACF;AAED,kBAAe,oBAAoB,CAAC"}
@@ -1,4 +1,4 @@
1
- import { RuntimeModule } from 'webpack';
1
+ declare const RuntimeModule: typeof import("webpack").RuntimeModule;
2
2
  declare class AutoPublicPathRuntimeModule extends RuntimeModule {
3
3
  private options;
4
4
  constructor(options: any);
@@ -0,0 +1,132 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const normalize_webpack_path_1 = require("@module-federation/sdk/normalize-webpack-path");
4
+ const { RuntimeGlobals, RuntimeModule, Template, javascript } = require((0, normalize_webpack_path_1.normalizeWebpackPath)('webpack'));
5
+ const { getUndoPath } = require((0, normalize_webpack_path_1.normalizeWebpackPath)('webpack/lib/util/identifier'));
6
+ class AutoPublicPathRuntimeModule extends RuntimeModule {
7
+ constructor(options) {
8
+ super('publicPath', RuntimeModule.STAGE_BASIC + 1);
9
+ this.options = options;
10
+ }
11
+ /**
12
+ * @returns {string} runtime code
13
+ */
14
+ generate() {
15
+ const { compilation } = this;
16
+ const { scriptType, path, publicPath, importMetaName, uniqueName, chunkLoading,
17
+ //@ts-ignore
18
+ } = compilation.outputOptions;
19
+ const getPath = () => compilation?.getPath(publicPath || '', {
20
+ hash: compilation?.hash || 'XXXX',
21
+ });
22
+ const chunkName = compilation?.getPath(javascript.JavascriptModulesPlugin.getChunkFilenameTemplate(this.chunk, compilation?.outputOptions), {
23
+ chunk: this.chunk,
24
+ contentHashType: 'javascript',
25
+ });
26
+ let undoPath = null;
27
+ if (chunkName && path) {
28
+ undoPath = getUndoPath(chunkName, path, false);
29
+ }
30
+ const getPathFromFederation = `
31
+ function getPathFromFederation() {
32
+ // Access the global federation manager or create a fallback object
33
+ var federationManager = globalThis.__FEDERATION__ || {};
34
+ // Access the current Webpack instance's federation details or create a fallback object
35
+ var instance = __webpack_require__.federation.instance || {};
36
+
37
+ // Function to aggregate all known remote module paths
38
+ var getAllKnownRemotes = function() {
39
+ var found = {};
40
+ // Iterate over all federation instances to collect module cache entries
41
+ (federationManager.__INSTANCES__ || []).forEach((instance) => {
42
+ instance.moduleCache.forEach((value, key) => {
43
+ found[key] = value;
44
+ });
45
+ });
46
+ return found;
47
+ };
48
+
49
+ // Retrieve the combined remote cache from all federation instances
50
+ const combinedRemoteCache = getAllKnownRemotes();
51
+ // Get the name of the current host from the instance
52
+ const hostName = instance.name;
53
+ // Find the path for the current host in the remote cache
54
+ const foundPath = combinedRemoteCache[hostName];
55
+ // If a path is not found, return undefined to indicate the absence of an entry path
56
+ if (!foundPath) { return undefined; }
57
+ // Return the entry path for the found remote module
58
+ const entryPath = foundPath.remoteInfo.entry;
59
+ return entryPath;
60
+ }
61
+ `;
62
+ const definePropertyCode = `
63
+ Object.defineProperty(__webpack_require__, "p", {
64
+ get: function() {
65
+ var scriptUrl;
66
+
67
+ // Attempt to get the script URL based on the environment
68
+ var scriptType = ${JSON.stringify(scriptType)};
69
+ var chunkLoading = ${JSON.stringify(chunkLoading)};
70
+ var isModuleEnvironment = ['module', 'node', 'async-node', 'require'].includes(scriptType) || chunkLoading;
71
+
72
+ if (isModuleEnvironment) {
73
+ try {
74
+ // Use Function constructor to avoid direct reference to import.meta in environments that do not support it
75
+ scriptUrl = (new Function('return typeof ${importMetaName}.url === "string" ? ${importMetaName}.url : undefined;'))();
76
+ } catch (e) {
77
+ // Handle cases where import.meta is not available or other errors occur
78
+ var scriptPath = getPathFromFederation();
79
+ if (scriptPath) {
80
+ scriptUrl = scriptPath;
81
+ } else if (typeof __filename !== "undefined") {
82
+ scriptUrl = __filename;
83
+ } else {
84
+ scriptUrl = ${publicPath !== 'auto' ? JSON.stringify(getPath()) : 'undefined'};
85
+ }
86
+ }
87
+ } else {
88
+ // Fallback for non-module environments, such as browsers
89
+ if (${RuntimeGlobals.global}.importScripts) {
90
+ scriptUrl = ${RuntimeGlobals.global}.location + "";
91
+ }
92
+ var document = ${RuntimeGlobals.global}.document;
93
+ if (!scriptUrl && document) {
94
+ if (document.currentScript) {
95
+ scriptUrl = document.currentScript.src;
96
+ } else {
97
+ var scripts = document.getElementsByTagName("script");
98
+ if (scripts.length) {
99
+ scriptUrl = scripts[scripts.length - 1].src;
100
+ }
101
+ }
102
+ }
103
+ }
104
+
105
+ if (!scriptUrl) {
106
+ throw new Error("Unable to calculate automatic public path");
107
+ }
108
+
109
+ // Clean up the script URL by removing any hash or query parameters
110
+ scriptUrl = scriptUrl.replace(/#.*$/, "").replace(/\\?.*$/, "").replace(/\\/[^\\/]+$/, "/");
111
+
112
+ // Apply any undo path that might be necessary for nested public paths
113
+ var finalScript = ${JSON.stringify(undoPath)} ? scriptUrl + ${JSON.stringify(undoPath)} : scriptUrl;
114
+
115
+ // Helper function to ensure the URL has a protocol if it starts with '//'
116
+ var addProtocol = function(url) {
117
+ return url.startsWith('//') ? 'https:' + url : url;
118
+ };
119
+
120
+ // Set the global variable for the public path
121
+ globalThis.currentVmokPublicPath = addProtocol(finalScript) || '/';
122
+
123
+ // Return the final public path
124
+ return finalScript
125
+ }
126
+ });
127
+ `;
128
+ return Template.asString([getPathFromFederation, definePropertyCode]);
129
+ }
130
+ }
131
+ exports.default = AutoPublicPathRuntimeModule;
132
+ //# sourceMappingURL=RemotePublicPathRuntimeModule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RemotePublicPathRuntimeModule.js","sourceRoot":"","sources":["../../../src/plugins/RemotePublicPathRuntimeModule.ts"],"names":[],"mappings":";;AAAA,0FAAqF;AACrF,MAAM,EAAE,cAAc,EAAE,aAAa,EAAE,QAAQ,EAAE,UAAU,EAAE,GAAG,OAAO,CACrE,IAAA,6CAAoB,EAAC,SAAS,CAAC,CACJ,CAAC;AAC9B,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAC7B,IAAA,6CAAoB,EAAC,6BAA6B,CAAC,CACJ,CAAC;AAElD,MAAM,2BAA4B,SAAQ,aAAa;IAGrD,YAAY,OAAY;QACtB,KAAK,CAAC,YAAY,EAAE,aAAa,CAAC,WAAW,GAAG,CAAC,CAAC,CAAC;QACnD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED;;OAEG;IACM,QAAQ;QACf,MAAM,EAAE,WAAW,EAAE,GAAG,IAAI,CAAC;QAC7B,MAAM,EACJ,UAAU,EACV,IAAI,EACJ,UAAU,EACV,cAAc,EACd,UAAU,EACV,YAAY;QACZ,YAAY;UACb,GAAG,WAAW,CAAC,aAAa,CAAC;QAE9B,MAAM,OAAO,GAAG,GAAG,EAAE,CACnB,WAAW,EAAE,OAAO,CAAC,UAAU,IAAI,EAAE,EAAE;YACrC,IAAI,EAAE,WAAW,EAAE,IAAI,IAAI,MAAM;SAClC,CAAC,CAAC;QAEL,MAAM,SAAS,GAAG,WAAW,EAAE,OAAO,CACpC,UAAU,CAAC,uBAAuB,CAAC,wBAAwB,CACzD,IAAI,CAAC,KAAK,EACV,WAAW,EAAE,aAAa,CAC3B,EACD;YACE,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,eAAe,EAAE,YAAY;SAC9B,CACF,CAAC;QAEF,IAAI,QAAQ,GAAkB,IAAI,CAAC;QACnC,IAAI,SAAS,IAAI,IAAI,EAAE,CAAC;YACtB,QAAQ,GAAG,WAAW,CAAC,SAAS,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;QACjD,CAAC;QAED,MAAM,qBAAqB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+BjC,CAAC;QACE,MAAM,kBAAkB,GAAG;;;;;;uBAMR,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC;yBACxB,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC;;;;;;mDAMF,cAAc,uBAAuB,cAAc;;;;;;;;;wBAU1F,UAAU,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,WACtD;;;;;YAKE,cAAc,CAAC,MAAM;sBACX,cAAc,CAAC,MAAM;;uBAEpB,cAAc,CAAC,MAAM;;;;;;;;;;;;;;;;;;;;;wBAqBpB,IAAI,CAAC,SAAS,CAChC,QAAQ,CACT,kBAAkB,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC;;;;;;;;;;;;;;CAc9C,CAAC;QAEE,OAAO,QAAQ,CAAC,QAAQ,CAAC,CAAC,qBAAqB,EAAE,kBAAkB,CAAC,CAAC,CAAC;IACxE,CAAC;CACF;AAED,kBAAe,2BAA2B,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { Compiler } from 'webpack';
1
+ import type { Compiler, WebpackPluginInstance } from 'webpack';
2
2
  import type { ModuleFederationPluginOptions } from '../types';
3
3
  /**
4
4
  * Interface for StreamingTargetOptions which extends ModuleFederationPluginOptions
@@ -12,7 +12,7 @@ interface StreamingTargetOptions extends ModuleFederationPluginOptions {
12
12
  /**
13
13
  * Class representing a StreamingTargetPlugin
14
14
  */
15
- declare class StreamingTargetPlugin {
15
+ declare class StreamingTargetPlugin implements WebpackPluginInstance {
16
16
  private options;
17
17
  /**
18
18
  * Create a StreamingTargetPlugin
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CAAC,iBAAiB,CAAC,CAAC;QACtE,CAAC;QAED,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,YAAY,GAAG,YAAY,CAAC;QAEpD,yBAAyB;QACzB,oEAAoE;QACpE,4DAA4D;QAC5D,8EAA8E;QAC9E,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,wBAAwB,GAAG,EAAE,CAAC;QACtD,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,WAAW,GAAG;YACpC,GAAG,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,WAAW;YACtC,aAAa,EAAE,IAAI;SACpB,CAAC;QAEF,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,qBAAqB;YACvC,OAAO,CAAC,wCAAwC,CAAC,CAAC,CAAC;YACnD,qBAAqB,EAAE,QAAQ,CAAC,OAAO,CAAC,qBAAqB;SAC9D,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAEnB,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,gBAAgB;YAClC,OAAO,CAAC,mCAAmC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAClE,IAAI,oCAA0B,CAAC;YAC7B,iBAAiB,EAAE,IAAI;YACvB,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI;YACvB,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,OAAiC;YACvD,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU;YAC3C,cAAc,EAAE,IAAI,CAAC,OAAO,CAAC,cAAc;YAC3C,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK;SAC1B,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IACrB,CAAC;CACF;AAED,kBAAe,qBAAqB,CAAC"}
@@ -24,6 +24,7 @@ interface NodeFederationContext {
24
24
  declare class UniversalFederationPlugin {
25
25
  private _options;
26
26
  private context;
27
+ private name;
27
28
  /**
28
29
  * Create a UniversalFederationPlugin
29
30
  * @param {NodeFederationOptions} options - The options for the plugin
@@ -8,6 +8,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
8
8
  */
9
9
  const StreamingTargetPlugin_1 = __importDefault(require("./StreamingTargetPlugin"));
10
10
  const NodeFederationPlugin_1 = __importDefault(require("./NodeFederationPlugin"));
11
+ const enhanced_1 = require("@module-federation/enhanced");
12
+ const normalize_webpack_path_1 = require("@module-federation/sdk/normalize-webpack-path");
11
13
  /**
12
14
  * Class representing a UniversalFederationPlugin
13
15
  */
@@ -20,6 +22,7 @@ class UniversalFederationPlugin {
20
22
  constructor(options, context) {
21
23
  this._options = options || {};
22
24
  this.context = context || {};
25
+ this.name = 'ModuleFederationPlugin';
23
26
  }
24
27
  /**
25
28
  * Apply the plugin to the compiler
@@ -28,6 +31,9 @@ class UniversalFederationPlugin {
28
31
  apply(compiler) {
29
32
  const { isServer, debug, ...options } = this._options;
30
33
  const { webpack } = compiler;
34
+ if (!process.env['FEDERATION_WEBPACK_PATH']) {
35
+ process.env['FEDERATION_WEBPACK_PATH'] = (0, normalize_webpack_path_1.getWebpackPath)(compiler);
36
+ }
31
37
  if (isServer ||
32
38
  compiler.options.name === 'server' ||
33
39
  compiler.options.target === 'node' ||
@@ -36,9 +42,7 @@ class UniversalFederationPlugin {
36
42
  new StreamingTargetPlugin_1.default({ ...options, debug }).apply(compiler);
37
43
  }
38
44
  else {
39
- new (this.context.ModuleFederationPlugin ||
40
- (webpack && webpack.container.ModuleFederationPlugin) ||
41
- require('webpack/lib/container/ModuleFederationPlugin'))(options).apply(compiler);
45
+ new enhanced_1.ModuleFederationPlugin(options).apply(compiler);
42
46
  }
43
47
  }
44
48
  }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UniversalFederationPlugin.js","sourceRoot":"","sources":["../../../src/plugins/UniversalFederationPlugin.ts"],"names":[],"mappings":";;;;;AAAA;;GAEG;AACH,oFAA4D;AAC5D,kFAA0D;AAC1D,0DAAqE;AAGrE,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ph } from 'webpack';
2
2
  /**
3
3
  * Generates the hot module replacement (HMR) code.
4
4
  * @param {boolean} withHmr - Flag indicating whether HMR is enabled.