@module-federation/node 0.6.7 → 0.8.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.
- package/CHANGELOG.md +21 -0
- package/package.json +4 -3
- package/src/plugins/NodeFederationPlugin.d.ts +3 -0
- package/src/plugins/NodeFederationPlugin.js +89 -66
- package/src/plugins/NodeFederationPlugin.js.map +1 -1
- package/src/plugins/loadScript.d.ts +1 -1
- package/src/plugins/loadScript.js +3 -3
- package/src/utils/flush-chunks.js.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,27 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
# [0.8.0](https://github.com/module-federation/nextjs-mf/compare/node-0.7.0...node-0.8.0) (2022-10-26)
|
|
6
|
+
|
|
7
|
+
### Dependency Updates
|
|
8
|
+
|
|
9
|
+
* `utils` updated to version `0.4.0`
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* Automatic Async boundary loader ([#330](https://github.com/module-federation/nextjs-mf/issues/330)) ([7e3c08c](https://github.com/module-federation/nextjs-mf/commit/7e3c08cf7835c0407bdce7ed6865b864153074a4))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# [0.7.0](https://github.com/module-federation/nextjs-mf/compare/node-0.6.7...node-0.7.0) (2022-10-19)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
* consolidate promise factories in server ([#297](https://github.com/module-federation/nextjs-mf/issues/297)) ([55387ee](https://github.com/module-federation/nextjs-mf/commit/55387eeb952fb3164900d73ddcb0007f644c766f))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
5
26
|
## [0.6.7](https://github.com/module-federation/nextjs-mf/compare/node-0.6.6...node-0.6.7) (2022-10-18)
|
|
6
27
|
|
|
7
28
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"public": true,
|
|
3
3
|
"name": "@module-federation/node",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.8.0",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "src/index.js",
|
|
7
7
|
"exports": {
|
|
@@ -33,9 +33,10 @@
|
|
|
33
33
|
"license": "MIT",
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"node-fetch": "^2.6.7",
|
|
36
|
-
"
|
|
36
|
+
"encoding": "^0.1.13",
|
|
37
|
+
"@module-federation/utilities": "0.4.0",
|
|
37
38
|
"react": "18.2.0",
|
|
38
|
-
"next": "
|
|
39
|
+
"next": "13.0.0",
|
|
39
40
|
"tslib": "^2.3.0"
|
|
40
41
|
},
|
|
41
42
|
"peerDependencies": {
|
|
@@ -6,6 +6,9 @@ interface NodeFederationOptions extends ModuleFederationPluginOptions {
|
|
|
6
6
|
interface Context {
|
|
7
7
|
ModuleFederationPlugin?: typeof container.ModuleFederationPlugin;
|
|
8
8
|
}
|
|
9
|
+
export declare const parseRemotes: (remotes: Record<string, any>) => Record<string, string>;
|
|
10
|
+
export declare const generateRemoteTemplate: (url: string, global: any) => string;
|
|
11
|
+
export declare const parseRemoteSyntax: (remote: any) => any;
|
|
9
12
|
declare class NodeFederationPlugin {
|
|
10
13
|
private options;
|
|
11
14
|
private context;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseRemoteSyntax = exports.generateRemoteTemplate = exports.parseRemotes = void 0;
|
|
4
|
+
const utilities_1 = require("@module-federation/utilities");
|
|
3
5
|
// possible remote evaluators
|
|
4
6
|
// this depends on the chunk format selected.
|
|
5
7
|
// commonjs2 - it think, is lazily evaluated - beware
|
|
@@ -81,19 +83,20 @@ const executeLoadTemplate = `
|
|
|
81
83
|
})
|
|
82
84
|
}
|
|
83
85
|
`;
|
|
84
|
-
|
|
85
|
-
return Object.entries(
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
acc.buildTime[name] = config;
|
|
86
|
+
const parseRemotes = (remotes) => {
|
|
87
|
+
return Object.entries(remotes).reduce((acc, remote) => {
|
|
88
|
+
if (!remote[1].startsWith('promise ') && remote[1].includes('@')) {
|
|
89
|
+
acc[remote[0]] = 'promise ' + (0, exports.parseRemoteSyntax)(remote[1]);
|
|
89
90
|
return acc;
|
|
90
91
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
92
|
+
acc[remote[0]] = remote[1];
|
|
93
|
+
return acc;
|
|
94
|
+
}, {});
|
|
95
|
+
};
|
|
96
|
+
exports.parseRemotes = parseRemotes;
|
|
97
|
+
// server template to convert remote into promise new promise and use require.loadChunk to load the chunk
|
|
98
|
+
const generateRemoteTemplate = (url, global) => {
|
|
99
|
+
return `new Promise(function (resolve, reject) {
|
|
97
100
|
if(!global.__remote_scope__) {
|
|
98
101
|
// create a global scope for container, similar to how remotes are set on window in the browser
|
|
99
102
|
global.__remote_scope__ = {
|
|
@@ -101,83 +104,104 @@ function buildRemotes(mfConf, webpack) {
|
|
|
101
104
|
}
|
|
102
105
|
}
|
|
103
106
|
|
|
107
|
+
if (typeof global.__remote_scope__[${JSON.stringify(global)}] !== 'undefined') return resolve(global.__remote_scope__[${JSON.stringify(global)}]);
|
|
104
108
|
global.__remote_scope__._config[${JSON.stringify(global)}] = ${JSON.stringify(url)};
|
|
109
|
+
var __webpack_error__ = new Error();
|
|
105
110
|
|
|
106
|
-
var __webpack_error__ = new Error();
|
|
107
|
-
if (typeof global.__remote_scope__[${JSON.stringify(global)}] !== 'undefined') return resolve(global.__remote_scope__[${JSON.stringify(global)}]);
|
|
108
111
|
__webpack_require__.l(
|
|
109
112
|
${JSON.stringify(url)},
|
|
110
113
|
function (event) {
|
|
111
114
|
if (typeof global.__remote_scope__[${JSON.stringify(global)}] !== 'undefined') return resolve(global.__remote_scope__[${JSON.stringify(global)}]);
|
|
112
|
-
|
|
113
|
-
__webpack_error__.message =
|
|
114
|
-
'Loading script failed.\\n(' + event.message + ': ' + realSrc + ')';
|
|
115
|
+
var realSrc = event && event.target && event.target.src;
|
|
116
|
+
__webpack_error__.message = 'Loading script failed.\\n(' + event.message + ': ' + realSrc + ')';
|
|
115
117
|
__webpack_error__.name = 'ScriptExternalLoadError';
|
|
116
118
|
__webpack_error__.stack = event.stack;
|
|
117
119
|
reject(__webpack_error__);
|
|
118
120
|
},
|
|
119
121
|
${JSON.stringify(global)},
|
|
120
122
|
);
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
return {
|
|
125
|
-
fake: true,
|
|
126
|
-
get:(arg)=>{
|
|
127
|
-
console.log('faking', arg,'module on', ${JSON.stringify(global)});
|
|
123
|
+
}).catch((e)=> {
|
|
124
|
+
console.error(${JSON.stringify(global)}, 'is offline, returning fake remote');
|
|
125
|
+
console.error(e);
|
|
128
126
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
init:()=>{}
|
|
134
|
-
}
|
|
127
|
+
return {
|
|
128
|
+
fake: true,
|
|
129
|
+
get: (arg) => {
|
|
130
|
+
console.log('faking', arg, 'module on', ${JSON.stringify(global)});
|
|
135
131
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
132
|
+
return Promise.resolve(() => {
|
|
133
|
+
return () => null
|
|
134
|
+
});
|
|
135
|
+
},
|
|
136
|
+
init: () => {
|
|
139
137
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
138
|
+
}
|
|
139
|
+
}).then(function (remote) {
|
|
140
|
+
if(remote.fake) {
|
|
141
|
+
return remote;
|
|
142
|
+
}
|
|
143
|
+
const proxy = {
|
|
143
144
|
get: (arg)=>{
|
|
144
|
-
if(!global.__remote_scope__[${JSON.stringify(global)}].__initialized) {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}
|
|
145
|
+
// if(!global.__remote_scope__[${JSON.stringify(global)}].__initialized) {
|
|
146
|
+
// try {
|
|
147
|
+
// global.__remote_scope__[${JSON.stringify(global)}].__initialized = true;
|
|
148
|
+
// proxy.init(__webpack_require__.S.default);
|
|
149
|
+
// } catch(e) {}
|
|
150
|
+
// }
|
|
150
151
|
return remote.get(arg).then((f)=>{
|
|
151
152
|
const m = f();
|
|
152
153
|
return ()=>new Proxy(m, {
|
|
153
154
|
get: (target, prop)=>{
|
|
154
|
-
|
|
155
|
+
if(global.usedChunks) global.usedChunks.add(${JSON.stringify(global)} + "->" + arg);
|
|
155
156
|
return target[prop];
|
|
156
157
|
}
|
|
157
158
|
})
|
|
158
159
|
})
|
|
159
160
|
},
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
161
|
+
init: function(shareScope) {
|
|
162
|
+
const handler = {
|
|
163
|
+
get(target, prop) {
|
|
164
|
+
if (target[prop]) {
|
|
165
|
+
Object.values(target[prop]).forEach(function(o) {
|
|
166
|
+
if(o.from === '_N_E') {
|
|
167
|
+
o.loaded = 1
|
|
168
|
+
}
|
|
169
|
+
})
|
|
170
|
+
}
|
|
171
|
+
return target[prop]
|
|
172
|
+
},
|
|
173
|
+
set(target, property, value) {
|
|
174
|
+
if(global.usedChunks) global.usedChunks.add(${JSON.stringify(global)} + "->" + property);
|
|
175
|
+
if (target[property]) {
|
|
176
|
+
return target[property]
|
|
168
177
|
}
|
|
169
|
-
|
|
178
|
+
target[property] = value
|
|
179
|
+
return true
|
|
180
|
+
}
|
|
170
181
|
}
|
|
171
|
-
|
|
182
|
+
try {
|
|
183
|
+
global.__remote_scope__[${JSON.stringify(global)}].init(new Proxy(shareScope, handler))
|
|
184
|
+
} catch (e) {
|
|
172
185
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
}
|
|
180
|
-
|
|
186
|
+
}
|
|
187
|
+
global.__remote_scope__[${JSON.stringify(global)}].__initialized = true
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
if (!global.__remote_scope__[${JSON.stringify(global)}].__initialized) {
|
|
191
|
+
proxy.init(__webpack_require__.S.default)
|
|
192
|
+
}
|
|
193
|
+
return proxy
|
|
194
|
+
})`;
|
|
195
|
+
};
|
|
196
|
+
exports.generateRemoteTemplate = generateRemoteTemplate;
|
|
197
|
+
const parseRemoteSyntax = (remote) => {
|
|
198
|
+
if (typeof remote === 'string' && remote.includes('@')) {
|
|
199
|
+
const [url, global] = (0, utilities_1.extractUrlAndGlobal)(remote);
|
|
200
|
+
return (0, exports.generateRemoteTemplate)(url, global);
|
|
201
|
+
}
|
|
202
|
+
return remote;
|
|
203
|
+
};
|
|
204
|
+
exports.parseRemoteSyntax = parseRemoteSyntax;
|
|
181
205
|
class NodeFederationPlugin {
|
|
182
206
|
constructor({ experiments, ...options }, context) {
|
|
183
207
|
this.options = options || {};
|
|
@@ -187,17 +211,16 @@ class NodeFederationPlugin {
|
|
|
187
211
|
apply(compiler) {
|
|
188
212
|
// When used with Next.js, context is needed to use Next.js webpack
|
|
189
213
|
const { webpack } = compiler;
|
|
190
|
-
const
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
};
|
|
214
|
+
// const defs = {
|
|
215
|
+
// 'process.env.REMOTES': runtime,
|
|
216
|
+
// 'process.env.REMOTE_CONFIG': hot,
|
|
217
|
+
// };
|
|
195
218
|
// new ((webpack && webpack.DefinePlugin) || require("webpack").DefinePlugin)(
|
|
196
219
|
// defs
|
|
197
220
|
// ).apply(compiler);
|
|
198
221
|
const pluginOptions = {
|
|
199
222
|
...this.options,
|
|
200
|
-
remotes:
|
|
223
|
+
remotes: (0, exports.parseRemotes)(this.options.remotes || {}),
|
|
201
224
|
};
|
|
202
225
|
new (this.context.ModuleFederationPlugin ||
|
|
203
226
|
(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
|
|
1
|
+
{"version":3,"file":"NodeFederationPlugin.js","sourceRoot":"","sources":["../../../../../packages/node/src/plugins/NodeFederationPlugin.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAIb,4DAAiE;AAYjE,6BAA6B;AAC7B,6CAA6C;AAC7C,qDAAqD;AACrD,yFAAyF;AACzF,yDAAyD;AACzD,wEAAwE;AACxE,mEAAmE;AACnE,wDAAwD;AAExD,eAAe;AACf,oFAAoF;AACpF,iHAAiH;AACjH,oGAAoG;AACpG,0FAA0F;AAC1F,qFAAqF;AACrF,uGAAuG;AACvG,wCAAwC;AACxC,uGAAuG;AACvG,uHAAuH;AACvH,+HAA+H;AAE/H,uDAAuD;AACvD,mEAAmE;AACnE,mEAAmE;AACnE,kIAAkI;AAClI,MAAM,mBAAmB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyD3B,CAAC;AAEK,MAAM,YAAY,GAAG,CAAC,OAA4B,EAAE,EAAE;IAC3D,OAAO,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE;QACpD,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,UAAU,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;YAChE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,UAAU,GAAG,IAAA,yBAAiB,EAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;YAC3D,OAAO,GAAG,CAA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const _default: "\n function loadScript(url, cb, chunkID) {\n var url;\n var cb = arguments[arguments.length - 1];\n if (typeof cb !== \"function\") {\n throw new Error(\"last argument should be a function\");\n }\n if (arguments.length === 2) {\n url = arguments[0];\n } else if (arguments.length === 3) {\n url = new URL(arguments[1], arguments[0]).toString();\n } else {\n throw new Error(\"invalid number of arguments\");\n }\n if (global.webpackChunkLoad) {\n global.webpackChunkLoad(url).then(function (resp) {\n return resp.text();\n }).then(function (rawData) {\n cb(null, rawData);\n }).catch(function (err) {\n console.error('Federated Chunk load failed', error);\n return cb(error)\n });\n } else {\n //TODO https support\n let request = (url.startsWith('https') ? require('https') : require('http')).get(url, function (resp) {\n if (resp.statusCode === 200) {\n let rawData = '';\n resp.setEncoding('utf8');\n resp.on('data', chunk => {\n rawData += chunk;\n });\n resp.on('end', () => {\n cb(null, rawData);\n });\n } else {\n cb(resp);\n }\n });\n request.on('error', error => {\n console.error('Federated Chunk load failed', error);\n return cb(error)\n });\n }\n }\n";
|
|
6
6
|
export default _default;
|
|
7
|
-
export declare const executeLoadTemplate = "\n function executeLoad(url, callback, name) {\n if(!name) {\n throw new Error('__webpack_require__.l name is required for ' + url);\n }\n
|
|
7
|
+
export declare const executeLoadTemplate = "\n function executeLoad(url, callback, name) {\n if(!name) {\n throw new Error('__webpack_require__.l name is required for ' + url);\n }\n if (typeof global.__remote_scope__[name] !== 'undefined') return callback(global.__remote_scope__[name]);\n const vm = require('vm');\n (global.webpackChunkLoad || global.fetch || require(\"node-fetch\"))(url).then(function (res) {\n return res.text();\n }).then(function (scriptContent) {\n try {\n const vmContext = {exports, require, module, global, __filename, __dirname, URL,console,process,Buffer, ...global};\n const remote = vm.runInNewContext(scriptContent + '\\nmodule.exports', vmContext, {filename: 'node-federation-loader-' + name + '.vm'});\n global.__remote_scope__[name] = remote[name] || remote;\n global.__remote_scope__._config[name] = url;\n callback(global.__remote_scope__[name])\n } catch (e) {\n console.error('executeLoad hit catch block');\n e.target = {src: url};\n callback(e);\n }\n }).catch((e) => {\n e.target = {src: url};\n callback(e);\n });\n }\n";
|
|
@@ -59,19 +59,19 @@ exports.executeLoadTemplate = `
|
|
|
59
59
|
if(!name) {
|
|
60
60
|
throw new Error('__webpack_require__.l name is required for ' + url);
|
|
61
61
|
}
|
|
62
|
-
console.log("server require.l remote load", url);
|
|
63
62
|
if (typeof global.__remote_scope__[name] !== 'undefined') return callback(global.__remote_scope__[name]);
|
|
64
63
|
const vm = require('vm');
|
|
65
64
|
(global.webpackChunkLoad || global.fetch || require("node-fetch"))(url).then(function (res) {
|
|
66
65
|
return res.text();
|
|
67
66
|
}).then(function (scriptContent) {
|
|
68
67
|
try {
|
|
69
|
-
const vmContext = {exports, require, module, global, __filename, __dirname, URL,
|
|
68
|
+
const vmContext = {exports, require, module, global, __filename, __dirname, URL,console,process,Buffer, ...global};
|
|
70
69
|
const remote = vm.runInNewContext(scriptContent + '\\nmodule.exports', vmContext, {filename: 'node-federation-loader-' + name + '.vm'});
|
|
71
70
|
global.__remote_scope__[name] = remote[name] || remote;
|
|
72
|
-
global.__remote_scope__
|
|
71
|
+
global.__remote_scope__._config[name] = url;
|
|
73
72
|
callback(global.__remote_scope__[name])
|
|
74
73
|
} catch (e) {
|
|
74
|
+
console.error('executeLoad hit catch block');
|
|
75
75
|
e.target = {src: url};
|
|
76
76
|
callback(e);
|
|
77
77
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flush-chunks.js","sourceRoot":"","sources":["../../../../../packages/node/src/utils/flush-chunks.js"],"names":[],"mappings":";;;AAAa,QAAA,UAAU,GAAG,IAAI,GAAG,EAAE,CAAA;AACnC,MAAM,CAAC,UAAU,GAAG,kBAAU,CAAA;AAEvB,MAAM,WAAW,GAAG,KAAK,IAAI,EAAE;IACpC,MAAM,UAAU,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,kBAAU,CAAC,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;Q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