@module-federation/node 2.0.1 → 2.0.2-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/README.md +27 -0
  3. package/jest.config.d.ts +11 -0
  4. package/jest.config.js +19 -0
  5. package/jest.config.js.map +1 -0
  6. package/package.json +3 -2
  7. package/src/filesystem/DynamicFilesystemRuntimeModule.d.ts +6 -0
  8. package/src/filesystem/DynamicFilesystemRuntimeModule.js +30 -0
  9. package/src/filesystem/DynamicFilesystemRuntimeModule.js.map +1 -0
  10. package/src/filesystem/stratagies.d.ts +11 -0
  11. package/src/filesystem/stratagies.js +105 -0
  12. package/src/filesystem/stratagies.js.map +1 -0
  13. package/src/plugins/CommonJsChunkLoadingPlugin.js +29 -2
  14. package/src/plugins/CommonJsChunkLoadingPlugin.js.map +1 -1
  15. package/src/plugins/{LoadFileChunkLoadingRuntimeModule.d.ts → DynamicFilesystemChunkLoadingRuntimeModule.d.ts} +8 -4
  16. package/src/plugins/DynamicFilesystemChunkLoadingRuntimeModule.js +145 -0
  17. package/src/plugins/DynamicFilesystemChunkLoadingRuntimeModule.js.map +1 -0
  18. package/src/plugins/FederationModuleInfoRuntimeModule.d.ts +9 -0
  19. package/src/plugins/FederationModuleInfoRuntimeModule.js +55 -0
  20. package/src/plugins/FederationModuleInfoRuntimeModule.js.map +1 -0
  21. package/src/plugins/NodeFederationPlugin.d.ts +18 -25
  22. package/src/plugins/NodeFederationPlugin.js +41 -102
  23. package/src/plugins/NodeFederationPlugin.js.map +1 -1
  24. package/src/plugins/RemotePublicPathRuntimeModule.d.ts +10 -0
  25. package/src/plugins/RemotePublicPathRuntimeModule.js +86 -0
  26. package/src/plugins/RemotePublicPathRuntimeModule.js.map +1 -0
  27. package/src/plugins/StreamingTargetPlugin.js +6 -7
  28. package/src/plugins/StreamingTargetPlugin.js.map +1 -1
  29. package/src/plugins/UniversalFederationPlugin.js +2 -1
  30. package/src/plugins/UniversalFederationPlugin.js.map +1 -1
  31. package/src/plugins/parts.d.ts +50 -0
  32. package/src/plugins/parts.js +316 -0
  33. package/src/plugins/parts.js.map +1 -0
  34. package/src/plugins/LoadFileChunkLoadingRuntimeModule.js +0 -434
  35. package/src/plugins/LoadFileChunkLoadingRuntimeModule.js.map +0 -1
  36. package/src/plugins/loadScript.d.ts +0 -7
  37. package/src/plugins/loadScript.js +0 -116
  38. package/src/plugins/loadScript.js.map +0 -1
@@ -9,6 +9,7 @@ import type { ModuleFederationPluginOptions } from '../types';
9
9
  interface NodeFederationOptions extends ModuleFederationPluginOptions {
10
10
  experiments?: Record<string, unknown>;
11
11
  debug?: boolean;
12
+ useRemoteSideloader?: boolean;
12
13
  }
13
14
  /**
14
15
  * Interface for Context
@@ -19,32 +20,24 @@ interface Context {
19
20
  ModuleFederationPlugin?: typeof container.ModuleFederationPlugin;
20
21
  }
21
22
  /**
22
- * This function parses the remotes and checks if they are internal or not.
23
- * If it's an internal remote then we add it to our new object with a key of the name of the remote and value as internal.
24
- * If it's not an internal remote then we check if there is a '@' in that string which means that this is probably a github repo.
25
- * @function
26
- * @param {Record<string, any>} remotes - The remotes to parse
27
- * @returns {Record<string, string>} The parsed remotes
28
- */
23
+ * This function iterates over all remotes and checks if they
24
+ * are internal or not. If it's an internal remote then we add it to our new object
25
+ * with a key of the name of the remote and value as internal. If it's not an internal
26
+ * remote then we check if there is a '@' in that string which likely means it is a global @ url
27
+ *
28
+ * @param {Record<string, any>} remotes - The remotes to parse.
29
+ * @returns {Record<string, string>} - The parsed remotes.
30
+ * */
29
31
  export declare const parseRemotes: (remotes: Record<string, any>) => Record<string, string>;
30
32
  /**
31
- * This function generates a remote template.
32
- * @function
33
- * @param {string} url - The url of the remote
34
- * @param {any} global - The global variable
35
- * @returns {string} The generated remote template
36
- */
37
- export declare const generateRemoteTemplate: (url: string, global: any) => string;
38
- /**
39
- * This function takes the remote string and splits it into two parts.
40
- * The first part of the split is going to be a url which will be used in generate Remote Template function.
41
- * The second part of the split is going to be a global variable name which will also be used in generate Remote Template function.
42
- * If there's no global variable name then we'll use default as default value for that parameter.
43
- * @function
44
- * @param {any} remote - The remote to parse
45
- * @returns {any} The parsed remote
33
+ * Parses the remote syntax and returns a formatted string if the remote includes '@' and does not start with 'window', 'global', or 'globalThis'.
34
+ * Otherwise, it returns the original remote string.
35
+ *
36
+ * @param {string} remote - The remote string to parse.
37
+ * @returns {string} - The parsed remote string or the original remote string.
38
+ * @throws {Error} - Throws an error if the remote is not a string.
46
39
  */
47
- export declare const parseRemoteSyntax: (remote: any) => any;
40
+ export declare const parseRemoteSyntax: (remote: any) => string;
48
41
  /**
49
42
  * Class representing a NodeFederationPlugin.
50
43
  * @class
@@ -61,9 +54,9 @@ declare class NodeFederationPlugin {
61
54
  */
62
55
  constructor({ experiments, debug, ...options }: NodeFederationOptions, context: Context);
63
56
  /**
64
- * Apply the NodeFederationPlugin.
57
+ * Apply method for the NodeFederationPlugin class.
65
58
  * @method
66
- * @param {Compiler} compiler - The webpack compiler
59
+ * @param {Compiler} compiler - The webpack compiler.
67
60
  */
68
61
  apply(compiler: Compiler): void;
69
62
  }
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseRemoteSyntax = exports.generateRemoteTemplate = exports.parseRemotes = void 0;
3
+ exports.parseRemoteSyntax = exports.parseRemotes = void 0;
4
4
  const pure_1 = require("@module-federation/utilities/src/utils/pure");
5
5
  // possible remote evaluators
6
6
  // this depends on the chunk format selected.
@@ -11,94 +11,43 @@ const pure_1 = require("@module-federation/utilities/src/utils/pure");
11
11
  // commonjs-module, ideal since it returns a commonjs module format
12
12
  // const remote = eval(scriptContent + 'module.exports')
13
13
  /**
14
- * This function parses the remotes and checks if they are internal or not.
15
- * If it's an internal remote then we add it to our new object with a key of the name of the remote and value as internal.
16
- * If it's not an internal remote then we check if there is a '@' in that string which means that this is probably a github repo.
17
- * @function
18
- * @param {Record<string, any>} remotes - The remotes to parse
19
- * @returns {Record<string, string>} The parsed remotes
20
- */
21
- const parseRemotes = (remotes) => Object.entries(remotes).reduce((acc, remote) => {
22
- if (remote[1].startsWith('internal ')) {
23
- acc[remote[0]] = remote[1];
24
- return acc;
14
+ * This function iterates over all remotes and checks if they
15
+ * are internal or not. If it's an internal remote then we add it to our new object
16
+ * with a key of the name of the remote and value as internal. If it's not an internal
17
+ * remote then we check if there is a '@' in that string which likely means it is a global @ url
18
+ *
19
+ * @param {Record<string, any>} remotes - The remotes to parse.
20
+ * @returns {Record<string, string>} - The parsed remotes.
21
+ * */
22
+ const parseRemotes = (remotes) => {
23
+ if (!remotes || typeof remotes !== 'object') {
24
+ throw new Error('remotes must be an object');
25
25
  }
26
- if (!remote[1].startsWith('promise ') && remote[1].includes('@')) {
27
- acc[remote[0]] = `promise ${(0, exports.parseRemoteSyntax)(remote[1])}`;
26
+ return Object.entries(remotes).reduce((acc, [key, value]) => {
27
+ const isInternal = value.startsWith('internal ');
28
+ const isGlobal = value.includes('@') && !['window.', 'global.', 'globalThis.', 'self.'].some(prefix => value.startsWith(prefix));
29
+ acc[key] = isInternal || !isGlobal ? value : (0, exports.parseRemoteSyntax)(value);
28
30
  return acc;
29
- }
30
- acc[remote[0]] = remote[1];
31
- return acc;
32
- }, {});
31
+ }, {});
32
+ };
33
33
  exports.parseRemotes = parseRemotes;
34
- // server template to convert remote into promise new promise and use require.loadChunk to load the chunk
35
34
  /**
36
- * This function generates a remote template.
37
- * @function
38
- * @param {string} url - The url of the remote
39
- * @param {any} global - The global variable
40
- * @returns {string} The generated remote template
41
- */
42
- const generateRemoteTemplate = (url, global) => `new Promise(function (resolve, reject) {
43
- if(!globalThis.__remote_scope__) {
44
- // create a global scope for container, similar to how remotes are set on window in the browser
45
- globalThis.__remote_scope__ = {
46
- _config: {},
47
- }
48
- }
49
-
50
- if (typeof globalThis.__remote_scope__[${JSON.stringify(global)}] !== 'undefined') return resolve(globalThis.__remote_scope__[${JSON.stringify(global)}]);
51
- globalThis.__remote_scope__._config[${JSON.stringify(global)}] = ${JSON.stringify(url)};
52
- var __webpack_error__ = new Error();
53
-
54
- __webpack_require__.l(
55
- ${JSON.stringify(url)},
56
- function (event) {
57
- if (typeof globalThis.__remote_scope__[${JSON.stringify(global)}] !== 'undefined') return resolve(globalThis.__remote_scope__[${JSON.stringify(global)}]);
58
- var realSrc = event && event.target && event.target.src;
59
- __webpack_error__.message = 'Loading script failed.\\n(' + event.message + ': ' + realSrc + ')';
60
- __webpack_error__.name = 'ScriptExternalLoadError';
61
- __webpack_error__.stack = event.stack;
62
- reject(__webpack_error__);
63
- },
64
- ${JSON.stringify(global)},
65
- );
66
- }).catch((e)=> {
67
- console.error(${JSON.stringify(global)}, 'is offline, returning fake remote');
68
- console.error(e);
69
-
70
- return {
71
- fake: true,
72
- get: (arg) => {
73
- console.warn('faking', arg, 'module on', ${JSON.stringify(global)});
74
-
75
- return Promise.resolve(() => {
76
- return () => null
77
- });
78
- },
79
- init: () => {
80
- }
81
- }
82
- }).then(function (remote) {
83
- if(remote.fake) {
84
- return remote;
85
- }
86
- return remote;
87
- })`;
88
- exports.generateRemoteTemplate = generateRemoteTemplate;
89
- /**
90
- * This function takes the remote string and splits it into two parts.
91
- * The first part of the split is going to be a url which will be used in generate Remote Template function.
92
- * The second part of the split is going to be a global variable name which will also be used in generate Remote Template function.
93
- * If there's no global variable name then we'll use default as default value for that parameter.
94
- * @function
95
- * @param {any} remote - The remote to parse
96
- * @returns {any} The parsed remote
35
+ * Parses the remote syntax and returns a formatted string if the remote includes '@' and does not start with 'window', 'global', or 'globalThis'.
36
+ * Otherwise, it returns the original remote string.
37
+ *
38
+ * @param {string} remote - The remote string to parse.
39
+ * @returns {string} - The parsed remote string or the original remote string.
40
+ * @throws {Error} - Throws an error if the remote is not a string.
97
41
  */
98
42
  const parseRemoteSyntax = (remote) => {
99
- if (typeof remote === 'string' && remote.includes('@')) {
43
+ if (typeof remote !== 'string') {
44
+ throw new Error('remote must be a string');
45
+ }
46
+ if (remote.includes('@')) {
100
47
  const [url, global] = (0, pure_1.extractUrlAndGlobal)(remote);
101
- return (0, exports.generateRemoteTemplate)(url, global);
48
+ if (!['window.', 'global.', 'globalThis.'].some(prefix => global.startsWith(prefix))) {
49
+ return `globalThis.__remote_scope__.${global}@${url}`;
50
+ }
102
51
  }
103
52
  return remote;
104
53
  };
@@ -120,36 +69,26 @@ class NodeFederationPlugin {
120
69
  this.experiments = experiments || {};
121
70
  }
122
71
  /**
123
- * Apply the NodeFederationPlugin.
72
+ * Apply method for the NodeFederationPlugin class.
124
73
  * @method
125
- * @param {Compiler} compiler - The webpack compiler
74
+ * @param {Compiler} compiler - The webpack compiler.
126
75
  */
127
76
  apply(compiler) {
128
77
  // When used with Next.js, context is needed to use Next.js webpack
129
78
  const { webpack } = compiler;
130
79
  const pluginOptions = {
131
80
  ...this._options,
132
- remotes: (0, exports.parseRemotes)(this._options.remotes || {}),
81
+ remotes: this._options.remotes ? (0, exports.parseRemotes)(this._options.remotes) : {},
133
82
  };
83
+ //TODO can use import meta mock object but need to update data structure of remote_scope
84
+ if (compiler.options && compiler.options.output) {
85
+ compiler.options.output.importMetaName = 'remoteContainerRegistry';
86
+ }
134
87
  const chunkFileName = compiler.options?.output?.chunkFilename;
135
88
  const uniqueName = compiler?.options?.output?.uniqueName || this._options.name;
136
- if (typeof chunkFileName === 'string') {
137
- const requiredSubstrings = [
138
- '[chunkhash]',
139
- '[contenthash]',
140
- '[fullHash]',
141
- uniqueName,
142
- ];
143
- if (
144
- //@ts-ignore
145
- !requiredSubstrings.some((substring) =>
146
- //@ts-ignore
147
- chunkFileName.includes(substring))) {
148
- const suffix = compiler.options.mode === 'development'
149
- ? `.[chunkhash].js`
150
- : `.[chunkhash].js`;
151
- compiler.options.output.chunkFilename = chunkFileName.replace('.js', suffix);
152
- }
89
+ if (typeof chunkFileName === 'string' && uniqueName && !chunkFileName.includes(uniqueName)) {
90
+ const suffix = `-[chunkhash].js`;
91
+ compiler.options.output.chunkFilename = chunkFileName.replace('.js', suffix);
153
92
  }
154
93
  new (this.context.ModuleFederationPlugin ||
155
94
  (webpack && webpack.container.ModuleFederationPlugin) ||
@@ -1 +1 @@
1
- {"version":3,"file":"NodeFederationPlugin.js","sourceRoot":"","sources":["../../../../../packages/node/src/plugins/NodeFederationPlugin.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAIb,sEAAkF;AAsBlF,6BAA6B;AAC7B,6CAA6C;AAC7C,qDAAqD;AACrD,yFAAyF;AACzF,yDAAyD;AACzD,wEAAwE;AACxE,mEAAmE;AACnE,wDAAwD;AAExD;;;;;;;GAOG;AACI,MAAM,YAAY,GAAG,CAAC,OAA4B,EAAE,EAAE,CAC3D,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE;IAC7C,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE;QACrC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;QAC3B,OAAO,GAAG,CAAC;KACZ;IACD,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,UAAU,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;QAChE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,WAAW,IAAA,yBAAiB,EAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAC3D,OAAO,GAAG,CAAC;KACZ;IACD,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IAC3B,OAAO,GAAG,CAAC;AACb,CAAC,EAAE,EAA4B,CAAC,CAAC;AAZtB,QAAA,YAAY,gBAYU;AACnC,yGAAyG;AAC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AC,OAAO,CAAC,MAAM,CAAC,cAAc,GAAG,yBAAyB,CAAC;SACpE;QAED,MAAM,aAAa,GAAG,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,aAAa,CAAC;QAC9D,MAAM,UAAU,GACd,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;QAE9D,IAAI,OAAO,aAAa,KAAK,QAAQ,IAAI,UAAU,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE;YAC1F,MAAM,MAAM,GAAG,iBAAiB,CAAC;YACjC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,aAAa,GAAG,aAAa,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;SAC9E;QAED,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,sBAAsB;YACtC,CAAC,OAAO,IAAI,OAAO,CAAC,SAAS,CAAC,sBAAsB,CAAC;YACrD,OAAO,CAAC,8CAA8C,CAAC,CAAC,CACxD,aAAa,CACd,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IACpB,CAAC;CACF;AAED,kBAAe,oBAAoB,CAAC"}
@@ -0,0 +1,10 @@
1
+ export default AutoPublicPathRuntimeModule;
2
+ declare class AutoPublicPathRuntimeModule extends RuntimeModule {
3
+ constructor(options: any);
4
+ options: any;
5
+ /**
6
+ * @returns {string} runtime code
7
+ */
8
+ generate(): string;
9
+ }
10
+ import { RuntimeModule } from "webpack";
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const webpack_1 = require("webpack");
4
+ const identifier_1 = require("webpack/lib/util/identifier");
5
+ class AutoPublicPathRuntimeModule extends webpack_1.RuntimeModule {
6
+ constructor(options) {
7
+ super("publicPath", webpack_1.RuntimeModule.STAGE_BASIC + 1);
8
+ this.options = options;
9
+ }
10
+ /**
11
+ * @returns {string} runtime code
12
+ */
13
+ generate() {
14
+ const { compilation } = this;
15
+ const { scriptType, path, publicPath, importMetaName, uniqueName } = compilation.outputOptions;
16
+ const getPath = () => {
17
+ return compilation.getPath(publicPath || "", {
18
+ hash: compilation.hash || "XXXX"
19
+ });
20
+ };
21
+ // If publicPath is not "auto", return the static value
22
+ if (publicPath !== "auto") {
23
+ return `${webpack_1.RuntimeGlobals.publicPath} = ${JSON.stringify(getPath())};`;
24
+ }
25
+ const chunkName = compilation.getPath(webpack_1.javascript.JavascriptModulesPlugin.getChunkFilenameTemplate(this.chunk, compilation.outputOptions), {
26
+ chunk: this.chunk,
27
+ contentHashType: "javascript"
28
+ });
29
+ const undoPath = (0, identifier_1.getUndoPath)(chunkName, path, false);
30
+ const ident = webpack_1.Template.toIdentifier(uniqueName);
31
+ return webpack_1.Template.asString([
32
+ "var scriptUrl;",
33
+ // its an esproxy so nesting into _config directly is not possible
34
+ "var remoteReg = globalThis.__remote_scope__._config;",
35
+ `
36
+ let remoteContainerRegistry = {
37
+ get url() {
38
+ return remoteReg[${JSON.stringify(ident)}];
39
+ }
40
+ };
41
+ `,
42
+ scriptType === "module"
43
+ ? webpack_1.Template.asString([
44
+ 'try {',
45
+ webpack_1.Template.indent([
46
+ `scriptUrl = new Function('return typeof ${importMetaName}.url === "string" ? ${importMetaName}.url : undefined;')();`,
47
+ ]),
48
+ '} catch (e) {',
49
+ webpack_1.Template.indent([
50
+ `if (typeof remoteContainerRegistry.url === "string") {`,
51
+ webpack_1.Template.indent('scriptUrl = remoteContainerRegistry.url;'),
52
+ '} else {',
53
+ webpack_1.Template.indent('scriptUrl = __filename;'),
54
+ '}',
55
+ ]),
56
+ '}'
57
+ ])
58
+ : webpack_1.Template.asString([
59
+ `if (${webpack_1.RuntimeGlobals.global}.importScripts) scriptUrl = ${webpack_1.RuntimeGlobals.global}.location + "";`,
60
+ `var document = ${webpack_1.RuntimeGlobals.global}.document;`,
61
+ "if (!scriptUrl && document) {",
62
+ webpack_1.Template.indent([
63
+ `if (document.currentScript)`,
64
+ webpack_1.Template.indent(`scriptUrl = document.currentScript.src`),
65
+ "if (!scriptUrl) {",
66
+ webpack_1.Template.indent([
67
+ 'var scripts = document.getElementsByTagName("script");',
68
+ "if(scripts.length) scriptUrl = scripts[scripts.length - 1].src"
69
+ ]),
70
+ "}"
71
+ ]),
72
+ "}",
73
+ ]),
74
+ "console.log('scriptUrl', scriptUrl);",
75
+ "// When supporting server environments where an automatic publicPath is not supported, you must specify an output.publicPath manually via configuration",
76
+ '// or pass an empty string ("") and set the __webpack_public_path__ variable from your code to use your own logic.',
77
+ 'if (!scriptUrl) throw new Error("Unable to calculate automatic public path");',
78
+ 'scriptUrl = scriptUrl.replace(/#.*$/, "").replace(/\\?.*$/, "").replace(/\\/[^\\/]+$/, "/");',
79
+ !undoPath
80
+ ? `${webpack_1.RuntimeGlobals.publicPath} = scriptUrl;`
81
+ : `${webpack_1.RuntimeGlobals.publicPath} = scriptUrl + ${JSON.stringify(undoPath)};`
82
+ ]);
83
+ }
84
+ }
85
+ exports.default = AutoPublicPathRuntimeModule;
86
+ //# sourceMappingURL=RemotePublicPathRuntimeModule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RemotePublicPathRuntimeModule.js","sourceRoot":"","sources":["../../../../../packages/node/src/plugins/RemotePublicPathRuntimeModule.js"],"names":[],"mappings":";;AAAA,qCAA8E;AAC9E,4DAA0D;AAE1D,MAAM,2BAA4B,SAAQ,uBAAa;IACrD,YAAY,OAAO;QACjB,KAAK,CAAC,YAAY,EAAE,uBAAa,CAAC,WAAW,GAAG,CAAC,CAAC,CAAC;QACnD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IACxB,CAAC;IAED;;OAEG;IACH,QAAQ;QACN,MAAM,EAAE,WAAW,EAAE,GAAG,IAAI,CAAC;QAC7B,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,cAAc,EAAE,UAAU,EAAE,GAAG,WAAW,CAAC,aAAa,CAAC;QAC/F,M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BACF,CAAC;gBACJ,CAAC,CAAC,kBAAQ,CAAC,QAAQ,CAAC;oBAClB,OAAO,wBAAc,CAAC,MAAM,+BAA+B,wBAAc,CAAC,MAAM,iBAAiB;oBACjG,kBAAkB,wBAAc,CAAC,MAAM,YAAY;oBACnD,+BAA+B;oBAC/B,kBAAQ,CAAC,MAAM,CAAC;wBACd,6BAA6B;wBAC7B,kBAAQ,CAAC,MAAM,CAAC,wCAAwC,CAAC;wBACzD,mBAAmB;wBACnB,kBAAQ,CAAC,MAAM,CAAC;4BACd,wDAAwD;4BACxD,gEAAgE;yBACjE,CAAC;wBACF,GAAG;qBACJ,CAAC;oBACF,GAAG;iBACJ,CAAC;YACJ,sCAAsC;YACtC,yJAAyJ;YACzJ,oHAAoH;YACpH,+EAA+E;YAC/E,8FAA8F;YAC9F,CAAC,QAAQ;gBACP,CAAC,CAAC,GAAG,wBAAc,CAAC,UAAU,eAAe;gBAC7C,CAAC,CAAC,GAAG,wBAAc,CAAC,UAAU,kBAAkB,IAAI,CAAC,SAAS,CAC5D,QAAQ,CACT,GAAG;SACP,CAAC,CAAC;IACL,CAAC;CACF;AAED,kBAAe,2BAA2B,CAAC"}
@@ -20,16 +20,15 @@ class StreamingTargetPlugin {
20
20
  * @param {Compiler} compiler - The webpack compiler
21
21
  */
22
22
  apply(compiler) {
23
- if (compiler.options.target) {
24
- console.warn(`target should be set to false while using NodeSoftwareStreamRuntime plugin, actual target: ${compiler.options.target}`);
25
- console.info('Setting target to false');
26
- compiler.options.target = false;
27
- }
28
23
  // When used with Next.js, context is needed to use Next.js webpack
29
24
  const { webpack } = compiler;
30
- // This will enable CommonJsChunkFormatPlugin
31
25
  compiler.options.output.chunkFormat = 'commonjs';
32
- // This will force async chunk loading
26
+ if (compiler.options.output.enabledLibraryTypes === undefined) {
27
+ compiler.options.output.enabledLibraryTypes = ['commonjs-module'];
28
+ }
29
+ else {
30
+ compiler.options.output.enabledLibraryTypes.push('commonjs-module');
31
+ }
33
32
  compiler.options.output.chunkLoading = 'async-node';
34
33
  // Disable default config
35
34
  // FIXME: enabledChunkLoadingTypes is of type 'string[] | undefined'
@@ -1 +1 @@
1
- {"version":3,"file":"StreamingTargetPlugin.js","sourceRoot":"","sources":["../../../../../packages/node/src/plugins/StreamingTargetPlugin.ts"],"names":[],"mappings":";;;;;AAGA,8FAAsE;AAkBtE;;GAEG;AACH,MAAM,qBAAqB;IAGzB;;;OAGG;IACH,YAAY,OAA+B;QACzC,IAAI,CAAC,OAAO,GAAG,OAAO,IAAI,EAAE,CAAC;IAC/B,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,QAAkB;QACtB,IAAI,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE;YAC3B,OAAO,CAAC,IAAI,CACV,8FAA8F,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,CACxH,CAAC;YACF,OAAO,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;YACxC,QAAQ,CAAC,OAAO,CAAC,MAAM,GAAG,KAAK,CAAC;SACjC;QAED,mEAAmE;QACnE,MAAM,EAAE,OAAO,EAAE,GAAG,QAAQ,CAAC;QAE7B,6CAA6C;QAC7C,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,WAAW,GAAG,UAAU,CAAC;QACjD,sCAAsC;QACtC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,YAAY,GAAG,YAAY,CAAC;QAEpD,yBAAyB;QACzB,oEAAoE;QACpE,4DAA4D;QAC5D,8EAA8E;QAC9E,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,wBAAwB,GAAG,EAAE,CAAC;QACtD,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,WAAW,GAAG;YACpC,GAAG,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,WAAW;YACtC,aAAa,EAAE,IAAI;SACpB,CAAC;QAEF,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,qBAAqB;YACvC,OAAO,CAAC,wCAAwC,CAAC,CAAC,CA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
30
30
  const { webpack } = compiler;
31
31
  if (isServer ||
32
32
  compiler.options.name === 'server' ||
33
- compiler.options.target === 'node') {
33
+ compiler.options.target === 'node' ||
34
+ compiler.options.target === 'async-node') {
34
35
  new NodeFederationPlugin_1.default(options, this.context).apply(compiler);
35
36
  new StreamingTargetPlugin_1.default({ ...options, debug }).apply(compiler);
36
37
  }
@@ -1 +1 @@
1
- {"version":3,"file":"UniversalFederationPlugin.js","sourceRoot":"","sources":["../../../../../packages/node/src/plugins/UniversalFederationPlugin.ts"],"names":[],"mappings":";;;;;AAAA;;GAEG;AACH,oFAA4D;AAC5D,kFAA0D;AAwB1D;;GAEG;AACH,MAAM,yBAAyB;IAI7B;;;;OAIG;IACH,YAAY,OAA8B,EAAE,OAA8B;QACxE,IAAI,CAAC,QAAQ,GAAG,OAAO,IAAK,EAA4B,CAAC;QACzD,IAAI,CAAC,OAAO,GAAG,OAAO,IAAK,EAA4B,CAAC;IAC1D,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,QAAkB;QACtB,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,OAAO,EAAE,GAAG,IAAI,CAAC,QAAQ,CAAC;QACtD,MAAM,EAAE,OAAO,EAAE,GAAG,QAAQ,CAAC;QAE7B,IACE,QAAQ;YACR,QAAQ,CAAC,OAAO,CAAC,IAAI,KAAK,QAAQ;YAClC,QAAQ,CAAC,OAAO,CAAC,MAAM,KAAK,MAAM,EAClC;YACA,IAAI,8BAAoB,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;YAChE,IAAI,+BAAqB,CAAC,EAAE,GAAG,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;SAClE;aAAM;YACL,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,sBAAsB;gBACtC,CAAC,OAAO,IAAI,OAAO,CAAC,SAAS,CAAC,sBAAsB,CAAC;gBACrD,OAAO,CAAC,8CAA8C,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,KAAK,CACvE,QAAQ,CACT,CAAC;SACH;IACH,CAAC;CACF;AAED;;GAEG;AACH,kBAAe,yBAAyB,CAAC"}
1
+ {"version":3,"file":"UniversalFederationPlugin.js","sourceRoot":"","sources":["../../../../../packages/node/src/plugins/UniversalFederationPlugin.ts"],"names":[],"mappings":";;;;;AAAA;;GAEG;AACH,oFAA4D;AAC5D,kFAA0D;AAwB1D;;GAEG;AACH,MAAM,yBAAyB;IAI7B;;;;OAIG;IACH,YAAY,OAA8B,EAAE,OAA8B;QACxE,IAAI,CAAC,QAAQ,GAAG,OAAO,IAAK,EAA4B,CAAC;QACzD,IAAI,CAAC,OAAO,GAAG,OAAO,IAAK,EAA4B,CAAC;IAC1D,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,QAAkB;QACtB,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,OAAO,EAAE,GAAG,IAAI,CAAC,QAAQ,CAAC;QACtD,MAAM,EAAE,OAAO,EAAE,GAAG,QAAQ,CAAC;QAE7B,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;YACA,IAAI,8BAAoB,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;YAChE,IAAI,+BAAqB,CAAC,EAAE,GAAG,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;SAClE;aAAM;YACL,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,sBAAsB;gBACtC,CAAC,OAAO,IAAI,OAAO,CAAC,SAAS,CAAC,sBAAsB,CAAC;gBACrD,OAAO,CAAC,8CAA8C,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,KAAK,CACvE,QAAQ,CACT,CAAC;SACH;IACH,CAAC;CACF;AAED;;GAEG;AACH,kBAAe,yBAAyB,CAAC"}
@@ -0,0 +1,50 @@
1
+ import { 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<string | number>;
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;