@bleedingdev/modern-js-server-core 3.5.0-ultramodern.3 → 3.5.0-ultramodern.31
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/dist/cjs/adapters/node/plugins/static.js +6 -1
- package/dist/cjs/adapters/node/plugins/staticModuleFederation.js +38 -32
- package/dist/esm/adapters/node/plugins/static.mjs +6 -1
- package/dist/esm/adapters/node/plugins/staticModuleFederation.mjs +36 -33
- package/dist/esm-node/adapters/node/plugins/static.mjs +6 -1
- package/dist/esm-node/adapters/node/plugins/staticModuleFederation.mjs +36 -33
- package/dist/types/adapters/node/plugins/staticModuleFederation.d.ts +3 -2
- package/package.json +5 -5
|
@@ -97,6 +97,10 @@ function createPublicMiddleware({ pwd, routes }) {
|
|
|
97
97
|
function matchPublicRoute(req, routes) {
|
|
98
98
|
for (const route of routes.sort(index_js_namespaceObject.sortRoutes))if (!route.isSSR && route.entryPath.startsWith('public') && req.path.startsWith(route.urlPath)) return route;
|
|
99
99
|
}
|
|
100
|
+
const isPathInside = (target, root)=>{
|
|
101
|
+
const relative = external_path_default().relative(external_path_default().resolve(root), external_path_default().resolve(target));
|
|
102
|
+
return '' === relative || !relative.startsWith(`..${external_path_default().sep}`) && '..' !== relative && !external_path_default().isAbsolute(relative);
|
|
103
|
+
};
|
|
100
104
|
const extractPathname = (url)=>{
|
|
101
105
|
try {
|
|
102
106
|
if (url.includes('://')) return new URL(url).pathname || '/';
|
|
@@ -174,8 +178,9 @@ function createStaticMiddleware(options) {
|
|
|
174
178
|
if (requestPath.includes('..')) return next();
|
|
175
179
|
const moduleFederationAssetMeta = await getModuleFederationAssets();
|
|
176
180
|
const isModuleFederationAsset = moduleFederationAssetMeta.assets.has(requestPath);
|
|
177
|
-
const isModuleFederationRemoteEntry = moduleFederationAssetMeta.
|
|
181
|
+
const isModuleFederationRemoteEntry = moduleFederationAssetMeta.remoteEntries.has(requestPath);
|
|
178
182
|
const serveByPath = async (filepath, moduleFederationAsset = false, moduleFederationRemoteEntry = false)=>{
|
|
183
|
+
if (!isPathInside(filepath, pwd)) return null;
|
|
179
184
|
if (!await utils_namespaceObject.fs.pathExists(filepath)) return null;
|
|
180
185
|
return serveFile(c, filepath, moduleFederationAsset, moduleFederationRemoteEntry, requestPath);
|
|
181
186
|
};
|
|
@@ -37,6 +37,7 @@ var __webpack_require__ = {};
|
|
|
37
37
|
var __webpack_exports__ = {};
|
|
38
38
|
__webpack_require__.r(__webpack_exports__);
|
|
39
39
|
__webpack_require__.d(__webpack_exports__, {
|
|
40
|
+
BACKEND_MODULE_FEDERATION_MANIFEST_FILE: ()=>BACKEND_MODULE_FEDERATION_MANIFEST_FILE,
|
|
40
41
|
MODULE_FEDERATION_MANIFEST_FILE: ()=>MODULE_FEDERATION_MANIFEST_FILE,
|
|
41
42
|
applyModuleFederationAssetHeaders: ()=>applyModuleFederationAssetHeaders,
|
|
42
43
|
getModuleFederationAssetList: ()=>getModuleFederationAssetList,
|
|
@@ -51,12 +52,17 @@ const utils_namespaceObject = require("@modern-js/utils");
|
|
|
51
52
|
const external_path_namespaceObject = require("path");
|
|
52
53
|
var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject);
|
|
53
54
|
const MODULE_FEDERATION_MANIFEST_FILE = 'mf-manifest.json';
|
|
55
|
+
const BACKEND_MODULE_FEDERATION_MANIFEST_FILE = 'backend-mf-manifest.json';
|
|
56
|
+
const MODULE_FEDERATION_MANIFEST_FILES = [
|
|
57
|
+
MODULE_FEDERATION_MANIFEST_FILE,
|
|
58
|
+
BACKEND_MODULE_FEDERATION_MANIFEST_FILE
|
|
59
|
+
];
|
|
54
60
|
const MODULE_FEDERATION_OPTIONAL_FILES = [
|
|
55
61
|
'mf-stats.json'
|
|
56
62
|
];
|
|
57
63
|
const trimLeadingSlash = (value)=>value.replace(/^\/+/, '');
|
|
58
64
|
const getModuleFederationRequestPath = (pathname, pathPrefix)=>trimLeadingSlash(pathname.replace(pathPrefix, ()=>''));
|
|
59
|
-
const isModuleFederationManifestRequest = (requestPath)=>requestPath
|
|
65
|
+
const isModuleFederationManifestRequest = (requestPath)=>MODULE_FEDERATION_MANIFEST_FILES.includes(requestPath);
|
|
60
66
|
const applyModuleFederationAssetHeaders = (c)=>{
|
|
61
67
|
c.header('Access-Control-Allow-Origin', '*');
|
|
62
68
|
c.header('Access-Control-Allow-Headers', '*');
|
|
@@ -67,8 +73,7 @@ const joinModuleFederationAssetPath = (assetPath, assetName)=>{
|
|
|
67
73
|
return trimLeadingSlash(external_path_default().posix.join(assetPath || '', assetName));
|
|
68
74
|
};
|
|
69
75
|
const appendModuleFederationAsset = (set, assetPath)=>{
|
|
70
|
-
if (
|
|
71
|
-
set.add(trimLeadingSlash(assetPath));
|
|
76
|
+
if (assetPath) set.add(trimLeadingSlash(assetPath));
|
|
72
77
|
};
|
|
73
78
|
const appendModuleFederationAssets = (set, assets)=>{
|
|
74
79
|
assets?.js?.sync?.forEach((asset)=>appendModuleFederationAsset(set, asset));
|
|
@@ -109,39 +114,39 @@ const patchModuleFederationRemoteEntryPublicPath = (c, remoteEntryBuffer, pathPr
|
|
|
109
114
|
};
|
|
110
115
|
const getModuleFederationAssetList = async (pwd)=>{
|
|
111
116
|
const assets = new Set();
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
} catch {}
|
|
117
|
+
const remoteEntries = new Set();
|
|
118
|
+
let manifestFound = false;
|
|
119
|
+
for (const manifestFile of MODULE_FEDERATION_MANIFEST_FILES){
|
|
120
|
+
const manifestPath = external_path_default().join(pwd, manifestFile);
|
|
121
|
+
if (!await utils_namespaceObject.fs.pathExists(manifestPath)) continue;
|
|
122
|
+
manifestFound = true;
|
|
123
|
+
assets.add(manifestFile);
|
|
124
|
+
const manifestBuffer = await fileReader_namespaceObject.fileReader.readFileFromSystem(manifestPath, 'buffer');
|
|
125
|
+
if (null !== manifestBuffer) try {
|
|
126
|
+
const manifest = JSON.parse(manifestBuffer.toString('utf-8'));
|
|
127
|
+
const remoteEntry = joinModuleFederationAssetPath(manifest.metaData?.remoteEntry?.path, manifest.metaData?.remoteEntry?.name);
|
|
128
|
+
const dtsZip = joinModuleFederationAssetPath(manifest.metaData?.types?.path, manifest.metaData?.types?.zip);
|
|
129
|
+
const dtsApi = joinModuleFederationAssetPath(manifest.metaData?.types?.path, manifest.metaData?.types?.api);
|
|
130
|
+
if (remoteEntry) {
|
|
131
|
+
assets.add(remoteEntry);
|
|
132
|
+
remoteEntries.add(remoteEntry);
|
|
133
|
+
}
|
|
134
|
+
appendModuleFederationAsset(assets, dtsZip);
|
|
135
|
+
appendModuleFederationAsset(assets, dtsApi);
|
|
136
|
+
manifest.shared?.forEach((item)=>appendModuleFederationAssets(assets, item.assets));
|
|
137
|
+
manifest.remotes?.forEach((item)=>appendModuleFederationAssets(assets, item.assets));
|
|
138
|
+
manifest.exposes?.forEach((item)=>appendModuleFederationAssets(assets, item.assets));
|
|
139
|
+
} catch {}
|
|
140
|
+
}
|
|
141
|
+
if (manifestFound) {
|
|
142
|
+
for (const filename of MODULE_FEDERATION_OPTIONAL_FILES)if (await utils_namespaceObject.fs.pathExists(external_path_default().join(pwd, filename))) assets.add(filename);
|
|
143
|
+
}
|
|
140
144
|
return {
|
|
141
145
|
assets,
|
|
142
|
-
|
|
146
|
+
remoteEntries
|
|
143
147
|
};
|
|
144
148
|
};
|
|
149
|
+
exports.BACKEND_MODULE_FEDERATION_MANIFEST_FILE = __webpack_exports__.BACKEND_MODULE_FEDERATION_MANIFEST_FILE;
|
|
145
150
|
exports.MODULE_FEDERATION_MANIFEST_FILE = __webpack_exports__.MODULE_FEDERATION_MANIFEST_FILE;
|
|
146
151
|
exports.applyModuleFederationAssetHeaders = __webpack_exports__.applyModuleFederationAssetHeaders;
|
|
147
152
|
exports.getModuleFederationAssetList = __webpack_exports__.getModuleFederationAssetList;
|
|
@@ -151,6 +156,7 @@ exports.patchModuleFederationManifestPublicPath = __webpack_exports__.patchModul
|
|
|
151
156
|
exports.patchModuleFederationRemoteEntryPublicPath = __webpack_exports__.patchModuleFederationRemoteEntryPublicPath;
|
|
152
157
|
exports.trimLeadingSlash = __webpack_exports__.trimLeadingSlash;
|
|
153
158
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
159
|
+
"BACKEND_MODULE_FEDERATION_MANIFEST_FILE",
|
|
154
160
|
"MODULE_FEDERATION_MANIFEST_FILE",
|
|
155
161
|
"applyModuleFederationAssetHeaders",
|
|
156
162
|
"getModuleFederationAssetList",
|
|
@@ -53,6 +53,10 @@ function createPublicMiddleware({ pwd, routes }) {
|
|
|
53
53
|
function matchPublicRoute(req, routes) {
|
|
54
54
|
for (const route of routes.sort(sortRoutes))if (!route.isSSR && route.entryPath.startsWith('public') && req.path.startsWith(route.urlPath)) return route;
|
|
55
55
|
}
|
|
56
|
+
const isPathInside = (target, root)=>{
|
|
57
|
+
const relative = path.relative(path.resolve(root), path.resolve(target));
|
|
58
|
+
return '' === relative || !relative.startsWith(`..${path.sep}`) && '..' !== relative && !path.isAbsolute(relative);
|
|
59
|
+
};
|
|
56
60
|
const extractPathname = (url)=>{
|
|
57
61
|
try {
|
|
58
62
|
if (url.includes('://')) return new URL(url).pathname || '/';
|
|
@@ -130,8 +134,9 @@ function createStaticMiddleware(options) {
|
|
|
130
134
|
if (requestPath.includes('..')) return next();
|
|
131
135
|
const moduleFederationAssetMeta = await getModuleFederationAssets();
|
|
132
136
|
const isModuleFederationAsset = moduleFederationAssetMeta.assets.has(requestPath);
|
|
133
|
-
const isModuleFederationRemoteEntry = moduleFederationAssetMeta.
|
|
137
|
+
const isModuleFederationRemoteEntry = moduleFederationAssetMeta.remoteEntries.has(requestPath);
|
|
134
138
|
const serveByPath = async (filepath, moduleFederationAsset = false, moduleFederationRemoteEntry = false)=>{
|
|
139
|
+
if (!isPathInside(filepath, pwd)) return null;
|
|
135
140
|
if (!await fs.pathExists(filepath)) return null;
|
|
136
141
|
return serveFile(c, filepath, moduleFederationAsset, moduleFederationRemoteEntry, requestPath);
|
|
137
142
|
};
|
|
@@ -2,12 +2,17 @@ import { fileReader } from "@modern-js/runtime-utils/fileReader";
|
|
|
2
2
|
import { fs } from "@modern-js/utils";
|
|
3
3
|
import path from "path";
|
|
4
4
|
const MODULE_FEDERATION_MANIFEST_FILE = 'mf-manifest.json';
|
|
5
|
+
const BACKEND_MODULE_FEDERATION_MANIFEST_FILE = 'backend-mf-manifest.json';
|
|
6
|
+
const MODULE_FEDERATION_MANIFEST_FILES = [
|
|
7
|
+
MODULE_FEDERATION_MANIFEST_FILE,
|
|
8
|
+
BACKEND_MODULE_FEDERATION_MANIFEST_FILE
|
|
9
|
+
];
|
|
5
10
|
const MODULE_FEDERATION_OPTIONAL_FILES = [
|
|
6
11
|
'mf-stats.json'
|
|
7
12
|
];
|
|
8
13
|
const trimLeadingSlash = (value)=>value.replace(/^\/+/, '');
|
|
9
14
|
const getModuleFederationRequestPath = (pathname, pathPrefix)=>trimLeadingSlash(pathname.replace(pathPrefix, ()=>''));
|
|
10
|
-
const isModuleFederationManifestRequest = (requestPath)=>requestPath
|
|
15
|
+
const isModuleFederationManifestRequest = (requestPath)=>MODULE_FEDERATION_MANIFEST_FILES.includes(requestPath);
|
|
11
16
|
const applyModuleFederationAssetHeaders = (c)=>{
|
|
12
17
|
c.header('Access-Control-Allow-Origin', '*');
|
|
13
18
|
c.header('Access-Control-Allow-Headers', '*');
|
|
@@ -18,8 +23,7 @@ const joinModuleFederationAssetPath = (assetPath, assetName)=>{
|
|
|
18
23
|
return trimLeadingSlash(path.posix.join(assetPath || '', assetName));
|
|
19
24
|
};
|
|
20
25
|
const appendModuleFederationAsset = (set, assetPath)=>{
|
|
21
|
-
if (
|
|
22
|
-
set.add(trimLeadingSlash(assetPath));
|
|
26
|
+
if (assetPath) set.add(trimLeadingSlash(assetPath));
|
|
23
27
|
};
|
|
24
28
|
const appendModuleFederationAssets = (set, assets)=>{
|
|
25
29
|
assets?.js?.sync?.forEach((asset)=>appendModuleFederationAsset(set, asset));
|
|
@@ -60,37 +64,36 @@ const patchModuleFederationRemoteEntryPublicPath = (c, remoteEntryBuffer, pathPr
|
|
|
60
64
|
};
|
|
61
65
|
const getModuleFederationAssetList = async (pwd)=>{
|
|
62
66
|
const assets = new Set();
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
} catch {}
|
|
67
|
+
const remoteEntries = new Set();
|
|
68
|
+
let manifestFound = false;
|
|
69
|
+
for (const manifestFile of MODULE_FEDERATION_MANIFEST_FILES){
|
|
70
|
+
const manifestPath = path.join(pwd, manifestFile);
|
|
71
|
+
if (!await fs.pathExists(manifestPath)) continue;
|
|
72
|
+
manifestFound = true;
|
|
73
|
+
assets.add(manifestFile);
|
|
74
|
+
const manifestBuffer = await fileReader.readFileFromSystem(manifestPath, 'buffer');
|
|
75
|
+
if (null !== manifestBuffer) try {
|
|
76
|
+
const manifest = JSON.parse(manifestBuffer.toString('utf-8'));
|
|
77
|
+
const remoteEntry = joinModuleFederationAssetPath(manifest.metaData?.remoteEntry?.path, manifest.metaData?.remoteEntry?.name);
|
|
78
|
+
const dtsZip = joinModuleFederationAssetPath(manifest.metaData?.types?.path, manifest.metaData?.types?.zip);
|
|
79
|
+
const dtsApi = joinModuleFederationAssetPath(manifest.metaData?.types?.path, manifest.metaData?.types?.api);
|
|
80
|
+
if (remoteEntry) {
|
|
81
|
+
assets.add(remoteEntry);
|
|
82
|
+
remoteEntries.add(remoteEntry);
|
|
83
|
+
}
|
|
84
|
+
appendModuleFederationAsset(assets, dtsZip);
|
|
85
|
+
appendModuleFederationAsset(assets, dtsApi);
|
|
86
|
+
manifest.shared?.forEach((item)=>appendModuleFederationAssets(assets, item.assets));
|
|
87
|
+
manifest.remotes?.forEach((item)=>appendModuleFederationAssets(assets, item.assets));
|
|
88
|
+
manifest.exposes?.forEach((item)=>appendModuleFederationAssets(assets, item.assets));
|
|
89
|
+
} catch {}
|
|
90
|
+
}
|
|
91
|
+
if (manifestFound) {
|
|
92
|
+
for (const filename of MODULE_FEDERATION_OPTIONAL_FILES)if (await fs.pathExists(path.join(pwd, filename))) assets.add(filename);
|
|
93
|
+
}
|
|
91
94
|
return {
|
|
92
95
|
assets,
|
|
93
|
-
|
|
96
|
+
remoteEntries
|
|
94
97
|
};
|
|
95
98
|
};
|
|
96
|
-
export { MODULE_FEDERATION_MANIFEST_FILE, applyModuleFederationAssetHeaders, getModuleFederationAssetList, getModuleFederationRequestPath, isModuleFederationManifestRequest, patchModuleFederationManifestPublicPath, patchModuleFederationRemoteEntryPublicPath, trimLeadingSlash };
|
|
99
|
+
export { BACKEND_MODULE_FEDERATION_MANIFEST_FILE, MODULE_FEDERATION_MANIFEST_FILE, applyModuleFederationAssetHeaders, getModuleFederationAssetList, getModuleFederationRequestPath, isModuleFederationManifestRequest, patchModuleFederationManifestPublicPath, patchModuleFederationRemoteEntryPublicPath, trimLeadingSlash };
|
|
@@ -54,6 +54,10 @@ function createPublicMiddleware({ pwd, routes }) {
|
|
|
54
54
|
function matchPublicRoute(req, routes) {
|
|
55
55
|
for (const route of routes.sort(sortRoutes))if (!route.isSSR && route.entryPath.startsWith('public') && req.path.startsWith(route.urlPath)) return route;
|
|
56
56
|
}
|
|
57
|
+
const isPathInside = (target, root)=>{
|
|
58
|
+
const relative = path.relative(path.resolve(root), path.resolve(target));
|
|
59
|
+
return '' === relative || !relative.startsWith(`..${path.sep}`) && '..' !== relative && !path.isAbsolute(relative);
|
|
60
|
+
};
|
|
57
61
|
const extractPathname = (url)=>{
|
|
58
62
|
try {
|
|
59
63
|
if (url.includes('://')) return new URL(url).pathname || '/';
|
|
@@ -131,8 +135,9 @@ function createStaticMiddleware(options) {
|
|
|
131
135
|
if (requestPath.includes('..')) return next();
|
|
132
136
|
const moduleFederationAssetMeta = await getModuleFederationAssets();
|
|
133
137
|
const isModuleFederationAsset = moduleFederationAssetMeta.assets.has(requestPath);
|
|
134
|
-
const isModuleFederationRemoteEntry = moduleFederationAssetMeta.
|
|
138
|
+
const isModuleFederationRemoteEntry = moduleFederationAssetMeta.remoteEntries.has(requestPath);
|
|
135
139
|
const serveByPath = async (filepath, moduleFederationAsset = false, moduleFederationRemoteEntry = false)=>{
|
|
140
|
+
if (!isPathInside(filepath, pwd)) return null;
|
|
136
141
|
if (!await fs.pathExists(filepath)) return null;
|
|
137
142
|
return serveFile(c, filepath, moduleFederationAsset, moduleFederationRemoteEntry, requestPath);
|
|
138
143
|
};
|
|
@@ -3,12 +3,17 @@ import { fileReader } from "@modern-js/runtime-utils/fileReader";
|
|
|
3
3
|
import { fs } from "@modern-js/utils";
|
|
4
4
|
import path from "path";
|
|
5
5
|
const MODULE_FEDERATION_MANIFEST_FILE = 'mf-manifest.json';
|
|
6
|
+
const BACKEND_MODULE_FEDERATION_MANIFEST_FILE = 'backend-mf-manifest.json';
|
|
7
|
+
const MODULE_FEDERATION_MANIFEST_FILES = [
|
|
8
|
+
MODULE_FEDERATION_MANIFEST_FILE,
|
|
9
|
+
BACKEND_MODULE_FEDERATION_MANIFEST_FILE
|
|
10
|
+
];
|
|
6
11
|
const MODULE_FEDERATION_OPTIONAL_FILES = [
|
|
7
12
|
'mf-stats.json'
|
|
8
13
|
];
|
|
9
14
|
const trimLeadingSlash = (value)=>value.replace(/^\/+/, '');
|
|
10
15
|
const getModuleFederationRequestPath = (pathname, pathPrefix)=>trimLeadingSlash(pathname.replace(pathPrefix, ()=>''));
|
|
11
|
-
const isModuleFederationManifestRequest = (requestPath)=>requestPath
|
|
16
|
+
const isModuleFederationManifestRequest = (requestPath)=>MODULE_FEDERATION_MANIFEST_FILES.includes(requestPath);
|
|
12
17
|
const applyModuleFederationAssetHeaders = (c)=>{
|
|
13
18
|
c.header('Access-Control-Allow-Origin', '*');
|
|
14
19
|
c.header('Access-Control-Allow-Headers', '*');
|
|
@@ -19,8 +24,7 @@ const joinModuleFederationAssetPath = (assetPath, assetName)=>{
|
|
|
19
24
|
return trimLeadingSlash(path.posix.join(assetPath || '', assetName));
|
|
20
25
|
};
|
|
21
26
|
const appendModuleFederationAsset = (set, assetPath)=>{
|
|
22
|
-
if (
|
|
23
|
-
set.add(trimLeadingSlash(assetPath));
|
|
27
|
+
if (assetPath) set.add(trimLeadingSlash(assetPath));
|
|
24
28
|
};
|
|
25
29
|
const appendModuleFederationAssets = (set, assets)=>{
|
|
26
30
|
assets?.js?.sync?.forEach((asset)=>appendModuleFederationAsset(set, asset));
|
|
@@ -61,37 +65,36 @@ const patchModuleFederationRemoteEntryPublicPath = (c, remoteEntryBuffer, pathPr
|
|
|
61
65
|
};
|
|
62
66
|
const getModuleFederationAssetList = async (pwd)=>{
|
|
63
67
|
const assets = new Set();
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
} catch {}
|
|
68
|
+
const remoteEntries = new Set();
|
|
69
|
+
let manifestFound = false;
|
|
70
|
+
for (const manifestFile of MODULE_FEDERATION_MANIFEST_FILES){
|
|
71
|
+
const manifestPath = path.join(pwd, manifestFile);
|
|
72
|
+
if (!await fs.pathExists(manifestPath)) continue;
|
|
73
|
+
manifestFound = true;
|
|
74
|
+
assets.add(manifestFile);
|
|
75
|
+
const manifestBuffer = await fileReader.readFileFromSystem(manifestPath, 'buffer');
|
|
76
|
+
if (null !== manifestBuffer) try {
|
|
77
|
+
const manifest = JSON.parse(manifestBuffer.toString('utf-8'));
|
|
78
|
+
const remoteEntry = joinModuleFederationAssetPath(manifest.metaData?.remoteEntry?.path, manifest.metaData?.remoteEntry?.name);
|
|
79
|
+
const dtsZip = joinModuleFederationAssetPath(manifest.metaData?.types?.path, manifest.metaData?.types?.zip);
|
|
80
|
+
const dtsApi = joinModuleFederationAssetPath(manifest.metaData?.types?.path, manifest.metaData?.types?.api);
|
|
81
|
+
if (remoteEntry) {
|
|
82
|
+
assets.add(remoteEntry);
|
|
83
|
+
remoteEntries.add(remoteEntry);
|
|
84
|
+
}
|
|
85
|
+
appendModuleFederationAsset(assets, dtsZip);
|
|
86
|
+
appendModuleFederationAsset(assets, dtsApi);
|
|
87
|
+
manifest.shared?.forEach((item)=>appendModuleFederationAssets(assets, item.assets));
|
|
88
|
+
manifest.remotes?.forEach((item)=>appendModuleFederationAssets(assets, item.assets));
|
|
89
|
+
manifest.exposes?.forEach((item)=>appendModuleFederationAssets(assets, item.assets));
|
|
90
|
+
} catch {}
|
|
91
|
+
}
|
|
92
|
+
if (manifestFound) {
|
|
93
|
+
for (const filename of MODULE_FEDERATION_OPTIONAL_FILES)if (await fs.pathExists(path.join(pwd, filename))) assets.add(filename);
|
|
94
|
+
}
|
|
92
95
|
return {
|
|
93
96
|
assets,
|
|
94
|
-
|
|
97
|
+
remoteEntries
|
|
95
98
|
};
|
|
96
99
|
};
|
|
97
|
-
export { MODULE_FEDERATION_MANIFEST_FILE, applyModuleFederationAssetHeaders, getModuleFederationAssetList, getModuleFederationRequestPath, isModuleFederationManifestRequest, patchModuleFederationManifestPublicPath, patchModuleFederationRemoteEntryPublicPath, trimLeadingSlash };
|
|
100
|
+
export { BACKEND_MODULE_FEDERATION_MANIFEST_FILE, MODULE_FEDERATION_MANIFEST_FILE, applyModuleFederationAssetHeaders, getModuleFederationAssetList, getModuleFederationRequestPath, isModuleFederationManifestRequest, patchModuleFederationManifestPublicPath, patchModuleFederationRemoteEntryPublicPath, trimLeadingSlash };
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import type { Middleware } from '../../../types';
|
|
2
2
|
export declare const MODULE_FEDERATION_MANIFEST_FILE = "mf-manifest.json";
|
|
3
|
+
export declare const BACKEND_MODULE_FEDERATION_MANIFEST_FILE = "backend-mf-manifest.json";
|
|
3
4
|
export type ModuleFederationServeAssets = {
|
|
4
5
|
assets: Set<string>;
|
|
5
|
-
|
|
6
|
+
remoteEntries: Set<string>;
|
|
6
7
|
};
|
|
7
8
|
export declare const trimLeadingSlash: (value: string) => string;
|
|
8
9
|
export declare const getModuleFederationRequestPath: (pathname: string, pathPrefix: string) => string;
|
|
9
|
-
export declare const isModuleFederationManifestRequest: (requestPath: string) =>
|
|
10
|
+
export declare const isModuleFederationManifestRequest: (requestPath: string) => boolean;
|
|
10
11
|
export declare const applyModuleFederationAssetHeaders: (c: Parameters<Middleware>[0]) => void;
|
|
11
12
|
export declare const patchModuleFederationManifestPublicPath: (c: Parameters<Middleware>[0], manifestBuffer: Buffer, pathPrefix: string) => Buffer<ArrayBufferLike>;
|
|
12
13
|
export declare const patchModuleFederationRemoteEntryPublicPath: (c: Parameters<Middleware>[0], remoteEntryBuffer: Buffer, pathPrefix: string) => Buffer<ArrayBufferLike>;
|
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"modern",
|
|
18
18
|
"modern.js"
|
|
19
19
|
],
|
|
20
|
-
"version": "3.5.0-ultramodern.
|
|
20
|
+
"version": "3.5.0-ultramodern.31",
|
|
21
21
|
"types": "./dist/types/index.d.ts",
|
|
22
22
|
"main": "./dist/cjs/index.js",
|
|
23
23
|
"exports": {
|
|
@@ -76,9 +76,9 @@
|
|
|
76
76
|
"flatted": "^3.4.2",
|
|
77
77
|
"hono": "^4.12.27",
|
|
78
78
|
"ts-deepmerge": "8.0.0",
|
|
79
|
-
"@modern-js/
|
|
80
|
-
"@modern-js/
|
|
81
|
-
"@modern-js/
|
|
79
|
+
"@modern-js/runtime-utils": "npm:@bleedingdev/modern-js-runtime-utils@3.5.0-ultramodern.31",
|
|
80
|
+
"@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.5.0-ultramodern.31",
|
|
81
|
+
"@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.5.0-ultramodern.31"
|
|
82
82
|
},
|
|
83
83
|
"devDependencies": {
|
|
84
84
|
"@rslib/core": "0.23.1",
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
"@types/node": "^26.0.1",
|
|
88
88
|
"@typescript/native-preview": "7.0.0-dev.20260628.1",
|
|
89
89
|
"http-proxy-middleware": "^4.1.1",
|
|
90
|
-
"@modern-js/types": "npm:@bleedingdev/modern-js-types@3.5.0-ultramodern.
|
|
90
|
+
"@modern-js/types": "npm:@bleedingdev/modern-js-types@3.5.0-ultramodern.31",
|
|
91
91
|
"@scripts/rstest-config": "2.66.0"
|
|
92
92
|
},
|
|
93
93
|
"sideEffects": false,
|