@module-federation/node 0.0.0-feat-node-support-1702694175665
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/jest.config.d.ts +11 -0
- package/jest.config.js +19 -0
- package/jest.config.js.map +1 -0
- package/package.json +66 -0
- package/src/filesystem/stratagies.d.ts +18 -0
- package/src/filesystem/stratagies.js +124 -0
- package/src/filesystem/stratagies.js.map +1 -0
- package/src/index.d.ts +5 -0
- package/src/index.js +17 -0
- package/src/index.js.map +1 -0
- package/src/plugins/AutomaticPublicPathPlugin.d.ts +9 -0
- package/src/plugins/AutomaticPublicPathPlugin.js +38 -0
- package/src/plugins/AutomaticPublicPathPlugin.js.map +1 -0
- package/src/plugins/ChunkCorrelationPlugin.d.ts +61 -0
- package/src/plugins/ChunkCorrelationPlugin.js +442 -0
- package/src/plugins/ChunkCorrelationPlugin.js.map +1 -0
- package/src/plugins/CommonJsChunkLoadingPlugin.d.ts +17 -0
- package/src/plugins/CommonJsChunkLoadingPlugin.js +121 -0
- package/src/plugins/CommonJsChunkLoadingPlugin.js.map +1 -0
- package/src/plugins/DynamicFilesystemChunkLoadingRuntimeModule.d.ts +39 -0
- package/src/plugins/DynamicFilesystemChunkLoadingRuntimeModule.js +119 -0
- package/src/plugins/DynamicFilesystemChunkLoadingRuntimeModule.js.map +1 -0
- package/src/plugins/NodeFederationPlugin.d.ts +46 -0
- package/src/plugins/NodeFederationPlugin.js +76 -0
- package/src/plugins/NodeFederationPlugin.js.map +1 -0
- package/src/plugins/RemotePublicPathRuntimeModule.d.ts +10 -0
- package/src/plugins/RemotePublicPathRuntimeModule.js +109 -0
- package/src/plugins/RemotePublicPathRuntimeModule.js.map +1 -0
- package/src/plugins/StreamingTargetPlugin.d.ts +28 -0
- package/src/plugins/StreamingTargetPlugin.js +59 -0
- package/src/plugins/StreamingTargetPlugin.js.map +1 -0
- package/src/plugins/UniversalFederationPlugin.d.ts +43 -0
- package/src/plugins/UniversalFederationPlugin.js +53 -0
- package/src/plugins/UniversalFederationPlugin.js.map +1 -0
- package/src/plugins/webpackChunkUtilities.d.ts +50 -0
- package/src/plugins/webpackChunkUtilities.js +321 -0
- package/src/plugins/webpackChunkUtilities.js.map +1 -0
- package/src/types/index.d.ts +3 -0
- package/src/types/index.js +3 -0
- package/src/types/index.js.map +1 -0
- package/src/utils/flush-chunks.d.ts +10 -0
- package/src/utils/flush-chunks.js +162 -0
- package/src/utils/flush-chunks.js.map +1 -0
- package/src/utils/hot-reload.d.ts +7 -0
- package/src/utils/hot-reload.js +142 -0
- package/src/utils/hot-reload.js.map +1 -0
- package/src/utils/index.d.ts +2 -0
- package/src/utils/index.js +19 -0
- package/src/utils/index.js.map +1 -0
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getFetchModule = exports.revalidate = exports.fetchRemote = exports.checkFakeRemote = exports.checkMedusaConfigChange = exports.checkUnreachableRemote = exports.performReload = void 0;
|
|
7
|
+
const hashmap = {};
|
|
8
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
9
|
+
const requireCacheRegex = /(remote|runtime|server|hot-reload|react-loadable-manifest)/;
|
|
10
|
+
const performReload = (shouldReload) => {
|
|
11
|
+
if (!shouldReload) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
let req;
|
|
15
|
+
if (typeof __non_webpack_require__ === 'undefined') {
|
|
16
|
+
req = require;
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
req = __non_webpack_require__;
|
|
20
|
+
}
|
|
21
|
+
//@ts-ignore
|
|
22
|
+
globalThis.__remote_scope__ = {};
|
|
23
|
+
Object.keys(req.cache).forEach((key) => {
|
|
24
|
+
if (requireCacheRegex.test(key)) {
|
|
25
|
+
delete req.cache[key];
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
return true;
|
|
29
|
+
};
|
|
30
|
+
exports.performReload = performReload;
|
|
31
|
+
const checkUnreachableRemote = (remoteScope) => {
|
|
32
|
+
for (const property in remoteScope.remotes) {
|
|
33
|
+
if (!remoteScope[property]) {
|
|
34
|
+
console.error('unreachable remote found', property, 'hot reloading to refetch');
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return false;
|
|
39
|
+
};
|
|
40
|
+
exports.checkUnreachableRemote = checkUnreachableRemote;
|
|
41
|
+
const checkMedusaConfigChange = (remoteScope, fetchModule) => {
|
|
42
|
+
//@ts-ignore
|
|
43
|
+
if (remoteScope._medusa) {
|
|
44
|
+
//@ts-ignore
|
|
45
|
+
for (const property in remoteScope._medusa) {
|
|
46
|
+
fetchModule(property)
|
|
47
|
+
.then((res) => res.json())
|
|
48
|
+
.then((medusaResponse) => {
|
|
49
|
+
if (medusaResponse.version !==
|
|
50
|
+
//@ts-ignore
|
|
51
|
+
remoteScope?._medusa[property].version) {
|
|
52
|
+
console.log('medusa config changed', property, 'hot reloading to refetch');
|
|
53
|
+
(0, exports.performReload)(true);
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return false;
|
|
60
|
+
};
|
|
61
|
+
exports.checkMedusaConfigChange = checkMedusaConfigChange;
|
|
62
|
+
const checkFakeRemote = (remoteScope) => {
|
|
63
|
+
for (const property in remoteScope._config) {
|
|
64
|
+
let remote = remoteScope._config[property];
|
|
65
|
+
const resolveRemote = async () => {
|
|
66
|
+
remote = await remote();
|
|
67
|
+
};
|
|
68
|
+
if (typeof remote === 'function') {
|
|
69
|
+
resolveRemote();
|
|
70
|
+
}
|
|
71
|
+
if (remote.fake) {
|
|
72
|
+
console.log('fake remote found', property, 'hot reloading to refetch');
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return false;
|
|
77
|
+
};
|
|
78
|
+
exports.checkFakeRemote = checkFakeRemote;
|
|
79
|
+
const fetchRemote = (remoteScope, fetchModule) => {
|
|
80
|
+
const fetches = [];
|
|
81
|
+
for (const property in remoteScope._config) {
|
|
82
|
+
const name = property;
|
|
83
|
+
const url = remoteScope._config[property];
|
|
84
|
+
const fetcher = fetchModule(url)
|
|
85
|
+
.then((re) => {
|
|
86
|
+
if (!re.ok) {
|
|
87
|
+
throw new Error(`Error loading remote: status: ${re.status}, content-type: ${re.headers.get('content-type')}`);
|
|
88
|
+
}
|
|
89
|
+
return re.text();
|
|
90
|
+
})
|
|
91
|
+
.then((contents) => {
|
|
92
|
+
const hash = crypto_1.default.createHash('md5').update(contents).digest('hex');
|
|
93
|
+
if (hashmap[name]) {
|
|
94
|
+
if (hashmap[name] !== hash) {
|
|
95
|
+
hashmap[name] = hash;
|
|
96
|
+
console.log(name, 'hash is different - must hot reload server');
|
|
97
|
+
return true;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
hashmap[name] = hash;
|
|
102
|
+
}
|
|
103
|
+
})
|
|
104
|
+
.catch((e) => {
|
|
105
|
+
console.error('Remote', name, url, 'Failed to load or is not online', e);
|
|
106
|
+
});
|
|
107
|
+
fetches.push(fetcher);
|
|
108
|
+
}
|
|
109
|
+
return Promise.all(fetches);
|
|
110
|
+
};
|
|
111
|
+
exports.fetchRemote = fetchRemote;
|
|
112
|
+
//@ts-ignore
|
|
113
|
+
const revalidate = (remoteScope = globalThis.__remote_scope__ || {}, fetchModule = getFetchModule() || (() => { })) => {
|
|
114
|
+
return new Promise((res) => {
|
|
115
|
+
if ((0, exports.checkUnreachableRemote)(remoteScope)) {
|
|
116
|
+
res(true);
|
|
117
|
+
}
|
|
118
|
+
// @ts-ignore
|
|
119
|
+
if ((0, exports.checkMedusaConfigChange)(remoteScope, fetchModule)) {
|
|
120
|
+
res(true);
|
|
121
|
+
}
|
|
122
|
+
if ((0, exports.checkFakeRemote)(remoteScope)) {
|
|
123
|
+
res(true);
|
|
124
|
+
}
|
|
125
|
+
(0, exports.fetchRemote)(remoteScope, fetchModule).then(() => res(false));
|
|
126
|
+
}).then((shouldReload) => {
|
|
127
|
+
return (0, exports.performReload)(shouldReload);
|
|
128
|
+
});
|
|
129
|
+
};
|
|
130
|
+
exports.revalidate = revalidate;
|
|
131
|
+
function getFetchModule() {
|
|
132
|
+
//@ts-ignore
|
|
133
|
+
const loadedModule = globalThis.webpackChunkLoad || global.webpackChunkLoad || global.fetch;
|
|
134
|
+
if (loadedModule) {
|
|
135
|
+
return loadedModule;
|
|
136
|
+
}
|
|
137
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
138
|
+
const nodeFetch = require('node-fetch');
|
|
139
|
+
return nodeFetch.default || nodeFetch;
|
|
140
|
+
}
|
|
141
|
+
exports.getFetchModule = getFetchModule;
|
|
142
|
+
//# sourceMappingURL=hot-reload.js.map
|
|
@@ -0,0 +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,oDAA4B;AAE5B,MAAM,iBAAiB,GACrB,4DAA4D,CAAC;AAExD,MAAM,aAAa,GAAG,CAAC,YAAiB,EAAE,EAAE;IACjD,IAAI,CAAC,YAAY,EAAE;QACjB,OAAO,KAAK,CAAC;KACd;IACD,IAAI,GAAgB,CAAC;IACrB,IAAI,OAAO,uBAAuB,KAAK,WAAW,EAAE;QAClD,GAAG,GAAG,OAAO,CAAC;KACf;SAAM;QACL,GAAG,GAAG,uBAAsC,CAAC;KAC9C;IAED,YAAY;IACZ,UAAU,CAAC,gBAAgB,GAAG,EAAE,CAAC;IAEjC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EA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G,CAAC,IAAI,CAAC,CAAC;SACX;QAED,IAAA,mBAAW,EAAC,WAAW,EAAE,WAAW,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;IAC/D,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,YAAY,EAAE,EAAE;QACvB,OAAO,IAAA,qBAAa,EAAC,YAAY,CAAC,CAAC;IACrC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AArBW,QAAA,UAAU,cAqBrB;AAEF,SAAgB,cAAc;IAC5B,YAAY;IACZ,MAAM,YAAY,GAChB,UAAU,CAAC,gBAAgB,IAAI,MAAM,CAAC,gBAAgB,IAAI,MAAM,CAAC,KAAK,CAAC;IACzE,IAAI,YAAY,EAAE;QAChB,OAAO,YAAY,CAAC;KACrB;IACD,8DAA8D;IAC9D,MAAM,SAAS,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;IACxC,OAAO,SAAS,CAAC,OAAO,IAAI,SAAS,CAAC;AACxC,CAAC;AAVD,wCAUC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./hot-reload"), exports);
|
|
18
|
+
__exportStar(require("./flush-chunks"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/node/src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,iDAA+B"}
|