@module-federation/node 0.11.1 → 0.12.1
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
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.12.1](https://github.com/module-federation/nextjs-mf/compare/node-0.12.0...node-0.12.1) (2023-03-24)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* enable chunk hashing all the time ([#669](https://github.com/module-federation/nextjs-mf/issues/669)) ([7417bc2](https://github.com/module-federation/nextjs-mf/commit/7417bc2acead56aa066a6b14ddb57a2474ea72e0))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# [0.12.0](https://github.com/module-federation/nextjs-mf/compare/node-0.11.1...node-0.12.0) (2023-03-14)
|
|
15
|
+
|
|
16
|
+
### Dependency Updates
|
|
17
|
+
|
|
18
|
+
* `utils` updated to version `1.4.0`
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
* Medusa Support in NextFederationPlugin ([#609](https://github.com/module-federation/nextjs-mf/issues/609)) ([0bbba38](https://github.com/module-federation/nextjs-mf/commit/0bbba384c45b7d149b7a6be2dfbe9851b541b528)), closes [#606](https://github.com/module-federation/nextjs-mf/issues/606)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
5
26
|
## [0.11.1](https://github.com/module-federation/nextjs-mf/compare/node-0.11.0...node-0.11.1) (2023-02-09)
|
|
6
27
|
|
|
7
28
|
|
package/README.md
CHANGED
|
@@ -83,10 +83,7 @@ The `NodeFederationPlugin` follows the same API as the [Module Federation Plugin
|
|
|
83
83
|
An example configuration is presented below:
|
|
84
84
|
|
|
85
85
|
```js
|
|
86
|
-
const {
|
|
87
|
-
NodeFederationPlugin,
|
|
88
|
-
StreamingTargetPlugin,
|
|
89
|
-
} = require('@module-federation/node');
|
|
86
|
+
const { NodeFederationPlugin, StreamingTargetPlugin } = require('@module-federation/node');
|
|
90
87
|
|
|
91
88
|
const config = {
|
|
92
89
|
target: isServer ? false : 'web',
|
|
@@ -141,9 +138,7 @@ Express has its own route stack, so reloading require cache will not be enough t
|
|
|
141
138
|
const app = express();
|
|
142
139
|
|
|
143
140
|
global.clearRoutes = () => {
|
|
144
|
-
app._router.stack = app._router.stack.filter(
|
|
145
|
-
(k) => !(k && k.route && k.route.path)
|
|
146
|
-
);
|
|
141
|
+
app._router.stack = app._router.stack.filter((k) => !(k && k.route && k.route.path));
|
|
147
142
|
};
|
|
148
143
|
|
|
149
144
|
// in some other file (within the scope of webpack build)
|
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.12.1",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "src/index.js",
|
|
7
7
|
"exports": {
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"encoding": "0.1.13",
|
|
36
36
|
"node-fetch": "2.6.7",
|
|
37
|
-
"@module-federation/utilities": "1.
|
|
37
|
+
"@module-federation/utilities": "1.4.0"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
40
|
"next": "^12||^13",
|
|
@@ -10,6 +10,13 @@ const utilities_1 = require("@module-federation/utilities");
|
|
|
10
10
|
// const remote = eval('let exports = {};' + scriptContent + 'exports');
|
|
11
11
|
// commonjs-module, ideal since it returns a commonjs module format
|
|
12
12
|
// const remote = eval(scriptContent + 'module.exports')
|
|
13
|
+
/*
|
|
14
|
+
This code is doing the following It 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 means that this is probably
|
|
18
|
+
a github repo
|
|
19
|
+
*/
|
|
13
20
|
const parseRemotes = (remotes) => Object.entries(remotes).reduce((acc, remote) => {
|
|
14
21
|
if (remote[1].startsWith('internal ')) {
|
|
15
22
|
acc[remote[0]] = remote[1];
|
|
@@ -117,6 +124,13 @@ const generateRemoteTemplate = (url, global) => `new Promise(function (resolve,
|
|
|
117
124
|
return proxy
|
|
118
125
|
})`;
|
|
119
126
|
exports.generateRemoteTemplate = generateRemoteTemplate;
|
|
127
|
+
/*
|
|
128
|
+
This code is taking the remote string and splitting it into two parts The first
|
|
129
|
+
part of the split is going to be a url which will be used in generate Remote Template
|
|
130
|
+
function The second part of the split is going to be a global variable name which
|
|
131
|
+
will also be used in generate Remote Template function If there\'s no global variable
|
|
132
|
+
name then we\'ll use default as default value for that parameter
|
|
133
|
+
*/
|
|
120
134
|
const parseRemoteSyntax = (remote) => {
|
|
121
135
|
if (typeof remote === 'string' && remote.includes('@')) {
|
|
122
136
|
const [url, global] = (0, utilities_1.extractUrlAndGlobal)(remote);
|
|
@@ -145,6 +159,12 @@ class NodeFederationPlugin {
|
|
|
145
159
|
...this._options,
|
|
146
160
|
remotes: (0, exports.parseRemotes)(this._options.remotes || {}),
|
|
147
161
|
};
|
|
162
|
+
const chunkFileName = compiler.options?.output?.chunkFilename;
|
|
163
|
+
if (typeof chunkFileName === 'string' &&
|
|
164
|
+
!chunkFileName.includes('[hash]') &&
|
|
165
|
+
!chunkFileName.includes('[contenthash]')) {
|
|
166
|
+
compiler.options.output.chunkFilename = chunkFileName.replace('.js', '.[contenthash].js');
|
|
167
|
+
}
|
|
148
168
|
new (this.context.ModuleFederationPlugin ||
|
|
149
169
|
(webpack && webpack.container.ModuleFederationPlugin) ||
|
|
150
170
|
require('webpack/lib/container/ModuleFederationPlugin'))(pluginOptions).apply(compiler);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NodeFederationPlugin.js","sourceRoot":"","sources":["../../../../../packages/node/src/plugins/NodeFederationPlugin.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAIb,4DAAmE;AAWnE,6BAA6B;AAC7B,6CAA6C;AAC7C,qDAAqD;AACrD,yFAAyF;AACzF,yDAAyD;AACzD,wEAAwE;AACxE,mEAAmE;AACnE,wDAAwD;
|
|
1
|
+
{"version":3,"file":"NodeFederationPlugin.js","sourceRoot":"","sources":["../../../../../packages/node/src/plugins/NodeFederationPlugin.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAIb,4DAAmE;AAWnE,6BAA6B;AAC7B,6CAA6C;AAC7C,qDAAqD;AACrD,yFAAyF;AACzF,yDAAyD;AACzD,wEAAwE;AACxE,mEAAmE;AACnE,wDAAwD;AAExD;;;;;;IAMI;AACG,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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C,CAAC;IACpB,CAAC;CACF;AAED,kBAAe,oBAAoB,CAAC"}
|
package/src/utils/hot-reload.js
CHANGED
|
@@ -4,6 +4,12 @@ exports.revalidate = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const hashmap = {};
|
|
6
6
|
const crypto_1 = tslib_1.__importDefault(require("crypto"));
|
|
7
|
+
/*
|
|
8
|
+
This code is doing two things First it checks if there are any fake remotes in the
|
|
9
|
+
global scope If so then we need to reload the server because a remote has changed
|
|
10
|
+
and needs to be fetched again Second it checks for each remote that was loaded by
|
|
11
|
+
webpack whether its hash has changed since last time or not
|
|
12
|
+
*/
|
|
7
13
|
const revalidate = () => {
|
|
8
14
|
if (global.__remote_scope__) {
|
|
9
15
|
const remoteScope = global.__remote_scope__;
|
|
@@ -88,6 +94,12 @@ const revalidate = () => {
|
|
|
88
94
|
return Promise.resolve(false);
|
|
89
95
|
};
|
|
90
96
|
exports.revalidate = revalidate;
|
|
97
|
+
/*
|
|
98
|
+
This code is importing the nodefetch module and assigning it to a variable named
|
|
99
|
+
node Fetch The code then checks if there\'s an existing global object called webpack
|
|
100
|
+
Chunk Load which is used by webpack If so we use that instead of nodefetch This
|
|
101
|
+
allows us to use fetch in our tests without having to mock out nodefetch
|
|
102
|
+
*/
|
|
91
103
|
function getFetchModule() {
|
|
92
104
|
const loadedModule = global.webpackChunkLoad || global.fetch;
|
|
93
105
|
if (loadedModule) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hot-reload.js","sourceRoot":"","sources":["../../../../../packages/node/src/utils/hot-reload.ts"],"names":[],"mappings":";;;;AAAA,MAAM,OAAO,GAAG,EAA4B,CAAC;AAC7C,4DAA4B;
|
|
1
|
+
{"version":3,"file":"hot-reload.js","sourceRoot":"","sources":["../../../../../packages/node/src/utils/hot-reload.ts"],"names":[],"mappings":";;;;AAAA,MAAM,OAAO,GAAG,EAA4B,CAAC;AAC7C,4DAA4B;AAE5B;;;;;IAKI;AACG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