@module-federation/node 0.0.0-chore-bump-node-22-20260710161714
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/LICENSE +21 -0
- package/README.md +235 -0
- package/dist/_virtual/_rolldown/runtime.js +31 -0
- package/dist/_virtual/_rolldown/runtime.mjs +8 -0
- package/dist/plugins/ChunkCorrelationPlugin.js +308 -0
- package/dist/plugins/ChunkCorrelationPlugin.js.map +1 -0
- package/dist/plugins/ChunkCorrelationPlugin.mjs +305 -0
- package/dist/plugins/ChunkCorrelationPlugin.mjs.map +1 -0
- package/dist/src/filesystem/stratagies.d.mts +21 -0
- package/dist/src/filesystem/stratagies.d.ts +21 -0
- package/dist/src/filesystem/stratagies.js +105 -0
- package/dist/src/filesystem/stratagies.js.map +1 -0
- package/dist/src/filesystem/stratagies.mjs +103 -0
- package/dist/src/filesystem/stratagies.mjs.map +1 -0
- package/dist/src/index.d.mts +8 -0
- package/dist/src/index.d.ts +8 -0
- package/dist/src/index.js +16 -0
- package/dist/src/index.mjs +9 -0
- package/dist/src/plugins/AutomaticPublicPathPlugin.d.mts +12 -0
- package/dist/src/plugins/AutomaticPublicPathPlugin.d.ts +11 -0
- package/dist/src/plugins/AutomaticPublicPathPlugin.js +29 -0
- package/dist/src/plugins/AutomaticPublicPathPlugin.js.map +1 -0
- package/dist/src/plugins/AutomaticPublicPathPlugin.mjs +28 -0
- package/dist/src/plugins/AutomaticPublicPathPlugin.mjs.map +1 -0
- package/dist/src/plugins/ChunkCorrelationPlugin.d.mts +5 -0
- package/dist/src/plugins/ChunkCorrelationPlugin.d.ts +4 -0
- package/dist/src/plugins/ChunkCorrelationPlugin.js +9 -0
- package/dist/src/plugins/ChunkCorrelationPlugin.js.map +1 -0
- package/dist/src/plugins/ChunkCorrelationPlugin.mjs +8 -0
- package/dist/src/plugins/ChunkCorrelationPlugin.mjs.map +1 -0
- package/dist/src/plugins/CommonJsChunkLoadingPlugin.d.mts +21 -0
- package/dist/src/plugins/CommonJsChunkLoadingPlugin.d.ts +20 -0
- package/dist/src/plugins/CommonJsChunkLoadingPlugin.js +71 -0
- package/dist/src/plugins/CommonJsChunkLoadingPlugin.js.map +1 -0
- package/dist/src/plugins/CommonJsChunkLoadingPlugin.mjs +70 -0
- package/dist/src/plugins/CommonJsChunkLoadingPlugin.mjs.map +1 -0
- package/dist/src/plugins/DynamicFilesystemChunkLoadingRuntimeModule.d.mts +46 -0
- package/dist/src/plugins/DynamicFilesystemChunkLoadingRuntimeModule.d.ts +45 -0
- package/dist/src/plugins/DynamicFilesystemChunkLoadingRuntimeModule.js +112 -0
- package/dist/src/plugins/DynamicFilesystemChunkLoadingRuntimeModule.js.map +1 -0
- package/dist/src/plugins/DynamicFilesystemChunkLoadingRuntimeModule.mjs +111 -0
- package/dist/src/plugins/DynamicFilesystemChunkLoadingRuntimeModule.mjs.map +1 -0
- package/dist/src/plugins/EntryChunkTrackerPlugin.d.mts +17 -0
- package/dist/src/plugins/EntryChunkTrackerPlugin.d.ts +17 -0
- package/dist/src/plugins/EntryChunkTrackerPlugin.js +39 -0
- package/dist/src/plugins/EntryChunkTrackerPlugin.js.map +1 -0
- package/dist/src/plugins/EntryChunkTrackerPlugin.mjs +38 -0
- package/dist/src/plugins/EntryChunkTrackerPlugin.mjs.map +1 -0
- package/dist/src/plugins/NodeFederationPlugin.d.mts +54 -0
- package/dist/src/plugins/NodeFederationPlugin.d.ts +53 -0
- package/dist/src/plugins/NodeFederationPlugin.js +76 -0
- package/dist/src/plugins/NodeFederationPlugin.js.map +1 -0
- package/dist/src/plugins/NodeFederationPlugin.mjs +73 -0
- package/dist/src/plugins/NodeFederationPlugin.mjs.map +1 -0
- package/dist/src/plugins/RemotePublicPathRuntimeModule.d.mts +15 -0
- package/dist/src/plugins/RemotePublicPathRuntimeModule.d.ts +14 -0
- package/dist/src/plugins/RemotePublicPathRuntimeModule.js +133 -0
- package/dist/src/plugins/RemotePublicPathRuntimeModule.js.map +1 -0
- package/dist/src/plugins/RemotePublicPathRuntimeModule.mjs +132 -0
- package/dist/src/plugins/RemotePublicPathRuntimeModule.mjs.map +1 -0
- package/dist/src/plugins/StreamingTargetPlugin.d.mts +32 -0
- package/dist/src/plugins/StreamingTargetPlugin.d.ts +31 -0
- package/dist/src/plugins/StreamingTargetPlugin.js +46 -0
- package/dist/src/plugins/StreamingTargetPlugin.js.map +1 -0
- package/dist/src/plugins/StreamingTargetPlugin.mjs +46 -0
- package/dist/src/plugins/StreamingTargetPlugin.mjs.map +1 -0
- package/dist/src/plugins/UniversalFederationPlugin.d.mts +49 -0
- package/dist/src/plugins/UniversalFederationPlugin.d.ts +48 -0
- package/dist/src/plugins/UniversalFederationPlugin.js +66 -0
- package/dist/src/plugins/UniversalFederationPlugin.js.map +1 -0
- package/dist/src/plugins/UniversalFederationPlugin.mjs +65 -0
- package/dist/src/plugins/UniversalFederationPlugin.mjs.map +1 -0
- package/dist/src/plugins/UniverseEntryChunkTrackerPlugin.d.mts +9 -0
- package/dist/src/plugins/UniverseEntryChunkTrackerPlugin.d.ts +8 -0
- package/dist/src/plugins/UniverseEntryChunkTrackerPlugin.js +25 -0
- package/dist/src/plugins/UniverseEntryChunkTrackerPlugin.js.map +1 -0
- package/dist/src/plugins/UniverseEntryChunkTrackerPlugin.mjs +23 -0
- package/dist/src/plugins/UniverseEntryChunkTrackerPlugin.mjs.map +1 -0
- package/dist/src/plugins/webpackChunkUtilities.d.mts +55 -0
- package/dist/src/plugins/webpackChunkUtilities.d.ts +55 -0
- package/dist/src/plugins/webpackChunkUtilities.js +242 -0
- package/dist/src/plugins/webpackChunkUtilities.js.map +1 -0
- package/dist/src/plugins/webpackChunkUtilities.mjs +234 -0
- package/dist/src/plugins/webpackChunkUtilities.mjs.map +1 -0
- package/dist/src/recordDynamicRemoteEntryHashPlugin.d.mts +7 -0
- package/dist/src/recordDynamicRemoteEntryHashPlugin.d.ts +6 -0
- package/dist/src/recordDynamicRemoteEntryHashPlugin.js +28 -0
- package/dist/src/recordDynamicRemoteEntryHashPlugin.js.map +1 -0
- package/dist/src/recordDynamicRemoteEntryHashPlugin.mjs +26 -0
- package/dist/src/recordDynamicRemoteEntryHashPlugin.mjs.map +1 -0
- package/dist/src/runtimePlugin.d.mts +27 -0
- package/dist/src/runtimePlugin.d.ts +27 -0
- package/dist/src/runtimePlugin.js +242 -0
- package/dist/src/runtimePlugin.js.map +1 -0
- package/dist/src/runtimePlugin.mjs +226 -0
- package/dist/src/runtimePlugin.mjs.map +1 -0
- package/dist/src/types/index.d.mts +8 -0
- package/dist/src/types/index.d.ts +8 -0
- package/dist/src/types/index.js +1 -0
- package/dist/src/types/index.mjs +1 -0
- package/dist/src/utils/flush-chunks.d.mts +15 -0
- package/dist/src/utils/flush-chunks.d.ts +15 -0
- package/dist/src/utils/flush-chunks.js +106 -0
- package/dist/src/utils/flush-chunks.js.map +1 -0
- package/dist/src/utils/flush-chunks.mjs +102 -0
- package/dist/src/utils/flush-chunks.mjs.map +1 -0
- package/dist/src/utils/hot-reload.d.mts +16 -0
- package/dist/src/utils/hot-reload.d.ts +16 -0
- package/dist/src/utils/hot-reload.js +206 -0
- package/dist/src/utils/hot-reload.js.map +1 -0
- package/dist/src/utils/hot-reload.mjs +195 -0
- package/dist/src/utils/hot-reload.mjs.map +1 -0
- package/dist/src/utils/index.d.mts +3 -0
- package/dist/src/utils/index.d.ts +3 -0
- package/dist/src/utils/index.js +15 -0
- package/dist/src/utils/index.mjs +4 -0
- package/package.json +135 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UniversalFederationPlugin.js","names":["ModuleFederationPlugin","NodeFederationPlugin","StreamingTargetPlugin"],"sources":["../../../src/plugins/UniversalFederationPlugin.ts"],"sourcesContent":["/**\n * Importing necessary plugins and types\n */\nimport StreamingTargetPlugin from './StreamingTargetPlugin';\nimport NodeFederationPlugin from './NodeFederationPlugin';\nimport { ModuleFederationPlugin } from '@module-federation/enhanced/webpack';\nimport { ModuleFederationPluginOptions } from '../types';\nimport type { Compiler, container } from 'webpack';\nimport { getWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\n\n/**\n * Interface for NodeFederationOptions\n * @property {boolean} isServer - Indicates if the server is running\n * @property {string} [promiseBaseURI] - The base URI for the promise\n * @property {boolean} [debug] - Indicates if debug mode is enabled\n */\ninterface NodeFederationOptions extends ModuleFederationPluginOptions {\n isServer: boolean;\n promiseBaseURI?: string;\n debug?: boolean;\n useRuntimePlugin?: boolean;\n}\n\n/**\n * Interface for NodeFederationContext\n * @property {typeof container.ModuleFederationPlugin} [ModuleFederationPlugin] - The ModuleFederationPlugin from webpack container\n */\ninterface NodeFederationContext {\n ModuleFederationPlugin?: typeof container.ModuleFederationPlugin;\n}\n\nconst resolveRuntimePluginPath = (): string =>\n process.env.IS_ESM_BUILD === 'true'\n ? require.resolve('../runtimePlugin.mjs')\n : require.resolve('../runtimePlugin.js');\n\n/**\n * Class representing a UniversalFederationPlugin\n */\nclass UniversalFederationPlugin {\n private _options: NodeFederationOptions;\n private context: NodeFederationContext;\n private name: string;\n\n /**\n * Create a UniversalFederationPlugin\n * @param {NodeFederationOptions} options - The options for the plugin\n * @param {NodeFederationContext} context - The context for the plugin\n */\n constructor(options: NodeFederationOptions, context: NodeFederationContext) {\n this._options = options || ({} as NodeFederationOptions);\n this.context = context || ({} as NodeFederationContext);\n this.name = 'ModuleFederationPlugin';\n if (this._options.useRuntimePlugin && this._options.isServer) {\n const runtimePluginPath = resolveRuntimePluginPath();\n this._options.runtimePlugins = this._options.runtimePlugins\n ? this._options.runtimePlugins.concat([runtimePluginPath])\n : [runtimePluginPath];\n }\n }\n\n private updateCompilerOptions(compiler: Compiler): void {\n compiler.options.output.chunkFormat = 'commonjs';\n if (compiler.options.output.enabledLibraryTypes === undefined) {\n compiler.options.output.enabledLibraryTypes = ['commonjs-module'];\n } else {\n compiler.options.output.enabledLibraryTypes.push('commonjs-module');\n }\n\n const chunkFileName = compiler.options?.output?.chunkFilename;\n const uniqueName =\n compiler?.options?.output?.uniqueName || this._options.name;\n if (\n typeof chunkFileName === 'string' &&\n uniqueName &&\n !chunkFileName.includes(uniqueName)\n ) {\n const suffix = `-[contenthash].js`;\n compiler.options.output.chunkFilename = chunkFileName.replace(\n '.js',\n suffix,\n );\n }\n }\n\n /**\n * Apply the plugin to the compiler\n * @param {Compiler} compiler - The webpack compiler\n */\n apply(compiler: Compiler) {\n const { isServer, debug, useRuntimePlugin, ...options } = this._options;\n const { webpack } = compiler;\n if (!process.env['FEDERATION_WEBPACK_PATH']) {\n process.env['FEDERATION_WEBPACK_PATH'] = getWebpackPath(compiler);\n }\n if (\n isServer ||\n compiler.options.name === 'server' ||\n compiler.options.target === 'node' ||\n compiler.options.target === 'async-node'\n ) {\n if (useRuntimePlugin) {\n this.updateCompilerOptions(compiler);\n new ModuleFederationPlugin({\n ...options,\n }).apply(compiler);\n } else {\n new NodeFederationPlugin(options, this.context).apply(compiler);\n new StreamingTargetPlugin({ ...options, debug }).apply(compiler);\n }\n } else {\n new ModuleFederationPlugin(options).apply(compiler);\n }\n }\n}\n\n/**\n * Exporting UniversalFederationPlugin as default\n */\nexport default UniversalFederationPlugin;\n"],"mappings":";;;;;;;;;;;AA+BA,MAAM,iCAGA,QAAQ,QAAQ,sBAAsB;;;;AAK5C,IAAM,4BAAN,MAAgC;;;;;;CAU9B,YAAY,SAAgC,SAAgC;AAC1E,OAAK,WAAW,WAAY,EAAE;AAC9B,OAAK,UAAU,WAAY,EAAE;AAC7B,OAAK,OAAO;AACZ,MAAI,KAAK,SAAS,oBAAoB,KAAK,SAAS,UAAU;GAC5D,MAAM,oBAAoB,0BAA0B;AACpD,QAAK,SAAS,iBAAiB,KAAK,SAAS,iBACzC,KAAK,SAAS,eAAe,OAAO,CAAC,kBAAkB,CAAC,GACxD,CAAC,kBAAkB;;;CAI3B,AAAQ,sBAAsB,UAA0B;AACtD,WAAS,QAAQ,OAAO,cAAc;AACtC,MAAI,SAAS,QAAQ,OAAO,wBAAwB,OAClD,UAAS,QAAQ,OAAO,sBAAsB,CAAC,kBAAkB;MAEjE,UAAS,QAAQ,OAAO,oBAAoB,KAAK,kBAAkB;EAGrE,MAAM,gBAAgB,SAAS,SAAS,QAAQ;EAChD,MAAM,aACJ,UAAU,SAAS,QAAQ,cAAc,KAAK,SAAS;AACzD,MACE,OAAO,kBAAkB,YACzB,cACA,CAAC,cAAc,SAAS,WAAW,EACnC;GACA,MAAM,SAAS;AACf,YAAS,QAAQ,OAAO,gBAAgB,cAAc,QACpD,OACA,OACD;;;;;;;CAQL,MAAM,UAAoB;EACxB,MAAM,EAAE,UAAU,OAAO,kBAAkB,GAAG,YAAY,KAAK;EAC/D,MAAM,EAAE,YAAY;AACpB,MAAI,CAAC,QAAQ,IAAI,2BACf,SAAQ,IAAI,+FAA4C,SAAS;AAEnE,MACE,YACA,SAAS,QAAQ,SAAS,YAC1B,SAAS,QAAQ,WAAW,UAC5B,SAAS,QAAQ,WAAW,aAE5B,KAAI,kBAAkB;AACpB,QAAK,sBAAsB,SAAS;AACpC,OAAIA,2DAAuB,EACzB,GAAG,SACJ,CAAC,CAAC,MAAM,SAAS;SACb;AACL,OAAIC,iDAAqB,SAAS,KAAK,QAAQ,CAAC,MAAM,SAAS;AAC/D,OAAIC,kDAAsB;IAAE,GAAG;IAAS;IAAO,CAAC,CAAC,MAAM,SAAS;;MAGlE,KAAIF,2DAAuB,QAAQ,CAAC,MAAM,SAAS"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { __require } from "../../_virtual/_rolldown/runtime.mjs";
|
|
2
|
+
import StreamingTargetPlugin from "./StreamingTargetPlugin.mjs";
|
|
3
|
+
import NodeFederationPlugin from "./NodeFederationPlugin.mjs";
|
|
4
|
+
import { getWebpackPath } from "@module-federation/sdk/normalize-webpack-path";
|
|
5
|
+
import { ModuleFederationPlugin } from "@module-federation/enhanced/webpack";
|
|
6
|
+
|
|
7
|
+
//#region src/plugins/UniversalFederationPlugin.ts
|
|
8
|
+
/**
|
|
9
|
+
* Importing necessary plugins and types
|
|
10
|
+
*/
|
|
11
|
+
const resolveRuntimePluginPath = () => __require.resolve("../runtimePlugin.mjs");
|
|
12
|
+
/**
|
|
13
|
+
* Class representing a UniversalFederationPlugin
|
|
14
|
+
*/
|
|
15
|
+
var UniversalFederationPlugin = class {
|
|
16
|
+
/**
|
|
17
|
+
* Create a UniversalFederationPlugin
|
|
18
|
+
* @param {NodeFederationOptions} options - The options for the plugin
|
|
19
|
+
* @param {NodeFederationContext} context - The context for the plugin
|
|
20
|
+
*/
|
|
21
|
+
constructor(options, context) {
|
|
22
|
+
this._options = options || {};
|
|
23
|
+
this.context = context || {};
|
|
24
|
+
this.name = "ModuleFederationPlugin";
|
|
25
|
+
if (this._options.useRuntimePlugin && this._options.isServer) {
|
|
26
|
+
const runtimePluginPath = resolveRuntimePluginPath();
|
|
27
|
+
this._options.runtimePlugins = this._options.runtimePlugins ? this._options.runtimePlugins.concat([runtimePluginPath]) : [runtimePluginPath];
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
updateCompilerOptions(compiler) {
|
|
31
|
+
compiler.options.output.chunkFormat = "commonjs";
|
|
32
|
+
if (compiler.options.output.enabledLibraryTypes === void 0) compiler.options.output.enabledLibraryTypes = ["commonjs-module"];
|
|
33
|
+
else compiler.options.output.enabledLibraryTypes.push("commonjs-module");
|
|
34
|
+
const chunkFileName = compiler.options?.output?.chunkFilename;
|
|
35
|
+
const uniqueName = compiler?.options?.output?.uniqueName || this._options.name;
|
|
36
|
+
if (typeof chunkFileName === "string" && uniqueName && !chunkFileName.includes(uniqueName)) {
|
|
37
|
+
const suffix = `-[contenthash].js`;
|
|
38
|
+
compiler.options.output.chunkFilename = chunkFileName.replace(".js", suffix);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Apply the plugin to the compiler
|
|
43
|
+
* @param {Compiler} compiler - The webpack compiler
|
|
44
|
+
*/
|
|
45
|
+
apply(compiler) {
|
|
46
|
+
const { isServer, debug, useRuntimePlugin, ...options } = this._options;
|
|
47
|
+
const { webpack } = compiler;
|
|
48
|
+
if (!process.env["FEDERATION_WEBPACK_PATH"]) process.env["FEDERATION_WEBPACK_PATH"] = getWebpackPath(compiler);
|
|
49
|
+
if (isServer || compiler.options.name === "server" || compiler.options.target === "node" || compiler.options.target === "async-node") if (useRuntimePlugin) {
|
|
50
|
+
this.updateCompilerOptions(compiler);
|
|
51
|
+
new ModuleFederationPlugin({ ...options }).apply(compiler);
|
|
52
|
+
} else {
|
|
53
|
+
new NodeFederationPlugin(options, this.context).apply(compiler);
|
|
54
|
+
new StreamingTargetPlugin({
|
|
55
|
+
...options,
|
|
56
|
+
debug
|
|
57
|
+
}).apply(compiler);
|
|
58
|
+
}
|
|
59
|
+
else new ModuleFederationPlugin(options).apply(compiler);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
//#endregion
|
|
64
|
+
export { UniversalFederationPlugin as default };
|
|
65
|
+
//# sourceMappingURL=UniversalFederationPlugin.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UniversalFederationPlugin.mjs","names":[],"sources":["../../../src/plugins/UniversalFederationPlugin.ts"],"sourcesContent":["/**\n * Importing necessary plugins and types\n */\nimport StreamingTargetPlugin from './StreamingTargetPlugin';\nimport NodeFederationPlugin from './NodeFederationPlugin';\nimport { ModuleFederationPlugin } from '@module-federation/enhanced/webpack';\nimport { ModuleFederationPluginOptions } from '../types';\nimport type { Compiler, container } from 'webpack';\nimport { getWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\n\n/**\n * Interface for NodeFederationOptions\n * @property {boolean} isServer - Indicates if the server is running\n * @property {string} [promiseBaseURI] - The base URI for the promise\n * @property {boolean} [debug] - Indicates if debug mode is enabled\n */\ninterface NodeFederationOptions extends ModuleFederationPluginOptions {\n isServer: boolean;\n promiseBaseURI?: string;\n debug?: boolean;\n useRuntimePlugin?: boolean;\n}\n\n/**\n * Interface for NodeFederationContext\n * @property {typeof container.ModuleFederationPlugin} [ModuleFederationPlugin] - The ModuleFederationPlugin from webpack container\n */\ninterface NodeFederationContext {\n ModuleFederationPlugin?: typeof container.ModuleFederationPlugin;\n}\n\nconst resolveRuntimePluginPath = (): string =>\n process.env.IS_ESM_BUILD === 'true'\n ? require.resolve('../runtimePlugin.mjs')\n : require.resolve('../runtimePlugin.js');\n\n/**\n * Class representing a UniversalFederationPlugin\n */\nclass UniversalFederationPlugin {\n private _options: NodeFederationOptions;\n private context: NodeFederationContext;\n private name: string;\n\n /**\n * Create a UniversalFederationPlugin\n * @param {NodeFederationOptions} options - The options for the plugin\n * @param {NodeFederationContext} context - The context for the plugin\n */\n constructor(options: NodeFederationOptions, context: NodeFederationContext) {\n this._options = options || ({} as NodeFederationOptions);\n this.context = context || ({} as NodeFederationContext);\n this.name = 'ModuleFederationPlugin';\n if (this._options.useRuntimePlugin && this._options.isServer) {\n const runtimePluginPath = resolveRuntimePluginPath();\n this._options.runtimePlugins = this._options.runtimePlugins\n ? this._options.runtimePlugins.concat([runtimePluginPath])\n : [runtimePluginPath];\n }\n }\n\n private updateCompilerOptions(compiler: Compiler): void {\n compiler.options.output.chunkFormat = 'commonjs';\n if (compiler.options.output.enabledLibraryTypes === undefined) {\n compiler.options.output.enabledLibraryTypes = ['commonjs-module'];\n } else {\n compiler.options.output.enabledLibraryTypes.push('commonjs-module');\n }\n\n const chunkFileName = compiler.options?.output?.chunkFilename;\n const uniqueName =\n compiler?.options?.output?.uniqueName || this._options.name;\n if (\n typeof chunkFileName === 'string' &&\n uniqueName &&\n !chunkFileName.includes(uniqueName)\n ) {\n const suffix = `-[contenthash].js`;\n compiler.options.output.chunkFilename = chunkFileName.replace(\n '.js',\n suffix,\n );\n }\n }\n\n /**\n * Apply the plugin to the compiler\n * @param {Compiler} compiler - The webpack compiler\n */\n apply(compiler: Compiler) {\n const { isServer, debug, useRuntimePlugin, ...options } = this._options;\n const { webpack } = compiler;\n if (!process.env['FEDERATION_WEBPACK_PATH']) {\n process.env['FEDERATION_WEBPACK_PATH'] = getWebpackPath(compiler);\n }\n if (\n isServer ||\n compiler.options.name === 'server' ||\n compiler.options.target === 'node' ||\n compiler.options.target === 'async-node'\n ) {\n if (useRuntimePlugin) {\n this.updateCompilerOptions(compiler);\n new ModuleFederationPlugin({\n ...options,\n }).apply(compiler);\n } else {\n new NodeFederationPlugin(options, this.context).apply(compiler);\n new StreamingTargetPlugin({ ...options, debug }).apply(compiler);\n }\n } else {\n new ModuleFederationPlugin(options).apply(compiler);\n }\n }\n}\n\n/**\n * Exporting UniversalFederationPlugin as default\n */\nexport default UniversalFederationPlugin;\n"],"mappings":";;;;;;;;;;AA+BA,MAAM,2CAEQ,QAAQ,uBAAuB;;;;AAM7C,IAAM,4BAAN,MAAgC;;;;;;CAU9B,YAAY,SAAgC,SAAgC;AAC1E,OAAK,WAAW,WAAY,EAAE;AAC9B,OAAK,UAAU,WAAY,EAAE;AAC7B,OAAK,OAAO;AACZ,MAAI,KAAK,SAAS,oBAAoB,KAAK,SAAS,UAAU;GAC5D,MAAM,oBAAoB,0BAA0B;AACpD,QAAK,SAAS,iBAAiB,KAAK,SAAS,iBACzC,KAAK,SAAS,eAAe,OAAO,CAAC,kBAAkB,CAAC,GACxD,CAAC,kBAAkB;;;CAI3B,AAAQ,sBAAsB,UAA0B;AACtD,WAAS,QAAQ,OAAO,cAAc;AACtC,MAAI,SAAS,QAAQ,OAAO,wBAAwB,OAClD,UAAS,QAAQ,OAAO,sBAAsB,CAAC,kBAAkB;MAEjE,UAAS,QAAQ,OAAO,oBAAoB,KAAK,kBAAkB;EAGrE,MAAM,gBAAgB,SAAS,SAAS,QAAQ;EAChD,MAAM,aACJ,UAAU,SAAS,QAAQ,cAAc,KAAK,SAAS;AACzD,MACE,OAAO,kBAAkB,YACzB,cACA,CAAC,cAAc,SAAS,WAAW,EACnC;GACA,MAAM,SAAS;AACf,YAAS,QAAQ,OAAO,gBAAgB,cAAc,QACpD,OACA,OACD;;;;;;;CAQL,MAAM,UAAoB;EACxB,MAAM,EAAE,UAAU,OAAO,kBAAkB,GAAG,YAAY,KAAK;EAC/D,MAAM,EAAE,YAAY;AACpB,MAAI,CAAC,QAAQ,IAAI,2BACf,SAAQ,IAAI,6BAA6B,eAAe,SAAS;AAEnE,MACE,YACA,SAAS,QAAQ,SAAS,YAC1B,SAAS,QAAQ,WAAW,UAC5B,SAAS,QAAQ,WAAW,aAE5B,KAAI,kBAAkB;AACpB,QAAK,sBAAsB,SAAS;AACpC,OAAI,uBAAuB,EACzB,GAAG,SACJ,CAAC,CAAC,MAAM,SAAS;SACb;AACL,OAAI,qBAAqB,SAAS,KAAK,QAAQ,CAAC,MAAM,SAAS;AAC/D,OAAI,sBAAsB;IAAE,GAAG;IAAS;IAAO,CAAC,CAAC,MAAM,SAAS;;MAGlE,KAAI,uBAAuB,QAAQ,CAAC,MAAM,SAAS"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Compiler, WebpackPluginInstance } from "webpack";
|
|
2
|
+
|
|
3
|
+
//#region src/plugins/UniverseEntryChunkTrackerPlugin.d.ts
|
|
4
|
+
declare class UniverseEntryChunkTrackerPlugin implements WebpackPluginInstance {
|
|
5
|
+
apply(compiler: Compiler): void;
|
|
6
|
+
}
|
|
7
|
+
//#endregion
|
|
8
|
+
export { UniverseEntryChunkTrackerPlugin as default };
|
|
9
|
+
//# sourceMappingURL=UniverseEntryChunkTrackerPlugin.d.mts.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Compiler, WebpackPluginInstance } from "webpack";
|
|
2
|
+
|
|
3
|
+
//#region src/plugins/UniverseEntryChunkTrackerPlugin.d.ts
|
|
4
|
+
declare class UniverseEntryChunkTrackerPlugin implements WebpackPluginInstance {
|
|
5
|
+
apply(compiler: Compiler): void;
|
|
6
|
+
}
|
|
7
|
+
export = UniverseEntryChunkTrackerPlugin;
|
|
8
|
+
//# sourceMappingURL=UniverseEntryChunkTrackerPlugin.d.ts.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
2
|
+
|
|
3
|
+
//#region src/plugins/UniverseEntryChunkTrackerPlugin.ts
|
|
4
|
+
var UniverseEntryChunkTrackerPlugin = class {
|
|
5
|
+
apply(compiler) {
|
|
6
|
+
const dataUrl = `data:text/javascript;base64,${Buffer.from(`
|
|
7
|
+
if(typeof module !== 'undefined') {
|
|
8
|
+
globalThis.entryChunkCache = globalThis.entryChunkCache || new Set();
|
|
9
|
+
module.filename && globalThis.entryChunkCache.add(module.filename);
|
|
10
|
+
if(module.children) {
|
|
11
|
+
module.children.forEach(function(c) {
|
|
12
|
+
c.filename && globalThis.entryChunkCache.add(c.filename);
|
|
13
|
+
})
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
`, "utf8").toString("base64")}`;
|
|
17
|
+
compiler.hooks.afterPlugins.tap("UniverseEntryChunkTrackerPlugin", () => {
|
|
18
|
+
new compiler.webpack.EntryPlugin(compiler.context, dataUrl, {}).apply(compiler);
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
exports.default = UniverseEntryChunkTrackerPlugin;
|
|
25
|
+
//# sourceMappingURL=UniverseEntryChunkTrackerPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UniverseEntryChunkTrackerPlugin.js","names":[],"sources":["../../../src/plugins/UniverseEntryChunkTrackerPlugin.ts"],"sourcesContent":["import type { WebpackPluginInstance, Compiler } from 'webpack';\n\nclass UniverseEntryChunkTrackerPlugin implements WebpackPluginInstance {\n apply(compiler: Compiler) {\n const code = `\n if(typeof module !== 'undefined') {\n globalThis.entryChunkCache = globalThis.entryChunkCache || new Set();\n module.filename && globalThis.entryChunkCache.add(module.filename);\n if(module.children) {\n module.children.forEach(function(c) {\n c.filename && globalThis.entryChunkCache.add(c.filename);\n })\n}\n }\n `;\n const base64Code = Buffer.from(code, 'utf8').toString('base64');\n const dataUrl = `data:text/javascript;base64,${base64Code}`;\n\n compiler.hooks.afterPlugins.tap('UniverseEntryChunkTrackerPlugin', () => {\n new compiler.webpack.EntryPlugin(compiler.context, dataUrl, {}).apply(\n compiler,\n );\n });\n }\n}\n\nexport default UniverseEntryChunkTrackerPlugin;\n"],"mappings":";;;AAEA,IAAM,kCAAN,MAAuE;CACrE,MAAM,UAAoB;EAaxB,MAAM,UAAU,+BADG,OAAO,KAXb;;;;;;;;;;OAWwB,OAAO,CAAC,SAAS,SAAS;AAG/D,WAAS,MAAM,aAAa,IAAI,yCAAyC;AACvE,OAAI,SAAS,QAAQ,YAAY,SAAS,SAAS,SAAS,EAAE,CAAC,CAAC,MAC9D,SACD;IACD"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
//#region src/plugins/UniverseEntryChunkTrackerPlugin.ts
|
|
2
|
+
var UniverseEntryChunkTrackerPlugin = class {
|
|
3
|
+
apply(compiler) {
|
|
4
|
+
const dataUrl = `data:text/javascript;base64,${Buffer.from(`
|
|
5
|
+
if(typeof module !== 'undefined') {
|
|
6
|
+
globalThis.entryChunkCache = globalThis.entryChunkCache || new Set();
|
|
7
|
+
module.filename && globalThis.entryChunkCache.add(module.filename);
|
|
8
|
+
if(module.children) {
|
|
9
|
+
module.children.forEach(function(c) {
|
|
10
|
+
c.filename && globalThis.entryChunkCache.add(c.filename);
|
|
11
|
+
})
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
`, "utf8").toString("base64")}`;
|
|
15
|
+
compiler.hooks.afterPlugins.tap("UniverseEntryChunkTrackerPlugin", () => {
|
|
16
|
+
new compiler.webpack.EntryPlugin(compiler.context, dataUrl, {}).apply(compiler);
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
export { UniverseEntryChunkTrackerPlugin as default };
|
|
23
|
+
//# sourceMappingURL=UniverseEntryChunkTrackerPlugin.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UniverseEntryChunkTrackerPlugin.mjs","names":[],"sources":["../../../src/plugins/UniverseEntryChunkTrackerPlugin.ts"],"sourcesContent":["import type { WebpackPluginInstance, Compiler } from 'webpack';\n\nclass UniverseEntryChunkTrackerPlugin implements WebpackPluginInstance {\n apply(compiler: Compiler) {\n const code = `\n if(typeof module !== 'undefined') {\n globalThis.entryChunkCache = globalThis.entryChunkCache || new Set();\n module.filename && globalThis.entryChunkCache.add(module.filename);\n if(module.children) {\n module.children.forEach(function(c) {\n c.filename && globalThis.entryChunkCache.add(c.filename);\n })\n}\n }\n `;\n const base64Code = Buffer.from(code, 'utf8').toString('base64');\n const dataUrl = `data:text/javascript;base64,${base64Code}`;\n\n compiler.hooks.afterPlugins.tap('UniverseEntryChunkTrackerPlugin', () => {\n new compiler.webpack.EntryPlugin(compiler.context, dataUrl, {}).apply(\n compiler,\n );\n });\n }\n}\n\nexport default UniverseEntryChunkTrackerPlugin;\n"],"mappings":";AAEA,IAAM,kCAAN,MAAuE;CACrE,MAAM,UAAoB;EAaxB,MAAM,UAAU,+BADG,OAAO,KAXb;;;;;;;;;;OAWwB,OAAO,CAAC,SAAS,SAAS;AAG/D,WAAS,MAAM,aAAa,IAAI,yCAAyC;AACvE,OAAI,SAAS,QAAQ,YAAY,SAAS,SAAS,SAAS,EAAE,CAAC,CAAC,MAC9D,SACD;IACD"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Chunk, ChunkGraph } from "webpack";
|
|
2
|
+
|
|
3
|
+
//#region src/plugins/webpackChunkUtilities.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Generates the hot module replacement (HMR) code.
|
|
6
|
+
* @param {boolean} withHmr - Flag indicating whether HMR is enabled.
|
|
7
|
+
* @param {string} rootOutputDir - The root output directory.
|
|
8
|
+
* @returns {string} - The generated HMR code.
|
|
9
|
+
*/
|
|
10
|
+
declare function generateHmrCode(withHmr: boolean, rootOutputDir: string): string;
|
|
11
|
+
/**
|
|
12
|
+
* Retrieves the initial chunk IDs.
|
|
13
|
+
* @param {Chunk} chunk - The chunk object.
|
|
14
|
+
* @param {ChunkGraph} chunkGraph - The chunk graph object.
|
|
15
|
+
* @param {any} chunkHasJs - Function to check if a chunk has JavaScript.
|
|
16
|
+
* @returns {Set} - The set of initial chunk IDs.
|
|
17
|
+
*/
|
|
18
|
+
declare function getInitialChunkIds(chunk: Chunk, chunkGraph: ChunkGraph, chunkHasJs: any): Set<Chunk.ChunkId>;
|
|
19
|
+
/**
|
|
20
|
+
* Generates the loading code for chunks.
|
|
21
|
+
* @param {boolean} withLoading - Flag indicating whether chunk loading is enabled.
|
|
22
|
+
* @param {string} fn - The function name.
|
|
23
|
+
* @param {any} hasJsMatcher - Function to check if a chunk has JavaScript.
|
|
24
|
+
* @param {string} rootOutputDir - The root output directory.
|
|
25
|
+
* @param {Record<string, string>} remotes - The remotes object.
|
|
26
|
+
* @param {string | undefined} name - The name of the chunk.
|
|
27
|
+
* @returns {string} - The generated loading code.
|
|
28
|
+
*/
|
|
29
|
+
declare function generateLoadingCode(withLoading: boolean, fn: string, hasJsMatcher: any, rootOutputDir: string, remotes: Record<string, string>, name: string | undefined): string;
|
|
30
|
+
/**
|
|
31
|
+
* Generates the HMR manifest code.
|
|
32
|
+
* @param {boolean} withHmrManifest - Flag indicating whether HMR manifest is enabled.
|
|
33
|
+
* @param {string} rootOutputDir - The root output directory.
|
|
34
|
+
* @returns {string} - The generated HMR manifest code.
|
|
35
|
+
*/
|
|
36
|
+
declare function generateHmrManifestCode(withHmrManifest: boolean, rootOutputDir: string): string;
|
|
37
|
+
/**
|
|
38
|
+
* Handles the on chunk load event.
|
|
39
|
+
* @param {boolean} withOnChunkLoad - Flag indicating whether on chunk load event is enabled.
|
|
40
|
+
* @param {any} runtimeTemplate - The runtime template.
|
|
41
|
+
* @returns {string} - The generated on chunk load event handler.
|
|
42
|
+
*/
|
|
43
|
+
declare function handleOnChunkLoad(withOnChunkLoad: boolean, runtimeTemplate: any): string;
|
|
44
|
+
/**
|
|
45
|
+
* Generates the load script for server-side execution. This function creates a script that loads a remote module
|
|
46
|
+
* and executes it in the current context. It supports both browser and Node.js environments.
|
|
47
|
+
* @param {any} runtimeTemplate - The runtime template used to generate the load script.
|
|
48
|
+
* @returns {string} - The generated load script.
|
|
49
|
+
*/
|
|
50
|
+
declare function generateLoadScript(runtimeTemplate: any): string;
|
|
51
|
+
declare function generateInstallChunk(runtimeTemplate: any, withOnChunkLoad: boolean): string;
|
|
52
|
+
declare function generateExternalInstallChunkCode(withExternalInstallChunk: boolean, debug: boolean | undefined): string;
|
|
53
|
+
//#endregion
|
|
54
|
+
export { generateExternalInstallChunkCode, generateHmrCode, generateHmrManifestCode, generateInstallChunk, generateLoadScript, generateLoadingCode, getInitialChunkIds, handleOnChunkLoad };
|
|
55
|
+
//# sourceMappingURL=webpackChunkUtilities.d.mts.map
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Chunk, ChunkGraph } from "webpack";
|
|
2
|
+
|
|
3
|
+
//#region src/plugins/webpackChunkUtilities.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Generates the hot module replacement (HMR) code.
|
|
6
|
+
* @param {boolean} withHmr - Flag indicating whether HMR is enabled.
|
|
7
|
+
* @param {string} rootOutputDir - The root output directory.
|
|
8
|
+
* @returns {string} - The generated HMR code.
|
|
9
|
+
*/
|
|
10
|
+
declare function generateHmrCode(withHmr: boolean, rootOutputDir: string): string;
|
|
11
|
+
/**
|
|
12
|
+
* Retrieves the initial chunk IDs.
|
|
13
|
+
* @param {Chunk} chunk - The chunk object.
|
|
14
|
+
* @param {ChunkGraph} chunkGraph - The chunk graph object.
|
|
15
|
+
* @param {any} chunkHasJs - Function to check if a chunk has JavaScript.
|
|
16
|
+
* @returns {Set} - The set of initial chunk IDs.
|
|
17
|
+
*/
|
|
18
|
+
declare function getInitialChunkIds(chunk: Chunk, chunkGraph: ChunkGraph, chunkHasJs: any): Set<Chunk.ChunkId>;
|
|
19
|
+
/**
|
|
20
|
+
* Generates the loading code for chunks.
|
|
21
|
+
* @param {boolean} withLoading - Flag indicating whether chunk loading is enabled.
|
|
22
|
+
* @param {string} fn - The function name.
|
|
23
|
+
* @param {any} hasJsMatcher - Function to check if a chunk has JavaScript.
|
|
24
|
+
* @param {string} rootOutputDir - The root output directory.
|
|
25
|
+
* @param {Record<string, string>} remotes - The remotes object.
|
|
26
|
+
* @param {string | undefined} name - The name of the chunk.
|
|
27
|
+
* @returns {string} - The generated loading code.
|
|
28
|
+
*/
|
|
29
|
+
declare function generateLoadingCode(withLoading: boolean, fn: string, hasJsMatcher: any, rootOutputDir: string, remotes: Record<string, string>, name: string | undefined): string;
|
|
30
|
+
/**
|
|
31
|
+
* Generates the HMR manifest code.
|
|
32
|
+
* @param {boolean} withHmrManifest - Flag indicating whether HMR manifest is enabled.
|
|
33
|
+
* @param {string} rootOutputDir - The root output directory.
|
|
34
|
+
* @returns {string} - The generated HMR manifest code.
|
|
35
|
+
*/
|
|
36
|
+
declare function generateHmrManifestCode(withHmrManifest: boolean, rootOutputDir: string): string;
|
|
37
|
+
/**
|
|
38
|
+
* Handles the on chunk load event.
|
|
39
|
+
* @param {boolean} withOnChunkLoad - Flag indicating whether on chunk load event is enabled.
|
|
40
|
+
* @param {any} runtimeTemplate - The runtime template.
|
|
41
|
+
* @returns {string} - The generated on chunk load event handler.
|
|
42
|
+
*/
|
|
43
|
+
declare function handleOnChunkLoad(withOnChunkLoad: boolean, runtimeTemplate: any): string;
|
|
44
|
+
/**
|
|
45
|
+
* Generates the load script for server-side execution. This function creates a script that loads a remote module
|
|
46
|
+
* and executes it in the current context. It supports both browser and Node.js environments.
|
|
47
|
+
* @param {any} runtimeTemplate - The runtime template used to generate the load script.
|
|
48
|
+
* @returns {string} - The generated load script.
|
|
49
|
+
*/
|
|
50
|
+
declare function generateLoadScript(runtimeTemplate: any): string;
|
|
51
|
+
declare function generateInstallChunk(runtimeTemplate: any, withOnChunkLoad: boolean): string;
|
|
52
|
+
declare function generateExternalInstallChunkCode(withExternalInstallChunk: boolean, debug: boolean | undefined): string;
|
|
53
|
+
//#endregion
|
|
54
|
+
export { generateExternalInstallChunkCode, generateHmrCode, generateHmrManifestCode, generateInstallChunk, generateLoadScript, generateLoadingCode, getInitialChunkIds, handleOnChunkLoad };
|
|
55
|
+
//# sourceMappingURL=webpackChunkUtilities.d.ts.map
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('../../_virtual/_rolldown/runtime.js');
|
|
3
|
+
let _module_federation_sdk_normalize_webpack_path = require("@module-federation/sdk/normalize-webpack-path");
|
|
4
|
+
|
|
5
|
+
//#region src/plugins/webpackChunkUtilities.ts
|
|
6
|
+
const { RuntimeGlobals, Template } = require((0, _module_federation_sdk_normalize_webpack_path.normalizeWebpackPath)("webpack"));
|
|
7
|
+
/**
|
|
8
|
+
* Generates the hot module replacement (HMR) code.
|
|
9
|
+
* @param {boolean} withHmr - Flag indicating whether HMR is enabled.
|
|
10
|
+
* @param {string} rootOutputDir - The root output directory.
|
|
11
|
+
* @returns {string} - The generated HMR code.
|
|
12
|
+
*/
|
|
13
|
+
function generateHmrCode(withHmr, rootOutputDir) {
|
|
14
|
+
if (!withHmr) return "// no HMR";
|
|
15
|
+
return Template.asString([
|
|
16
|
+
"function loadUpdateChunk(chunkId, updatedModulesList) {",
|
|
17
|
+
Template.indent([
|
|
18
|
+
"return new Promise(function(resolve, reject) {",
|
|
19
|
+
Template.indent([
|
|
20
|
+
`var filename = require('path').join(__dirname, ${JSON.stringify(rootOutputDir)} + ${RuntimeGlobals.getChunkUpdateScriptFilename}(chunkId));`,
|
|
21
|
+
"require('fs').readFile(filename, 'utf-8', function(err, content) {",
|
|
22
|
+
Template.indent([
|
|
23
|
+
"if(err) return reject(err);",
|
|
24
|
+
"var update = {};",
|
|
25
|
+
"require('vm').runInThisContext('(function(exports, require, __dirname, __filename) {' + content + '\\n})', filename)(update, require, require('path').dirname(filename), filename);",
|
|
26
|
+
"var updatedModules = update.modules;",
|
|
27
|
+
"var runtime = update.runtime;",
|
|
28
|
+
"for(var moduleId in updatedModules) {",
|
|
29
|
+
Template.indent([
|
|
30
|
+
`if(${RuntimeGlobals.hasOwnProperty}(updatedModules, moduleId)) {`,
|
|
31
|
+
Template.indent([`currentUpdate[moduleId] = updatedModules[moduleId];`, "if(updatedModulesList) updatedModulesList.push(moduleId);"]),
|
|
32
|
+
"}"
|
|
33
|
+
]),
|
|
34
|
+
"}",
|
|
35
|
+
"if(runtime) currentUpdateRuntime.push(runtime);",
|
|
36
|
+
"resolve();"
|
|
37
|
+
]),
|
|
38
|
+
"});"
|
|
39
|
+
]),
|
|
40
|
+
"});"
|
|
41
|
+
]),
|
|
42
|
+
"}",
|
|
43
|
+
"",
|
|
44
|
+
Template.getFunctionContent(require("webpack/lib/hmr/JavascriptHotModuleReplacement.runtime.js")).replace(/\$key\$/g, "readFileVm").replace(/\$installedChunks\$/g, "installedChunks").replace(/\$loadUpdateChunk\$/g, "loadUpdateChunk").replace(/\$moduleCache\$/g, RuntimeGlobals.moduleCache).replace(/\$moduleFactories\$/g, RuntimeGlobals.moduleFactories).replace(/\$ensureChunkHandlers\$/g, RuntimeGlobals.ensureChunkHandlers).replace(/\$hasOwnProperty\$/g, RuntimeGlobals.hasOwnProperty).replace(/\$hmrModuleData\$/g, RuntimeGlobals.hmrModuleData).replace(/\$hmrDownloadUpdateHandlers\$/g, RuntimeGlobals.hmrDownloadUpdateHandlers).replace(/\$hmrInvalidateModuleHandlers\$/g, RuntimeGlobals.hmrInvalidateModuleHandlers)
|
|
45
|
+
]);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Retrieves the initial chunk IDs.
|
|
49
|
+
* @param {Chunk} chunk - The chunk object.
|
|
50
|
+
* @param {ChunkGraph} chunkGraph - The chunk graph object.
|
|
51
|
+
* @param {any} chunkHasJs - Function to check if a chunk has JavaScript.
|
|
52
|
+
* @returns {Set} - The set of initial chunk IDs.
|
|
53
|
+
*/
|
|
54
|
+
function getInitialChunkIds(chunk, chunkGraph, chunkHasJs) {
|
|
55
|
+
const initialChunkIds = new Set(chunk.ids);
|
|
56
|
+
for (const c of chunk.getAllInitialChunks()) {
|
|
57
|
+
if (c === chunk || chunkHasJs(c, chunkGraph)) continue;
|
|
58
|
+
if (c.ids) for (const id of c.ids) initialChunkIds.add(id);
|
|
59
|
+
for (const c of chunk.getAllAsyncChunks()) {
|
|
60
|
+
if (c === chunk || chunkHasJs(c, chunkGraph)) continue;
|
|
61
|
+
if (c.ids) for (const id of c.ids) initialChunkIds.add(id);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return initialChunkIds;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Generates the loading code for chunks.
|
|
68
|
+
* @param {boolean} withLoading - Flag indicating whether chunk loading is enabled.
|
|
69
|
+
* @param {string} fn - The function name.
|
|
70
|
+
* @param {any} hasJsMatcher - Function to check if a chunk has JavaScript.
|
|
71
|
+
* @param {string} rootOutputDir - The root output directory.
|
|
72
|
+
* @param {Record<string, string>} remotes - The remotes object.
|
|
73
|
+
* @param {string | undefined} name - The name of the chunk.
|
|
74
|
+
* @returns {string} - The generated loading code.
|
|
75
|
+
*/
|
|
76
|
+
function generateLoadingCode(withLoading, fn, hasJsMatcher, rootOutputDir, remotes, name) {
|
|
77
|
+
if (!withLoading) return "// no chunk loading";
|
|
78
|
+
return Template.asString([
|
|
79
|
+
"// Dynamic filesystem chunk loading for javascript",
|
|
80
|
+
`${fn}.readFileVm = function(chunkId, promises) {`,
|
|
81
|
+
hasJsMatcher !== false ? Template.indent([
|
|
82
|
+
"var installedChunkData = installedChunks[chunkId];",
|
|
83
|
+
"if(installedChunkData !== 0) { // 0 means \"already installed\".",
|
|
84
|
+
Template.indent([
|
|
85
|
+
"// array of [resolve, reject, promise] means \"currently loading\"",
|
|
86
|
+
"if(installedChunkData) {",
|
|
87
|
+
Template.indent(["promises.push(installedChunkData[2]);"]),
|
|
88
|
+
"} else {",
|
|
89
|
+
Template.indent([
|
|
90
|
+
hasJsMatcher === true ? "if(true) { // all chunks have JS" : `if(${hasJsMatcher("chunkId")}) {`,
|
|
91
|
+
Template.indent([
|
|
92
|
+
"// load the chunk and return promise to it",
|
|
93
|
+
"var promise = new Promise(async function(resolve, reject) {",
|
|
94
|
+
Template.indent([
|
|
95
|
+
"installedChunkData = installedChunks[chunkId] = [resolve, reject];",
|
|
96
|
+
"function installChunkCallback(error,chunk){",
|
|
97
|
+
Template.indent(["if(error) return reject(error);", "installChunk(chunk);"]),
|
|
98
|
+
"}",
|
|
99
|
+
"var fs = typeof process !== \"undefined\" ? require('fs') : false;",
|
|
100
|
+
`var filename = typeof process !== "undefined" ? require('path').join(__dirname, ${JSON.stringify(rootOutputDir)} + ${RuntimeGlobals.getChunkScriptFilename}(chunkId)) : false;`,
|
|
101
|
+
"if(fs && fs.existsSync(filename)) {",
|
|
102
|
+
Template.indent([`loadChunkStrategy('filesystem', chunkId, ${JSON.stringify(rootOutputDir)}, remotes, installChunkCallback);`]),
|
|
103
|
+
"} else { ",
|
|
104
|
+
Template.indent([
|
|
105
|
+
`var remotes = ${JSON.stringify(Object.values(remotes).reduce((acc, remote) => {
|
|
106
|
+
const [global, url] = remote.split("@");
|
|
107
|
+
acc[global] = url;
|
|
108
|
+
return acc;
|
|
109
|
+
}, {}))};`,
|
|
110
|
+
`var chunkName = ${RuntimeGlobals.getChunkScriptFilename}(chunkId);`,
|
|
111
|
+
"const loadingStrategy = typeof process !== 'undefined' ? 'http-vm' : 'http-eval';",
|
|
112
|
+
`loadChunkStrategy(loadingStrategy, chunkName,${RuntimeGlobals.require}.federation.initOptions.name, ${RuntimeGlobals.require}.federation.initOptions.remotes, installChunkCallback);`
|
|
113
|
+
]),
|
|
114
|
+
"}"
|
|
115
|
+
]),
|
|
116
|
+
"});",
|
|
117
|
+
"promises.push(installedChunkData[2] = promise);"
|
|
118
|
+
]),
|
|
119
|
+
"} else installedChunks[chunkId] = 0;"
|
|
120
|
+
]),
|
|
121
|
+
"}"
|
|
122
|
+
]),
|
|
123
|
+
"}"
|
|
124
|
+
]) : Template.indent(["installedChunks[chunkId] = 0;"]),
|
|
125
|
+
"};"
|
|
126
|
+
]);
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Generates the HMR manifest code.
|
|
130
|
+
* @param {boolean} withHmrManifest - Flag indicating whether HMR manifest is enabled.
|
|
131
|
+
* @param {string} rootOutputDir - The root output directory.
|
|
132
|
+
* @returns {string} - The generated HMR manifest code.
|
|
133
|
+
*/
|
|
134
|
+
function generateHmrManifestCode(withHmrManifest, rootOutputDir) {
|
|
135
|
+
if (!withHmrManifest) return "// no HMR manifest";
|
|
136
|
+
return Template.asString([
|
|
137
|
+
`${RuntimeGlobals.hmrDownloadManifest} = function() {`,
|
|
138
|
+
Template.indent([
|
|
139
|
+
"return new Promise(function(resolve, reject) {",
|
|
140
|
+
Template.indent([
|
|
141
|
+
`var filename = require('path').join(__dirname, ${JSON.stringify(rootOutputDir)} + ${RuntimeGlobals.getUpdateManifestFilename}());`,
|
|
142
|
+
"require('fs').readFile(filename, 'utf-8', function(err, content) {",
|
|
143
|
+
Template.indent([
|
|
144
|
+
"if(err) {",
|
|
145
|
+
Template.indent(["if(err.code === \"ENOENT\") return resolve();", "return reject(err);"]),
|
|
146
|
+
"}",
|
|
147
|
+
"try { resolve(JSON.parse(content)); }",
|
|
148
|
+
"catch(e) { reject(e); }"
|
|
149
|
+
]),
|
|
150
|
+
"});"
|
|
151
|
+
]),
|
|
152
|
+
"});"
|
|
153
|
+
]),
|
|
154
|
+
"}"
|
|
155
|
+
]);
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Handles the on chunk load event.
|
|
159
|
+
* @param {boolean} withOnChunkLoad - Flag indicating whether on chunk load event is enabled.
|
|
160
|
+
* @param {any} runtimeTemplate - The runtime template.
|
|
161
|
+
* @returns {string} - The generated on chunk load event handler.
|
|
162
|
+
*/
|
|
163
|
+
function handleOnChunkLoad(withOnChunkLoad, runtimeTemplate) {
|
|
164
|
+
if (withOnChunkLoad) return `${RuntimeGlobals.onChunksLoaded}.readFileVm = ${runtimeTemplate.returningFunction("installedChunks[chunkId] === 0", "chunkId")};`;
|
|
165
|
+
else return "// no on chunks loaded";
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Generates the load script for server-side execution. This function creates a script that loads a remote module
|
|
169
|
+
* and executes it in the current context. It supports both browser and Node.js environments.
|
|
170
|
+
* @param {any} runtimeTemplate - The runtime template used to generate the load script.
|
|
171
|
+
* @returns {string} - The generated load script.
|
|
172
|
+
*/
|
|
173
|
+
function generateLoadScript(runtimeTemplate) {
|
|
174
|
+
return Template.asString(["// load script equivalent for server side", `${RuntimeGlobals.loadScript} = ${runtimeTemplate.basicFunction("url, callback, chunkId", [Template.indent([`async function executeLoad(url, callback, name) {
|
|
175
|
+
if (!name) {
|
|
176
|
+
throw new Error('__webpack_require__.l name is required for ' + url);
|
|
177
|
+
}
|
|
178
|
+
const usesInternalRef = name.startsWith('__webpack_require__')
|
|
179
|
+
if (usesInternalRef) {
|
|
180
|
+
const regex = /__webpack_require__\\.federation\\.instance\\.moduleCache\\.get\\(([^)]+)\\)/;
|
|
181
|
+
const match = name.match(regex);
|
|
182
|
+
if (match) {
|
|
183
|
+
name = match[1].replace(/["']/g, '');
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
try {
|
|
187
|
+
const federation = ${RuntimeGlobals.require}.federation;
|
|
188
|
+
const res = await ${RuntimeGlobals.require}.federation.runtime.loadScriptNode(url, { attrs: {} });
|
|
189
|
+
const enhancedRemote = federation.instance.initRawContainer(name, url, res);
|
|
190
|
+
// use normal global assignment
|
|
191
|
+
if(!usesInternalRef && !globalThis[name]) {
|
|
192
|
+
globalThis[name] = enhancedRemote
|
|
193
|
+
}
|
|
194
|
+
callback(enhancedRemote);
|
|
195
|
+
} catch (error) {
|
|
196
|
+
callback(error);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
}`, `executeLoad(url, callback, chunkId);`])])}`]);
|
|
200
|
+
}
|
|
201
|
+
function generateInstallChunk(runtimeTemplate, withOnChunkLoad) {
|
|
202
|
+
return `var installChunk = ${runtimeTemplate.basicFunction("chunk", [
|
|
203
|
+
"var moreModules = chunk.modules, chunkIds = chunk.ids, runtime = chunk.runtime;",
|
|
204
|
+
"for(var moduleId in moreModules) {",
|
|
205
|
+
Template.indent([
|
|
206
|
+
`if(${RuntimeGlobals.hasOwnProperty}(moreModules, moduleId)) {`,
|
|
207
|
+
Template.indent([`${RuntimeGlobals.moduleFactories}[moduleId] = moreModules[moduleId];`]),
|
|
208
|
+
"}"
|
|
209
|
+
]),
|
|
210
|
+
"}",
|
|
211
|
+
"if(runtime) runtime(__webpack_require__);",
|
|
212
|
+
"for(var i = 0; i < chunkIds.length; i++) {",
|
|
213
|
+
Template.indent([
|
|
214
|
+
"if(installedChunks[chunkIds[i]]) {",
|
|
215
|
+
Template.indent(["installedChunks[chunkIds[i]][0]();"]),
|
|
216
|
+
"}",
|
|
217
|
+
"installedChunks[chunkIds[i]] = 0;"
|
|
218
|
+
]),
|
|
219
|
+
"}",
|
|
220
|
+
withOnChunkLoad ? `${RuntimeGlobals.onChunksLoaded}();` : ""
|
|
221
|
+
])};`;
|
|
222
|
+
}
|
|
223
|
+
function generateExternalInstallChunkCode(withExternalInstallChunk, debug) {
|
|
224
|
+
if (!withExternalInstallChunk) return "// no external install chunk";
|
|
225
|
+
return Template.asString([
|
|
226
|
+
"module.exports = __webpack_require__;",
|
|
227
|
+
`${RuntimeGlobals.externalInstallChunk} = function(){`,
|
|
228
|
+
debug ? `console.debug('node: webpack installing to install chunk id:', arguments['0'].id);` : "",
|
|
229
|
+
`return installChunk.apply(this, arguments)};`
|
|
230
|
+
]);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
//#endregion
|
|
234
|
+
exports.generateExternalInstallChunkCode = generateExternalInstallChunkCode;
|
|
235
|
+
exports.generateHmrCode = generateHmrCode;
|
|
236
|
+
exports.generateHmrManifestCode = generateHmrManifestCode;
|
|
237
|
+
exports.generateInstallChunk = generateInstallChunk;
|
|
238
|
+
exports.generateLoadScript = generateLoadScript;
|
|
239
|
+
exports.generateLoadingCode = generateLoadingCode;
|
|
240
|
+
exports.getInitialChunkIds = getInitialChunkIds;
|
|
241
|
+
exports.handleOnChunkLoad = handleOnChunkLoad;
|
|
242
|
+
//# sourceMappingURL=webpackChunkUtilities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webpackChunkUtilities.js","names":[],"sources":["../../../src/plugins/webpackChunkUtilities.ts"],"sourcesContent":["import { normalizeWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\nconst { RuntimeGlobals, Template } = require(\n normalizeWebpackPath('webpack'),\n) as typeof import('webpack');\nimport type { Chunk, ChunkGraph } from 'webpack';\n\n/**\n * Generates the hot module replacement (HMR) code.\n * @param {boolean} withHmr - Flag indicating whether HMR is enabled.\n * @param {string} rootOutputDir - The root output directory.\n * @returns {string} - The generated HMR code.\n */\nexport function generateHmrCode(\n withHmr: boolean,\n rootOutputDir: string,\n): string {\n if (!withHmr) {\n return '// no HMR';\n }\n\n return Template.asString([\n // Function to load updated chunk\n 'function loadUpdateChunk(chunkId, updatedModulesList) {',\n Template.indent([\n 'return new Promise(function(resolve, reject) {',\n Template.indent([\n // Construct filename for the updated chunk\n `var filename = require('path').join(__dirname, ${JSON.stringify(\n rootOutputDir,\n )} + ${RuntimeGlobals.getChunkUpdateScriptFilename}(chunkId));`,\n // Read the updated chunk file\n \"require('fs').readFile(filename, 'utf-8', function(err, content) {\",\n Template.indent([\n 'if(err) return reject(err);',\n 'var update = {};',\n // Execute the updated chunk in the current context\n \"require('vm').runInThisContext('(function(exports, require, __dirname, __filename) {' + content + '\\\\n})', filename)\" +\n \"(update, require, require('path').dirname(filename), filename);\",\n 'var updatedModules = update.modules;',\n 'var runtime = update.runtime;',\n // Iterate over the updated modules\n 'for(var moduleId in updatedModules) {',\n Template.indent([\n `if(${RuntimeGlobals.hasOwnProperty}(updatedModules, moduleId)) {`,\n Template.indent([\n `currentUpdate[moduleId] = updatedModules[moduleId];`,\n 'if(updatedModulesList) updatedModulesList.push(moduleId);',\n ]),\n '}',\n ]),\n '}',\n 'if(runtime) currentUpdateRuntime.push(runtime);',\n 'resolve();',\n ]),\n '});',\n ]),\n '});',\n ]),\n '}',\n '',\n // Replace placeholders in the HMR runtime code\n Template.getFunctionContent(\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n require('webpack/lib/hmr/JavascriptHotModuleReplacement.runtime.js'),\n )\n .replace(/\\$key\\$/g, 'readFileVm')\n .replace(/\\$installedChunks\\$/g, 'installedChunks')\n .replace(/\\$loadUpdateChunk\\$/g, 'loadUpdateChunk')\n .replace(/\\$moduleCache\\$/g, RuntimeGlobals.moduleCache)\n .replace(/\\$moduleFactories\\$/g, RuntimeGlobals.moduleFactories)\n .replace(/\\$ensureChunkHandlers\\$/g, RuntimeGlobals.ensureChunkHandlers)\n .replace(/\\$hasOwnProperty\\$/g, RuntimeGlobals.hasOwnProperty)\n .replace(/\\$hmrModuleData\\$/g, RuntimeGlobals.hmrModuleData)\n .replace(\n /\\$hmrDownloadUpdateHandlers\\$/g,\n RuntimeGlobals.hmrDownloadUpdateHandlers,\n )\n .replace(\n /\\$hmrInvalidateModuleHandlers\\$/g,\n RuntimeGlobals.hmrInvalidateModuleHandlers,\n ),\n ]);\n}\n/**\n * Retrieves the initial chunk IDs.\n * @param {Chunk} chunk - The chunk object.\n * @param {ChunkGraph} chunkGraph - The chunk graph object.\n * @param {any} chunkHasJs - Function to check if a chunk has JavaScript.\n * @returns {Set} - The set of initial chunk IDs.\n */\nexport function getInitialChunkIds(\n chunk: Chunk,\n chunkGraph: ChunkGraph,\n chunkHasJs: any,\n) {\n const initialChunkIds = new Set(chunk.ids);\n for (const c of chunk.getAllInitialChunks()) {\n if (c === chunk || chunkHasJs(c, chunkGraph)) continue;\n if (c.ids) {\n for (const id of c.ids) initialChunkIds.add(id);\n }\n for (const c of chunk.getAllAsyncChunks()) {\n if (c === chunk || chunkHasJs(c, chunkGraph)) continue;\n if (c.ids) {\n for (const id of c.ids) initialChunkIds.add(id);\n }\n }\n }\n return initialChunkIds;\n}\n/**\n * Generates the loading code for chunks.\n * @param {boolean} withLoading - Flag indicating whether chunk loading is enabled.\n * @param {string} fn - The function name.\n * @param {any} hasJsMatcher - Function to check if a chunk has JavaScript.\n * @param {string} rootOutputDir - The root output directory.\n * @param {Record<string, string>} remotes - The remotes object.\n * @param {string | undefined} name - The name of the chunk.\n * @returns {string} - The generated loading code.\n */\nexport function generateLoadingCode(\n withLoading: boolean,\n fn: string,\n hasJsMatcher: any,\n rootOutputDir: string,\n remotes: Record<string, string>,\n name: string | undefined,\n): string {\n if (!withLoading) {\n return '// no chunk loading';\n }\n\n return Template.asString([\n '// Dynamic filesystem chunk loading for javascript',\n `${fn}.readFileVm = function(chunkId, promises) {`,\n hasJsMatcher !== false\n ? Template.indent([\n 'var installedChunkData = installedChunks[chunkId];',\n 'if(installedChunkData !== 0) { // 0 means \"already installed\".',\n Template.indent([\n '// array of [resolve, reject, promise] means \"currently loading\"',\n 'if(installedChunkData) {',\n Template.indent(['promises.push(installedChunkData[2]);']),\n '} else {',\n Template.indent([\n hasJsMatcher === true\n ? 'if(true) { // all chunks have JS'\n : `if(${hasJsMatcher('chunkId')}) {`,\n Template.indent([\n '// load the chunk and return promise to it',\n 'var promise = new Promise(async function(resolve, reject) {',\n Template.indent([\n 'installedChunkData = installedChunks[chunkId] = [resolve, reject];',\n 'function installChunkCallback(error,chunk){',\n Template.indent([\n 'if(error) return reject(error);',\n 'installChunk(chunk);',\n ]),\n '}',\n 'var fs = typeof process !== \"undefined\" ? require(\\'fs\\') : false;',\n `var filename = typeof process !== \"undefined\" ? require('path').join(__dirname, ${JSON.stringify(\n rootOutputDir,\n )} + ${\n RuntimeGlobals.getChunkScriptFilename\n }(chunkId)) : false;`,\n\n 'if(fs && fs.existsSync(filename)) {',\n Template.indent([\n `loadChunkStrategy('filesystem', chunkId, ${JSON.stringify(\n rootOutputDir,\n )}, remotes, installChunkCallback);`,\n ]),\n '} else { ',\n Template.indent([\n `var remotes = ${JSON.stringify(\n Object.values(remotes).reduce(\n (acc, remote) => {\n const [global, url] = remote.split('@');\n acc[global] = url;\n return acc;\n },\n {} as Record<string, string>,\n ),\n )};`,\n\n `var chunkName = ${RuntimeGlobals.getChunkScriptFilename}(chunkId);`,\n \"const loadingStrategy = typeof process !== 'undefined' ? 'http-vm' : 'http-eval';\",\n `loadChunkStrategy(loadingStrategy, chunkName,${RuntimeGlobals.require}.federation.initOptions.name, ${RuntimeGlobals.require}.federation.initOptions.remotes, installChunkCallback);`,\n ]),\n '}',\n ]),\n '});',\n 'promises.push(installedChunkData[2] = promise);',\n ]),\n '} else installedChunks[chunkId] = 0;',\n ]),\n '}',\n ]),\n '}',\n ])\n : Template.indent(['installedChunks[chunkId] = 0;']),\n '};',\n ]);\n}\n/**\n * Generates the HMR manifest code.\n * @param {boolean} withHmrManifest - Flag indicating whether HMR manifest is enabled.\n * @param {string} rootOutputDir - The root output directory.\n * @returns {string} - The generated HMR manifest code.\n */\nexport function generateHmrManifestCode(\n withHmrManifest: boolean,\n rootOutputDir: string,\n): string {\n if (!withHmrManifest) {\n return '// no HMR manifest';\n }\n\n return Template.asString([\n `${RuntimeGlobals.hmrDownloadManifest} = function() {`,\n Template.indent([\n 'return new Promise(function(resolve, reject) {',\n Template.indent([\n `var filename = require('path').join(__dirname, ${JSON.stringify(\n rootOutputDir,\n )} + ${RuntimeGlobals.getUpdateManifestFilename}());`,\n \"require('fs').readFile(filename, 'utf-8', function(err, content) {\",\n Template.indent([\n 'if(err) {',\n Template.indent([\n 'if(err.code === \"ENOENT\") return resolve();',\n 'return reject(err);',\n ]),\n '}',\n 'try { resolve(JSON.parse(content)); }',\n 'catch(e) { reject(e); }',\n ]),\n '});',\n ]),\n '});',\n ]),\n '}',\n ]);\n}\n/**\n * Handles the on chunk load event.\n * @param {boolean} withOnChunkLoad - Flag indicating whether on chunk load event is enabled.\n * @param {any} runtimeTemplate - The runtime template.\n * @returns {string} - The generated on chunk load event handler.\n */\nexport function handleOnChunkLoad(\n withOnChunkLoad: boolean,\n runtimeTemplate: any,\n): string {\n if (withOnChunkLoad) {\n return `${\n RuntimeGlobals.onChunksLoaded\n }.readFileVm = ${runtimeTemplate.returningFunction(\n 'installedChunks[chunkId] === 0',\n 'chunkId',\n )};`;\n } else {\n return '// no on chunks loaded';\n }\n}\n/**\n * Generates the load script for server-side execution. This function creates a script that loads a remote module\n * and executes it in the current context. It supports both browser and Node.js environments.\n * @param {any} runtimeTemplate - The runtime template used to generate the load script.\n * @returns {string} - The generated load script.\n */\nexport function generateLoadScript(runtimeTemplate: any): string {\n return Template.asString([\n '// load script equivalent for server side',\n `${RuntimeGlobals.loadScript} = ${runtimeTemplate.basicFunction(\n 'url, callback, chunkId',\n [\n Template.indent([\n `async function executeLoad(url, callback, name) {\n if (!name) {\n throw new Error('__webpack_require__.l name is required for ' + url);\n }\n const usesInternalRef = name.startsWith('__webpack_require__')\n if (usesInternalRef) {\n const regex = /__webpack_require__\\\\.federation\\\\.instance\\\\.moduleCache\\\\.get\\\\(([^)]+)\\\\)/;\n const match = name.match(regex);\n if (match) {\n name = match[1].replace(/[\"']/g, '');\n }\n }\n try {\n const federation = ${RuntimeGlobals.require}.federation;\n const res = await ${RuntimeGlobals.require}.federation.runtime.loadScriptNode(url, { attrs: {} });\n const enhancedRemote = federation.instance.initRawContainer(name, url, res);\n // use normal global assignment\n if(!usesInternalRef && !globalThis[name]) {\n globalThis[name] = enhancedRemote\n }\n callback(enhancedRemote);\n } catch (error) {\n callback(error);\n }\n\n }`,\n `executeLoad(url, callback, chunkId);`,\n ]),\n ],\n )}`,\n ]);\n}\nexport function generateInstallChunk(\n runtimeTemplate: any,\n withOnChunkLoad: boolean,\n): string {\n return `var installChunk = ${runtimeTemplate.basicFunction('chunk', [\n 'var moreModules = chunk.modules, chunkIds = chunk.ids, runtime = chunk.runtime;',\n 'for(var moduleId in moreModules) {',\n Template.indent([\n `if(${RuntimeGlobals.hasOwnProperty}(moreModules, moduleId)) {`,\n Template.indent([\n `${RuntimeGlobals.moduleFactories}[moduleId] = moreModules[moduleId];`,\n ]),\n '}',\n ]),\n '}',\n 'if(runtime) runtime(__webpack_require__);',\n 'for(var i = 0; i < chunkIds.length; i++) {',\n Template.indent([\n 'if(installedChunks[chunkIds[i]]) {',\n Template.indent(['installedChunks[chunkIds[i]][0]();']),\n '}',\n 'installedChunks[chunkIds[i]] = 0;',\n ]),\n '}',\n withOnChunkLoad ? `${RuntimeGlobals.onChunksLoaded}();` : '',\n ])};`;\n}\nexport function generateExternalInstallChunkCode(\n withExternalInstallChunk: boolean,\n debug: boolean | undefined,\n): string {\n if (!withExternalInstallChunk) {\n return '// no external install chunk';\n }\n\n return Template.asString([\n 'module.exports = __webpack_require__;',\n `${RuntimeGlobals.externalInstallChunk} = function(){`,\n debug\n ? `console.debug('node: webpack installing to install chunk id:', arguments['0'].id);`\n : '',\n `return installChunk.apply(this, arguments)};`,\n ]);\n}\n"],"mappings":"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"}
|