@module-federation/node 0.0.0-docs-remove-invalid-lark-link-20251205062649

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 (64) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +235 -0
  3. package/dist/jest.config.d.ts +11 -0
  4. package/dist/jest.config.js +19 -0
  5. package/dist/jest.config.js.map +1 -0
  6. package/dist/package.json +90 -0
  7. package/dist/src/filesystem/stratagies.d.ts +18 -0
  8. package/dist/src/filesystem/stratagies.js +124 -0
  9. package/dist/src/filesystem/stratagies.js.map +1 -0
  10. package/dist/src/index.d.ts +7 -0
  11. package/dist/src/index.js +22 -0
  12. package/dist/src/index.js.map +1 -0
  13. package/dist/src/plugins/AutomaticPublicPathPlugin.d.ts +9 -0
  14. package/dist/src/plugins/AutomaticPublicPathPlugin.js +38 -0
  15. package/dist/src/plugins/AutomaticPublicPathPlugin.js.map +1 -0
  16. package/dist/src/plugins/ChunkCorrelationPlugin.d.ts +61 -0
  17. package/dist/src/plugins/ChunkCorrelationPlugin.js +441 -0
  18. package/dist/src/plugins/ChunkCorrelationPlugin.js.map +1 -0
  19. package/dist/src/plugins/CommonJsChunkLoadingPlugin.d.ts +17 -0
  20. package/dist/src/plugins/CommonJsChunkLoadingPlugin.js +121 -0
  21. package/dist/src/plugins/CommonJsChunkLoadingPlugin.js.map +1 -0
  22. package/dist/src/plugins/DynamicFilesystemChunkLoadingRuntimeModule.d.ts +40 -0
  23. package/dist/src/plugins/DynamicFilesystemChunkLoadingRuntimeModule.js +128 -0
  24. package/dist/src/plugins/DynamicFilesystemChunkLoadingRuntimeModule.js.map +1 -0
  25. package/dist/src/plugins/EntryChunkTrackerPlugin.d.ts +13 -0
  26. package/dist/src/plugins/EntryChunkTrackerPlugin.js +41 -0
  27. package/dist/src/plugins/EntryChunkTrackerPlugin.js.map +1 -0
  28. package/dist/src/plugins/NodeFederationPlugin.d.ts +46 -0
  29. package/dist/src/plugins/NodeFederationPlugin.js +88 -0
  30. package/dist/src/plugins/NodeFederationPlugin.js.map +1 -0
  31. package/dist/src/plugins/RemotePublicPathRuntimeModule.d.ts +10 -0
  32. package/dist/src/plugins/RemotePublicPathRuntimeModule.js +134 -0
  33. package/dist/src/plugins/RemotePublicPathRuntimeModule.js.map +1 -0
  34. package/dist/src/plugins/StreamingTargetPlugin.d.ts +28 -0
  35. package/dist/src/plugins/StreamingTargetPlugin.js +59 -0
  36. package/dist/src/plugins/StreamingTargetPlugin.js.map +1 -0
  37. package/dist/src/plugins/UniversalFederationPlugin.d.ts +45 -0
  38. package/dist/src/plugins/UniversalFederationPlugin.js +85 -0
  39. package/dist/src/plugins/UniversalFederationPlugin.js.map +1 -0
  40. package/dist/src/plugins/UniverseEntryChunkTrackerPlugin.d.ts +5 -0
  41. package/dist/src/plugins/UniverseEntryChunkTrackerPlugin.js +28 -0
  42. package/dist/src/plugins/UniverseEntryChunkTrackerPlugin.js.map +1 -0
  43. package/dist/src/plugins/webpackChunkUtilities.d.ts +50 -0
  44. package/dist/src/plugins/webpackChunkUtilities.js +304 -0
  45. package/dist/src/plugins/webpackChunkUtilities.js.map +1 -0
  46. package/dist/src/recordDynamicRemoteEntryHashPlugin.d.ts +3 -0
  47. package/dist/src/recordDynamicRemoteEntryHashPlugin.js +65 -0
  48. package/dist/src/recordDynamicRemoteEntryHashPlugin.js.map +1 -0
  49. package/dist/src/runtimePlugin.d.ts +22 -0
  50. package/dist/src/runtimePlugin.js +280 -0
  51. package/dist/src/runtimePlugin.js.map +1 -0
  52. package/dist/src/types/index.d.ts +3 -0
  53. package/dist/src/types/index.js +3 -0
  54. package/dist/src/types/index.js.map +1 -0
  55. package/dist/src/utils/flush-chunks.d.ts +11 -0
  56. package/dist/src/utils/flush-chunks.js +177 -0
  57. package/dist/src/utils/flush-chunks.js.map +1 -0
  58. package/dist/src/utils/hot-reload.d.ts +12 -0
  59. package/dist/src/utils/hot-reload.js +292 -0
  60. package/dist/src/utils/hot-reload.js.map +1 -0
  61. package/dist/src/utils/index.d.ts +2 -0
  62. package/dist/src/utils/index.js +19 -0
  63. package/dist/src/utils/index.js.map +1 -0
  64. package/package.json +90 -0
@@ -0,0 +1,45 @@
1
+ import { ModuleFederationPluginOptions } from '../types';
2
+ import type { Compiler, container } from 'webpack';
3
+ /**
4
+ * Interface for NodeFederationOptions
5
+ * @property {boolean} isServer - Indicates if the server is running
6
+ * @property {string} [promiseBaseURI] - The base URI for the promise
7
+ * @property {boolean} [debug] - Indicates if debug mode is enabled
8
+ */
9
+ interface NodeFederationOptions extends ModuleFederationPluginOptions {
10
+ isServer: boolean;
11
+ promiseBaseURI?: string;
12
+ debug?: boolean;
13
+ useRuntimePlugin?: boolean;
14
+ }
15
+ /**
16
+ * Interface for NodeFederationContext
17
+ * @property {typeof container.ModuleFederationPlugin} [ModuleFederationPlugin] - The ModuleFederationPlugin from webpack container
18
+ */
19
+ interface NodeFederationContext {
20
+ ModuleFederationPlugin?: typeof container.ModuleFederationPlugin;
21
+ }
22
+ /**
23
+ * Class representing a UniversalFederationPlugin
24
+ */
25
+ declare class UniversalFederationPlugin {
26
+ private _options;
27
+ private context;
28
+ private name;
29
+ /**
30
+ * Create a UniversalFederationPlugin
31
+ * @param {NodeFederationOptions} options - The options for the plugin
32
+ * @param {NodeFederationContext} context - The context for the plugin
33
+ */
34
+ constructor(options: NodeFederationOptions, context: NodeFederationContext);
35
+ private updateCompilerOptions;
36
+ /**
37
+ * Apply the plugin to the compiler
38
+ * @param {Compiler} compiler - The webpack compiler
39
+ */
40
+ apply(compiler: Compiler): void;
41
+ }
42
+ /**
43
+ * Exporting UniversalFederationPlugin as default
44
+ */
45
+ export default UniversalFederationPlugin;
@@ -0,0 +1,85 @@
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
+ /**
7
+ * Importing necessary plugins and types
8
+ */
9
+ const StreamingTargetPlugin_1 = __importDefault(require("./StreamingTargetPlugin"));
10
+ const NodeFederationPlugin_1 = __importDefault(require("./NodeFederationPlugin"));
11
+ const webpack_1 = require("@module-federation/enhanced/webpack");
12
+ const normalize_webpack_path_1 = require("@module-federation/sdk/normalize-webpack-path");
13
+ /**
14
+ * Class representing a UniversalFederationPlugin
15
+ */
16
+ class UniversalFederationPlugin {
17
+ /**
18
+ * Create a UniversalFederationPlugin
19
+ * @param {NodeFederationOptions} options - The options for the plugin
20
+ * @param {NodeFederationContext} context - The context for the plugin
21
+ */
22
+ constructor(options, context) {
23
+ this._options = options || {};
24
+ this.context = context || {};
25
+ this.name = 'ModuleFederationPlugin';
26
+ if (this._options.useRuntimePlugin && this._options.isServer) {
27
+ this._options.runtimePlugins = this._options.runtimePlugins
28
+ ? this._options.runtimePlugins.concat([
29
+ require.resolve('../runtimePlugin.js'),
30
+ ])
31
+ : [require.resolve('../runtimePlugin.js')];
32
+ }
33
+ }
34
+ updateCompilerOptions(compiler) {
35
+ compiler.options.output.chunkFormat = 'commonjs';
36
+ if (compiler.options.output.enabledLibraryTypes === undefined) {
37
+ compiler.options.output.enabledLibraryTypes = ['commonjs-module'];
38
+ }
39
+ else {
40
+ compiler.options.output.enabledLibraryTypes.push('commonjs-module');
41
+ }
42
+ const chunkFileName = compiler.options?.output?.chunkFilename;
43
+ const uniqueName = compiler?.options?.output?.uniqueName || this._options.name;
44
+ if (typeof chunkFileName === 'string' &&
45
+ uniqueName &&
46
+ !chunkFileName.includes(uniqueName)) {
47
+ const suffix = `-[contenthash].js`;
48
+ compiler.options.output.chunkFilename = chunkFileName.replace('.js', suffix);
49
+ }
50
+ }
51
+ /**
52
+ * Apply the plugin to the compiler
53
+ * @param {Compiler} compiler - The webpack compiler
54
+ */
55
+ apply(compiler) {
56
+ const { isServer, debug, useRuntimePlugin, ...options } = this._options;
57
+ const { webpack } = compiler;
58
+ if (!process.env['FEDERATION_WEBPACK_PATH']) {
59
+ process.env['FEDERATION_WEBPACK_PATH'] = (0, normalize_webpack_path_1.getWebpackPath)(compiler);
60
+ }
61
+ if (isServer ||
62
+ compiler.options.name === 'server' ||
63
+ compiler.options.target === 'node' ||
64
+ compiler.options.target === 'async-node') {
65
+ if (useRuntimePlugin) {
66
+ this.updateCompilerOptions(compiler);
67
+ new webpack_1.ModuleFederationPlugin({
68
+ ...options,
69
+ }).apply(compiler);
70
+ }
71
+ else {
72
+ new NodeFederationPlugin_1.default(options, this.context).apply(compiler);
73
+ new StreamingTargetPlugin_1.default({ ...options, debug }).apply(compiler);
74
+ }
75
+ }
76
+ else {
77
+ new webpack_1.ModuleFederationPlugin(options).apply(compiler);
78
+ }
79
+ }
80
+ }
81
+ /**
82
+ * Exporting UniversalFederationPlugin as default
83
+ */
84
+ exports.default = UniversalFederationPlugin;
85
+ //# sourceMappingURL=UniversalFederationPlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UniversalFederationPlugin.js","sourceRoot":"","sources":["../../../src/plugins/UniversalFederationPlugin.ts"],"names":[],"mappings":";;;;;AAAA;;GAEG;AACH,oFAA4D;AAC5D,kFAA0D;AAC1D,iEAA6E;AAG7E,0FAA+E;AAuB/E;;GAEG;AACH,MAAM,yBAAyB;IAK7B;;;;OAIG;IACH,YAAY,OAA8B,EAAE,OAA8B;QACxE,IAAI,CAAC,QAAQ,GAAG,OAAO,IAAK,EAA4B,CAAC;QACzD,IAAI,CAAC,OAAO,GAAG,OAAO,IAAK,EAA4B,CAAC;QACxD,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;QACrC,IAAI,IAAI,CAAC,QAAQ,CAAC,gBAAgB,IAAI,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC;YAC7D,IAAI,CAAC,QAAQ,CAAC,cAAc,GAAG,IAAI,CAAC,QAAQ,CAAC,cAAc;gBACzD,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAC;oBAClC,OAAO,CAAC,OA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CAAC,EAAE,CAAC;YAC5C,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC,GAAG,IAAA,uCAAc,EAAC,QAAQ,CAAC,CAAC;QACpE,CAAC;QACD,IACE,QAAQ;YACR,QAAQ,CAAC,OAAO,CAAC,IAAI,KAAK,QAAQ;YAClC,QAAQ,CAAC,OAAO,CAAC,MAAM,KAAK,MAAM;YAClC,QAAQ,CAAC,OAAO,CAAC,MAAM,KAAK,YAAY,EACxC,CAAC;YACD,IAAI,gBAAgB,EAAE,CAAC;gBACrB,IAAI,CAAC,qBAAqB,CAAC,QAAQ,CAAC,CAAC;gBACrC,IAAI,gCAAsB,CAAC;oBACzB,GAAG,OAAO;iBACX,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;YACrB,CAAC;iBAAM,CAAC;gBACN,IAAI,8BAAoB,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;gBAChE,IAAI,+BAAqB,CAAC,EAAE,GAAG,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;YACnE,CAAC;QACH,CAAC;aAAM,CAAC;YACN,IAAI,gCAAsB,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QACtD,CAAC;IACH,CAAC;CACF;AAED;;GAEG;AACH,kBAAe,yBAAyB,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { WebpackPluginInstance, Compiler } from 'webpack';
2
+ declare class UniverseEntryChunkTrackerPlugin implements WebpackPluginInstance {
3
+ apply(compiler: Compiler): void;
4
+ }
5
+ export default UniverseEntryChunkTrackerPlugin;
@@ -0,0 +1,28 @@
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 btoa_1 = __importDefault(require("btoa"));
7
+ class UniverseEntryChunkTrackerPlugin {
8
+ apply(compiler) {
9
+ const code = `
10
+ if(typeof module !== 'undefined') {
11
+ globalThis.entryChunkCache = globalThis.entryChunkCache || new Set();
12
+ module.filename && globalThis.entryChunkCache.add(module.filename);
13
+ if(module.children) {
14
+ module.children.forEach(function(c) {
15
+ c.filename && globalThis.entryChunkCache.add(c.filename);
16
+ })
17
+ }
18
+ }
19
+ `;
20
+ const base64Code = (0, btoa_1.default)(code);
21
+ const dataUrl = `data:text/javascript;base64,${base64Code}`;
22
+ compiler.hooks.afterPlugins.tap('UniverseEntryChunkTrackerPlugin', () => {
23
+ new compiler.webpack.EntryPlugin(compiler.context, dataUrl, {}).apply(compiler);
24
+ });
25
+ }
26
+ }
27
+ exports.default = UniverseEntryChunkTrackerPlugin;
28
+ //# sourceMappingURL=UniverseEntryChunkTrackerPlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UniverseEntryChunkTrackerPlugin.js","sourceRoot":"","sources":["../../../src/plugins/UniverseEntryChunkTrackerPlugin.ts"],"names":[],"mappings":";;;;;AAAA,gDAAyB;AAGzB,MAAM,+BAA+B;IACnC,KAAK,CAAC,QAAkB;QACtB,MAAM,IAAI,GAAG;;;;;;;;;;KAUZ,CAAC;QACF,MAAM,UAAU,GAAG,IAAA,cAAK,EAAC,IAAI,CAAC,CAAC;QAC/B,MAAM,OAAO,GAAG,+BAA+B,UAAU,EAAE,CAAC;QAE5D,QAAQ,CAAC,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,iCAAiC,EAAE,GAAG,EAAE;YACtE,IAAI,QAAQ,CAAC,OAAO,CAAC,WAAW,CAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC,KAAK,CACnE,QAAQ,CACT,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAED,kBAAe,+BAA+B,CAAC"}
@@ -0,0 +1,50 @@
1
+ import type { Chunk, ChunkGraph } from 'webpack';
2
+ /**
3
+ * Generates the hot module replacement (HMR) code.
4
+ * @param {boolean} withHmr - Flag indicating whether HMR is enabled.
5
+ * @param {string} rootOutputDir - The root output directory.
6
+ * @returns {string} - The generated HMR code.
7
+ */
8
+ export declare function generateHmrCode(withHmr: boolean, rootOutputDir: string): string;
9
+ /**
10
+ * Retrieves the initial chunk IDs.
11
+ * @param {Chunk} chunk - The chunk object.
12
+ * @param {ChunkGraph} chunkGraph - The chunk graph object.
13
+ * @param {any} chunkHasJs - Function to check if a chunk has JavaScript.
14
+ * @returns {Set} - The set of initial chunk IDs.
15
+ */
16
+ export declare function getInitialChunkIds(chunk: Chunk, chunkGraph: ChunkGraph, chunkHasJs: any): Set<Chunk.ChunkId>;
17
+ /**
18
+ * Generates the loading code for chunks.
19
+ * @param {boolean} withLoading - Flag indicating whether chunk loading is enabled.
20
+ * @param {string} fn - The function name.
21
+ * @param {any} hasJsMatcher - Function to check if a chunk has JavaScript.
22
+ * @param {string} rootOutputDir - The root output directory.
23
+ * @param {Record<string, string>} remotes - The remotes object.
24
+ * @param {string | undefined} name - The name of the chunk.
25
+ * @returns {string} - The generated loading code.
26
+ */
27
+ export declare function generateLoadingCode(withLoading: boolean, fn: string, hasJsMatcher: any, rootOutputDir: string, remotes: Record<string, string>, name: string | undefined): string;
28
+ /**
29
+ * Generates the HMR manifest code.
30
+ * @param {boolean} withHmrManifest - Flag indicating whether HMR manifest is enabled.
31
+ * @param {string} rootOutputDir - The root output directory.
32
+ * @returns {string} - The generated HMR manifest code.
33
+ */
34
+ export declare function generateHmrManifestCode(withHmrManifest: boolean, rootOutputDir: string): string;
35
+ /**
36
+ * Handles the on chunk load event.
37
+ * @param {boolean} withOnChunkLoad - Flag indicating whether on chunk load event is enabled.
38
+ * @param {any} runtimeTemplate - The runtime template.
39
+ * @returns {string} - The generated on chunk load event handler.
40
+ */
41
+ export declare function handleOnChunkLoad(withOnChunkLoad: boolean, runtimeTemplate: any): string;
42
+ /**
43
+ * Generates the load script for server-side execution. This function creates a script that loads a remote module
44
+ * and executes it in the current context. It supports both browser and Node.js environments.
45
+ * @param {any} runtimeTemplate - The runtime template used to generate the load script.
46
+ * @returns {string} - The generated load script.
47
+ */
48
+ export declare function generateLoadScript(runtimeTemplate: any): string;
49
+ export declare function generateInstallChunk(runtimeTemplate: any, withOnChunkLoad: boolean): string;
50
+ export declare function generateExternalInstallChunkCode(withExternalInstallChunk: boolean, debug: boolean | undefined): string;
@@ -0,0 +1,304 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateHmrCode = generateHmrCode;
4
+ exports.getInitialChunkIds = getInitialChunkIds;
5
+ exports.generateLoadingCode = generateLoadingCode;
6
+ exports.generateHmrManifestCode = generateHmrManifestCode;
7
+ exports.handleOnChunkLoad = handleOnChunkLoad;
8
+ exports.generateLoadScript = generateLoadScript;
9
+ exports.generateInstallChunk = generateInstallChunk;
10
+ exports.generateExternalInstallChunkCode = generateExternalInstallChunkCode;
11
+ const normalize_webpack_path_1 = require("@module-federation/sdk/normalize-webpack-path");
12
+ const { RuntimeGlobals, Template } = require((0, normalize_webpack_path_1.normalizeWebpackPath)('webpack'));
13
+ /**
14
+ * Generates the hot module replacement (HMR) code.
15
+ * @param {boolean} withHmr - Flag indicating whether HMR is enabled.
16
+ * @param {string} rootOutputDir - The root output directory.
17
+ * @returns {string} - The generated HMR code.
18
+ */
19
+ function generateHmrCode(withHmr, rootOutputDir) {
20
+ if (!withHmr) {
21
+ return '// no HMR';
22
+ }
23
+ return Template.asString([
24
+ // Function to load updated chunk
25
+ 'function loadUpdateChunk(chunkId, updatedModulesList) {',
26
+ Template.indent([
27
+ 'return new Promise(function(resolve, reject) {',
28
+ Template.indent([
29
+ // Construct filename for the updated chunk
30
+ `var filename = require('path').join(__dirname, ${JSON.stringify(rootOutputDir)} + ${RuntimeGlobals.getChunkUpdateScriptFilename}(chunkId));`,
31
+ // Read the updated chunk file
32
+ "require('fs').readFile(filename, 'utf-8', function(err, content) {",
33
+ Template.indent([
34
+ 'if(err) return reject(err);',
35
+ 'var update = {};',
36
+ // Execute the updated chunk in the current context
37
+ "require('vm').runInThisContext('(function(exports, require, __dirname, __filename) {' + content + '\\n})', filename)" +
38
+ "(update, require, require('path').dirname(filename), filename);",
39
+ 'var updatedModules = update.modules;',
40
+ 'var runtime = update.runtime;',
41
+ // Iterate over the updated modules
42
+ 'for(var moduleId in updatedModules) {',
43
+ Template.indent([
44
+ `if(${RuntimeGlobals.hasOwnProperty}(updatedModules, moduleId)) {`,
45
+ Template.indent([
46
+ `currentUpdate[moduleId] = updatedModules[moduleId];`,
47
+ 'if(updatedModulesList) updatedModulesList.push(moduleId);',
48
+ ]),
49
+ '}',
50
+ ]),
51
+ '}',
52
+ 'if(runtime) currentUpdateRuntime.push(runtime);',
53
+ 'resolve();',
54
+ ]),
55
+ '});',
56
+ ]),
57
+ '});',
58
+ ]),
59
+ '}',
60
+ '',
61
+ // Replace placeholders in the HMR runtime code
62
+ Template.getFunctionContent(
63
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
64
+ require('webpack/lib/hmr/JavascriptHotModuleReplacement.runtime.js'))
65
+ .replace(/\$key\$/g, 'readFileVm')
66
+ .replace(/\$installedChunks\$/g, 'installedChunks')
67
+ .replace(/\$loadUpdateChunk\$/g, 'loadUpdateChunk')
68
+ .replace(/\$moduleCache\$/g, RuntimeGlobals.moduleCache)
69
+ .replace(/\$moduleFactories\$/g, RuntimeGlobals.moduleFactories)
70
+ .replace(/\$ensureChunkHandlers\$/g, RuntimeGlobals.ensureChunkHandlers)
71
+ .replace(/\$hasOwnProperty\$/g, RuntimeGlobals.hasOwnProperty)
72
+ .replace(/\$hmrModuleData\$/g, RuntimeGlobals.hmrModuleData)
73
+ .replace(/\$hmrDownloadUpdateHandlers\$/g, RuntimeGlobals.hmrDownloadUpdateHandlers)
74
+ .replace(/\$hmrInvalidateModuleHandlers\$/g, RuntimeGlobals.hmrInvalidateModuleHandlers),
75
+ ]);
76
+ }
77
+ /**
78
+ * Retrieves the initial chunk IDs.
79
+ * @param {Chunk} chunk - The chunk object.
80
+ * @param {ChunkGraph} chunkGraph - The chunk graph object.
81
+ * @param {any} chunkHasJs - Function to check if a chunk has JavaScript.
82
+ * @returns {Set} - The set of initial chunk IDs.
83
+ */
84
+ function getInitialChunkIds(chunk, chunkGraph, chunkHasJs) {
85
+ const initialChunkIds = new Set(chunk.ids);
86
+ for (const c of chunk.getAllInitialChunks()) {
87
+ if (c === chunk || chunkHasJs(c, chunkGraph))
88
+ continue;
89
+ if (c.ids) {
90
+ for (const id of c.ids)
91
+ initialChunkIds.add(id);
92
+ }
93
+ for (const c of chunk.getAllAsyncChunks()) {
94
+ if (c === chunk || chunkHasJs(c, chunkGraph))
95
+ continue;
96
+ if (c.ids) {
97
+ for (const id of c.ids)
98
+ initialChunkIds.add(id);
99
+ }
100
+ }
101
+ }
102
+ return initialChunkIds;
103
+ }
104
+ /**
105
+ * Generates the loading code for chunks.
106
+ * @param {boolean} withLoading - Flag indicating whether chunk loading is enabled.
107
+ * @param {string} fn - The function name.
108
+ * @param {any} hasJsMatcher - Function to check if a chunk has JavaScript.
109
+ * @param {string} rootOutputDir - The root output directory.
110
+ * @param {Record<string, string>} remotes - The remotes object.
111
+ * @param {string | undefined} name - The name of the chunk.
112
+ * @returns {string} - The generated loading code.
113
+ */
114
+ function generateLoadingCode(withLoading, fn, hasJsMatcher, rootOutputDir, remotes, name) {
115
+ if (!withLoading) {
116
+ return '// no chunk loading';
117
+ }
118
+ return Template.asString([
119
+ '// Dynamic filesystem chunk loading for javascript',
120
+ `${fn}.readFileVm = function(chunkId, promises) {`,
121
+ hasJsMatcher !== false
122
+ ? Template.indent([
123
+ 'var installedChunkData = installedChunks[chunkId];',
124
+ 'if(installedChunkData !== 0) { // 0 means "already installed".',
125
+ Template.indent([
126
+ '// array of [resolve, reject, promise] means "currently loading"',
127
+ 'if(installedChunkData) {',
128
+ Template.indent(['promises.push(installedChunkData[2]);']),
129
+ '} else {',
130
+ Template.indent([
131
+ hasJsMatcher === true
132
+ ? 'if(true) { // all chunks have JS'
133
+ : `if(${hasJsMatcher('chunkId')}) {`,
134
+ Template.indent([
135
+ '// load the chunk and return promise to it',
136
+ 'var promise = new Promise(async function(resolve, reject) {',
137
+ Template.indent([
138
+ 'installedChunkData = installedChunks[chunkId] = [resolve, reject];',
139
+ 'function installChunkCallback(error,chunk){',
140
+ Template.indent([
141
+ 'if(error) return reject(error);',
142
+ 'installChunk(chunk);',
143
+ ]),
144
+ '}',
145
+ 'var fs = typeof process !== "undefined" ? require(\'fs\') : false;',
146
+ `var filename = typeof process !== "undefined" ? require('path').join(__dirname, ${JSON.stringify(rootOutputDir)} + ${RuntimeGlobals.getChunkScriptFilename}(chunkId)) : false;`,
147
+ 'if(fs && fs.existsSync(filename)) {',
148
+ Template.indent([
149
+ `loadChunkStrategy('filesystem', chunkId, ${JSON.stringify(rootOutputDir)}, remotes, installChunkCallback);`,
150
+ ]),
151
+ '} else { ',
152
+ Template.indent([
153
+ `var remotes = ${JSON.stringify(Object.values(remotes).reduce((acc, remote) => {
154
+ const [global, url] = remote.split('@');
155
+ acc[global] = url;
156
+ return acc;
157
+ }, {}))};`,
158
+ `var chunkName = ${RuntimeGlobals.getChunkScriptFilename}(chunkId);`,
159
+ "const loadingStrategy = typeof process !== 'undefined' ? 'http-vm' : 'http-eval';",
160
+ `loadChunkStrategy(loadingStrategy, chunkName,${RuntimeGlobals.require}.federation.initOptions.name, ${RuntimeGlobals.require}.federation.initOptions.remotes, installChunkCallback);`,
161
+ ]),
162
+ '}',
163
+ ]),
164
+ '});',
165
+ 'promises.push(installedChunkData[2] = promise);',
166
+ ]),
167
+ '} else installedChunks[chunkId] = 0;',
168
+ ]),
169
+ '}',
170
+ ]),
171
+ '}',
172
+ ])
173
+ : Template.indent(['installedChunks[chunkId] = 0;']),
174
+ '};',
175
+ ]);
176
+ }
177
+ /**
178
+ * Generates the HMR manifest code.
179
+ * @param {boolean} withHmrManifest - Flag indicating whether HMR manifest is enabled.
180
+ * @param {string} rootOutputDir - The root output directory.
181
+ * @returns {string} - The generated HMR manifest code.
182
+ */
183
+ function generateHmrManifestCode(withHmrManifest, rootOutputDir) {
184
+ if (!withHmrManifest) {
185
+ return '// no HMR manifest';
186
+ }
187
+ return Template.asString([
188
+ `${RuntimeGlobals.hmrDownloadManifest} = function() {`,
189
+ Template.indent([
190
+ 'return new Promise(function(resolve, reject) {',
191
+ Template.indent([
192
+ `var filename = require('path').join(__dirname, ${JSON.stringify(rootOutputDir)} + ${RuntimeGlobals.getUpdateManifestFilename}());`,
193
+ "require('fs').readFile(filename, 'utf-8', function(err, content) {",
194
+ Template.indent([
195
+ 'if(err) {',
196
+ Template.indent([
197
+ 'if(err.code === "ENOENT") return resolve();',
198
+ 'return reject(err);',
199
+ ]),
200
+ '}',
201
+ 'try { resolve(JSON.parse(content)); }',
202
+ 'catch(e) { reject(e); }',
203
+ ]),
204
+ '});',
205
+ ]),
206
+ '});',
207
+ ]),
208
+ '}',
209
+ ]);
210
+ }
211
+ /**
212
+ * Handles the on chunk load event.
213
+ * @param {boolean} withOnChunkLoad - Flag indicating whether on chunk load event is enabled.
214
+ * @param {any} runtimeTemplate - The runtime template.
215
+ * @returns {string} - The generated on chunk load event handler.
216
+ */
217
+ function handleOnChunkLoad(withOnChunkLoad, runtimeTemplate) {
218
+ if (withOnChunkLoad) {
219
+ return `${RuntimeGlobals.onChunksLoaded}.readFileVm = ${runtimeTemplate.returningFunction('installedChunks[chunkId] === 0', 'chunkId')};`;
220
+ }
221
+ else {
222
+ return '// no on chunks loaded';
223
+ }
224
+ }
225
+ /**
226
+ * Generates the load script for server-side execution. This function creates a script that loads a remote module
227
+ * and executes it in the current context. It supports both browser and Node.js environments.
228
+ * @param {any} runtimeTemplate - The runtime template used to generate the load script.
229
+ * @returns {string} - The generated load script.
230
+ */
231
+ function generateLoadScript(runtimeTemplate) {
232
+ return Template.asString([
233
+ '// load script equivalent for server side',
234
+ `${RuntimeGlobals.loadScript} = ${runtimeTemplate.basicFunction('url, callback, chunkId', [
235
+ Template.indent([
236
+ `async function executeLoad(url, callback, name) {
237
+ if (!name) {
238
+ throw new Error('__webpack_require__.l name is required for ' + url);
239
+ }
240
+ const usesInternalRef = name.startsWith('__webpack_require__')
241
+ if (usesInternalRef) {
242
+ const regex = /__webpack_require__\\.federation\\.instance\\.moduleCache\\.get\\(([^)]+)\\)/;
243
+ const match = name.match(regex);
244
+ if (match) {
245
+ name = match[1].replace(/["']/g, '');
246
+ }
247
+ }
248
+ try {
249
+ const federation = ${RuntimeGlobals.require}.federation;
250
+ const res = await ${RuntimeGlobals.require}.federation.runtime.loadScriptNode(url, { attrs: {} });
251
+ const enhancedRemote = federation.instance.initRawContainer(name, url, res);
252
+ // use normal global assignment
253
+ if(!usesInternalRef && !globalThis[name]) {
254
+ globalThis[name] = enhancedRemote
255
+ }
256
+ callback(enhancedRemote);
257
+ } catch (error) {
258
+ callback(error);
259
+ }
260
+
261
+ }`,
262
+ `executeLoad(url, callback, chunkId);`,
263
+ ]),
264
+ ])}`,
265
+ ]);
266
+ }
267
+ function generateInstallChunk(runtimeTemplate, withOnChunkLoad) {
268
+ return `var installChunk = ${runtimeTemplate.basicFunction('chunk', [
269
+ 'var moreModules = chunk.modules, chunkIds = chunk.ids, runtime = chunk.runtime;',
270
+ 'for(var moduleId in moreModules) {',
271
+ Template.indent([
272
+ `if(${RuntimeGlobals.hasOwnProperty}(moreModules, moduleId)) {`,
273
+ Template.indent([
274
+ `${RuntimeGlobals.moduleFactories}[moduleId] = moreModules[moduleId];`,
275
+ ]),
276
+ '}',
277
+ ]),
278
+ '}',
279
+ 'if(runtime) runtime(__webpack_require__);',
280
+ 'for(var i = 0; i < chunkIds.length; i++) {',
281
+ Template.indent([
282
+ 'if(installedChunks[chunkIds[i]]) {',
283
+ Template.indent(['installedChunks[chunkIds[i]][0]();']),
284
+ '}',
285
+ 'installedChunks[chunkIds[i]] = 0;',
286
+ ]),
287
+ '}',
288
+ withOnChunkLoad ? `${RuntimeGlobals.onChunksLoaded}();` : '',
289
+ ])};`;
290
+ }
291
+ function generateExternalInstallChunkCode(withExternalInstallChunk, debug) {
292
+ if (!withExternalInstallChunk) {
293
+ return '// no external install chunk';
294
+ }
295
+ return Template.asString([
296
+ 'module.exports = __webpack_require__;',
297
+ `${RuntimeGlobals.externalInstallChunk} = function(){`,
298
+ debug
299
+ ? `console.debug('node: webpack installing to install chunk id:', arguments['0'].id);`
300
+ : '',
301
+ `return installChunk.apply(this, arguments)};`,
302
+ ]);
303
+ }
304
+ //# sourceMappingURL=webpackChunkUtilities.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webpackChunkUtilities.js","sourceRoot":"","sources":["../../../src/plugins/webpackChunkUtilities.ts"],"names":[],"mappings":";;AAYA,0CAsEC;AAQD,gDAmBC;AAWD,kDAmFC;AAOD,0DAiCC;AAOD,8CAcC;AAOD,gDAsCC;AACD,oDA0BC;AACD,4EAgBC;AAjWD,0FAAqF;AACrF,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,GAAG,OAAO,CAC1C,IAAA,6CAAoB,EAAC,SAAS,CAAC,CACJ,CAAC;AAG9B;;;;;GAKG;AACH,SAAgB,eAAe,CAC7B,OAAgB,EAChB,aAAqB;IAErB,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,WAAW,CAAC;IACrB,CAAC;IAED,OAAO,QAAQ,CAAC,QAAQ,CAAC;QACvB,iCAAiC;QACjC,yDAAyD;QACzD,QAAQ,CAAC,MAAM,CAAC;YACd,gDAAgD;YAChD,QAAQ,CAAC,MAAM,CAAC;gBACd,2CAA2C;gBAC3C,kDAAkD,IAAI,CAAC,SAAS,CAC9D,aAAa,CACd,MAAM,cAAc,CAAC,4BAA4B,aAAa;gBAC/D,8BAA8B;gBAC9B,oEAAoE;gBACpE,QAAQ,CAAC,MAAM,CAAC;oBACd,6BAA6B;oBAC7B,kBAAkB;oBAClB,mDAAmD;oBACnD,sHAAsH;wBACpH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CAAsC;aACvC,CAAC;SACH,CACF,EAAE;KACJ,CAAC,CAAC;AACL,CAAC;AACD,SAAgB,oBAAoB,CAClC,eAAoB,EACpB,eAAwB;IAExB,OAAO,sBAAsB,eAAe,CAAC,aAAa,CAAC,OAAO,EAAE;QAClE,iFAAiF;QACjF,oCAAoC;QACpC,QAAQ,CAAC,MAAM,CAAC;YACd,MAAM,cAAc,CAAC,cAAc,4BAA4B;YAC/D,QAAQ,CAAC,MAAM,CAAC;gBACd,GAAG,cAAc,CAAC,eAAe,qCAAqC;aACvE,CAAC;YACF,GAAG;SACJ,CAAC;QACF,GAAG;QACH,2CAA2C;QAC3C,4CAA4C;QAC5C,QAAQ,CAAC,MAAM,CAAC;YACd,oCAAoC;YACpC,QAAQ,CAAC,MAAM,CAAC,CAAC,oCAAoC,CAAC,CAAC;YACvD,GAAG;YACH,mCAAmC;SACpC,CAAC;QACF,GAAG;QACH,eAAe,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,cAAc,KAAK,CAAC,CAAC,CAAC,EAAE;KAC7D,CAAC,GAAG,CAAC;AACR,CAAC;AACD,SAAgB,gCAAgC,CAC9C,wBAAiC,EACjC,KAA0B;IAE1B,IAAI,CAAC,wBAAwB,EAAE,CAAC;QAC9B,OAAO,8BAA8B,CAAC;IACxC,CAAC;IAED,OAAO,QAAQ,CAAC,QAAQ,CAAC;QACvB,uCAAuC;QACvC,GAAG,cAAc,CAAC,oBAAoB,gBAAgB;QACtD,KAAK;YACH,CAAC,CAAC,oFAAoF;YACtF,CAAC,CAAC,EAAE;QACN,8CAA8C;KAC/C,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { ModuleFederationRuntimePlugin } from '@module-federation/runtime';
2
+ declare const recordDynamicRemoteEntryHashPlugin: () => ModuleFederationRuntimePlugin;
3
+ export default recordDynamicRemoteEntryHashPlugin;
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ const recordDynamicRemoteEntryHashPlugin = () => ({
37
+ name: 'record-dynamic-remote-entry-hash-plugin',
38
+ beforeInit(args) {
39
+ if (!globalThis.mfHashMap) {
40
+ globalThis.mfHashMap = {};
41
+ }
42
+ return args;
43
+ },
44
+ async onLoad(args) {
45
+ const { moduleInstance } = args;
46
+ if (!moduleInstance.remoteInfo) {
47
+ return args;
48
+ }
49
+ const hashmap = globalThis.mfHashMap;
50
+ if (!hashmap) {
51
+ return args;
52
+ }
53
+ const { name, entry } = moduleInstance.remoteInfo;
54
+ if (!hashmap[name]) {
55
+ const hotReloadUtils = await Promise.resolve().then(() => __importStar(require('./utils/hot-reload')));
56
+ const fetcher = hotReloadUtils.createFetcher(entry, hotReloadUtils.getFetchModule(), name, (hash) => {
57
+ hashmap[name] = hash;
58
+ });
59
+ await fetcher;
60
+ }
61
+ return args;
62
+ },
63
+ });
64
+ exports.default = recordDynamicRemoteEntryHashPlugin;
65
+ //# sourceMappingURL=recordDynamicRemoteEntryHashPlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recordDynamicRemoteEntryHashPlugin.js","sourceRoot":"","sources":["../../src/recordDynamicRemoteEntryHashPlugin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,MAAM,kCAAkC,GACtC,GAAG,EAAE,CAAC,CAAC;IACL,IAAI,EAAE,yCAAyC;IAC/C,UAAU,CAAC,IAAI;QACb,IAAI,CAAC,UAAU,CAAC,SAAS,EAAE,CAAC;YAC1B,UAAU,CAAC,SAAS,GAAG,EAAE,CAAC;QAC5B,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IACD,KAAK,CAAC,MAAM,CAAC,IAAI;QACf,MAAM,EAAE,cAAc,EAAE,GAAG,IAAI,CAAC;QAEhC,IAAI,CAAC,cAAc,CAAC,UAAU,EAAE,CAAC;YAC/B,OAAO,IAAI,CAAC;QACd,CAAC;QACD,MAAM,OAAO,GAAG,UAAU,CAAC,SAAS,CAAC;QAErC,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,cAAc,CAAC,UAAU,CAAC;QAElD,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;YACnB,MAAM,cAAc,GAAG,wDAAa,oBAAoB,GAAC,CAAC;YAC1D,MAAM,OAAO,GAAG,cAAc,CAAC,aAAa,CAC1C,KAAK,EACL,cAAc,CAAC,cAAc,EAAE,EAC/B,IAAI,EACJ,CAAC,IAAI,EAAE,EAAE;gBACP,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;YACvB,CAAC,CACF,CAAC;YACF,MAAM,OAAO,CAAC;QAChB,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAC,CAAC;AACL,kBAAe,kCAAkC,CAAC"}
@@ -0,0 +1,22 @@
1
+ import type { ModuleFederationRuntimePlugin } from '@module-federation/runtime';
2
+ export declare const nodeRuntimeImportCache: Map<string, Promise<any>>;
3
+ export declare function importNodeModule<T>(name: string): Promise<T>;
4
+ export declare const resolveFile: (rootOutputDir: string, chunkId: string) => string;
5
+ export declare const returnFromCache: (remoteName: string) => string | null;
6
+ export declare const returnFromGlobalInstances: (remoteName: string) => string | null;
7
+ export declare const loadFromFs: (filename: string, callback: (err: Error | null, chunk: any) => void) => void;
8
+ export declare const fetchAndRun: (url: URL, chunkName: string, callback: (err: Error | null, chunk: any) => void, args: any) => void;
9
+ export declare const resolveUrl: (remoteName: string, chunkName: string) => URL | null;
10
+ export declare const loadChunk: (strategy: string, chunkId: string, rootOutputDir: string, callback: (err: Error | null, chunk: any) => void, args: any) => void;
11
+ export declare const installChunk: (chunk: any, installedChunks: {
12
+ [key: string]: any;
13
+ }) => void;
14
+ export declare const deleteChunk: (chunkId: string, installedChunks: {
15
+ [key: string]: any;
16
+ }) => boolean;
17
+ export declare const setupScriptLoader: () => void;
18
+ export declare const setupChunkHandler: (installedChunks: {
19
+ [key: string]: any;
20
+ }, args: any) => ((chunkId: string, promises: any[]) => void);
21
+ export declare const setupWebpackRequirePatching: (handle: (chunkId: string, promises: any[]) => void) => void;
22
+ export default function (): ModuleFederationRuntimePlugin;