@module-federation/modern-js 0.0.0-next-20250926024003 → 0.0.0-perf-devtools-20260107043700
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/cli/configPlugin.js +301 -363
- package/dist/cjs/cli/index.js +103 -91
- package/dist/cjs/cli/mfRuntimePlugins/inject-node-fetch.js +51 -41
- package/dist/cjs/cli/mfRuntimePlugins/resolve-entry-ipv4.js +73 -75
- package/dist/cjs/cli/mfRuntimePlugins/shared-strategy.js +50 -40
- package/dist/cjs/cli/server/data-fetch-server-plugin.js +55 -44
- package/dist/cjs/cli/ssrPlugin.js +270 -222
- package/dist/cjs/cli/utils.js +84 -81
- package/dist/cjs/constant.js +37 -28
- package/dist/cjs/interfaces/bundler.js +17 -15
- package/dist/cjs/logger.js +37 -25
- package/dist/cjs/react/index.js +55 -19
- package/dist/cjs/react/plugin.js +65 -0
- package/dist/cjs/react/v18.js +58 -0
- package/dist/cjs/react/v19.js +58 -0
- package/dist/cjs/runtime/index.js +55 -19
- package/dist/cjs/server/fileCache.js +76 -76
- package/dist/cjs/server/index.js +65 -57
- package/dist/cjs/server/staticMiddleware.js +84 -84
- package/dist/cjs/ssr-runtime/SSRLiveReload.js +40 -34
- package/dist/cjs/ssr-runtime/devPlugin.js +63 -67
- package/dist/cjs/ssr-runtime/injectDataFetchFunctionPlugin.js +44 -36
- package/dist/cjs/types/index.js +17 -15
- package/dist/esm/cli/configPlugin.mjs +305 -0
- package/dist/esm/cli/index.mjs +83 -0
- package/dist/esm/cli/mfRuntimePlugins/inject-node-fetch.mjs +12 -0
- package/dist/esm/cli/mfRuntimePlugins/resolve-entry-ipv4.mjs +58 -0
- package/dist/esm/cli/mfRuntimePlugins/shared-strategy.mjs +21 -0
- package/dist/esm/cli/server/data-fetch-server-plugin.mjs +17 -0
- package/dist/esm/cli/ssrPlugin.mjs +254 -0
- package/dist/esm/cli/utils.mjs +40 -0
- package/dist/esm/constant.mjs +3 -0
- package/dist/esm/logger.mjs +5 -0
- package/dist/esm/react/plugin.mjs +3 -0
- package/dist/esm/react/v18.mjs +1 -0
- package/dist/esm/react/v19.mjs +1 -0
- package/dist/esm/server/fileCache.mjs +90 -0
- package/dist/esm/server/index.mjs +36 -0
- package/dist/esm/server/staticMiddleware.mjs +87 -0
- package/dist/esm/ssr-runtime/SSRLiveReload.mjs +22 -0
- package/dist/esm/ssr-runtime/devPlugin.mjs +70 -0
- package/dist/esm/ssr-runtime/injectDataFetchFunctionPlugin.mjs +34 -0
- package/dist/esm-node/cli/configPlugin.mjs +263 -0
- package/dist/esm-node/cli/index.mjs +67 -0
- package/dist/esm-node/cli/mfRuntimePlugins/inject-node-fetch.mjs +10 -0
- package/dist/esm-node/cli/mfRuntimePlugins/resolve-entry-ipv4.mjs +46 -0
- package/dist/esm-node/cli/mfRuntimePlugins/shared-strategy.mjs +19 -0
- package/dist/esm-node/cli/server/data-fetch-server-plugin.mjs +15 -0
- package/dist/esm-node/cli/ssrPlugin.mjs +228 -0
- package/dist/esm-node/cli/utils.mjs +40 -0
- package/dist/esm-node/constant.mjs +3 -0
- package/dist/esm-node/logger.mjs +5 -0
- package/dist/esm-node/react/plugin.mjs +3 -0
- package/dist/esm-node/react/v18.mjs +1 -0
- package/dist/esm-node/react/v19.mjs +1 -0
- package/dist/esm-node/server/fileCache.mjs +37 -0
- package/dist/esm-node/server/index.mjs +34 -0
- package/dist/esm-node/server/staticMiddleware.mjs +42 -0
- package/dist/esm-node/ssr-runtime/SSRLiveReload.mjs +15 -0
- package/dist/esm-node/ssr-runtime/devPlugin.mjs +33 -0
- package/dist/esm-node/ssr-runtime/injectDataFetchFunctionPlugin.mjs +14 -0
- package/dist/types/react/plugin.d.ts +2 -0
- package/dist/types/react/v18.d.ts +1 -0
- package/dist/types/react/v19.d.ts +1 -0
- package/dist/types/types/index.d.ts +13 -0
- package/package.json +59 -29
- package/dist/cjs/cli/configPlugin.spec.js +0 -112
- package/dist/cjs/server/fileCache.spec.js +0 -28
- package/dist/cjs/server/staticMiddleware.spec.js +0 -185
- package/dist/esm/cli/configPlugin.js +0 -401
- package/dist/esm/cli/configPlugin.spec.js +0 -108
- package/dist/esm/cli/index.js +0 -90
- package/dist/esm/cli/mfRuntimePlugins/inject-node-fetch.js +0 -16
- package/dist/esm/cli/mfRuntimePlugins/resolve-entry-ipv4.js +0 -74
- package/dist/esm/cli/mfRuntimePlugins/shared-strategy.js +0 -25
- package/dist/esm/cli/server/data-fetch-server-plugin.js +0 -20
- package/dist/esm/cli/ssrPlugin.js +0 -219
- package/dist/esm/cli/utils.js +0 -53
- package/dist/esm/constant.js +0 -6
- package/dist/esm/logger.js +0 -7
- package/dist/esm/server/fileCache.js +0 -98
- package/dist/esm/server/fileCache.spec.js +0 -50
- package/dist/esm/server/index.js +0 -41
- package/dist/esm/server/staticMiddleware.js +0 -104
- package/dist/esm/server/staticMiddleware.spec.js +0 -328
- package/dist/esm/ssr-runtime/SSRLiveReload.js +0 -26
- package/dist/esm/ssr-runtime/devPlugin.js +0 -73
- package/dist/esm/ssr-runtime/injectDataFetchFunctionPlugin.js +0 -34
- package/dist/esm-node/cli/configPlugin.js +0 -353
- package/dist/esm-node/cli/configPlugin.spec.js +0 -89
- package/dist/esm-node/cli/index.js +0 -70
- package/dist/esm-node/cli/mfRuntimePlugins/inject-node-fetch.js +0 -14
- package/dist/esm-node/cli/mfRuntimePlugins/resolve-entry-ipv4.js +0 -62
- package/dist/esm-node/cli/mfRuntimePlugins/shared-strategy.js +0 -23
- package/dist/esm-node/cli/server/data-fetch-server-plugin.js +0 -18
- package/dist/esm-node/cli/ssrPlugin.js +0 -200
- package/dist/esm-node/cli/utils.js +0 -53
- package/dist/esm-node/constant.js +0 -6
- package/dist/esm-node/logger.js +0 -7
- package/dist/esm-node/server/fileCache.js +0 -49
- package/dist/esm-node/server/fileCache.spec.js +0 -27
- package/dist/esm-node/server/index.js +0 -39
- package/dist/esm-node/server/staticMiddleware.js +0 -55
- package/dist/esm-node/server/staticMiddleware.spec.js +0 -162
- package/dist/esm-node/ssr-runtime/SSRLiveReload.js +0 -19
- package/dist/esm-node/ssr-runtime/devPlugin.js +0 -37
- package/dist/esm-node/ssr-runtime/injectDataFetchFunctionPlugin.js +0 -16
- /package/dist/esm/interfaces/{bundler.js → bundler.mjs} +0 -0
- /package/dist/esm/react/{index.js → index.mjs} +0 -0
- /package/dist/esm/runtime/{index.js → index.mjs} +0 -0
- /package/dist/esm/types/{index.js → index.mjs} +0 -0
- /package/dist/esm-node/interfaces/{bundler.js → bundler.mjs} +0 -0
- /package/dist/esm-node/react/{index.js → index.mjs} +0 -0
- /package/dist/esm-node/runtime/{index.js → index.mjs} +0 -0
- /package/dist/esm-node/types/{index.js → index.mjs} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@module-federation/modern-js",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-perf-devtools-20260107043700",
|
|
4
4
|
"files": [
|
|
5
5
|
"dist/",
|
|
6
6
|
"types.d.ts",
|
|
@@ -17,48 +17,60 @@
|
|
|
17
17
|
"exports": {
|
|
18
18
|
".": {
|
|
19
19
|
"types": "./dist/types/cli/index.d.ts",
|
|
20
|
-
"import": "./dist/esm/cli/index.
|
|
20
|
+
"import": "./dist/esm/cli/index.mjs",
|
|
21
21
|
"require": "./dist/cjs/cli/index.js"
|
|
22
22
|
},
|
|
23
23
|
"./runtime": {
|
|
24
24
|
"types": "./dist/types/runtime/index.d.ts",
|
|
25
|
-
"default": "./dist/esm/runtime/index.
|
|
25
|
+
"default": "./dist/esm/runtime/index.mjs"
|
|
26
26
|
},
|
|
27
27
|
"./react": {
|
|
28
28
|
"types": "./dist/types/react/index.d.ts",
|
|
29
|
-
"default": "./dist/esm/react/index.
|
|
29
|
+
"default": "./dist/esm/react/index.mjs"
|
|
30
|
+
},
|
|
31
|
+
"./react-v18": {
|
|
32
|
+
"types": "./dist/types/react/v18.d.ts",
|
|
33
|
+
"default": "./dist/esm/react/v18.mjs"
|
|
34
|
+
},
|
|
35
|
+
"./react-v19": {
|
|
36
|
+
"types": "./dist/types/react/v19.d.ts",
|
|
37
|
+
"default": "./dist/esm/react/v19.mjs"
|
|
38
|
+
},
|
|
39
|
+
"./react-plugin": {
|
|
40
|
+
"types": "./dist/types/react/plugin.d.ts",
|
|
41
|
+
"default": "./dist/esm/react/plugin.mjs"
|
|
30
42
|
},
|
|
31
43
|
"./ssr-dev-plugin": {
|
|
32
44
|
"types": "./dist/types/ssr-runtime/devPlugin.d.ts",
|
|
33
|
-
"default": "./dist/esm/ssr-runtime/devPlugin.
|
|
45
|
+
"default": "./dist/esm/ssr-runtime/devPlugin.mjs"
|
|
34
46
|
},
|
|
35
47
|
"./ssr-inject-data-fetch-function-plugin": {
|
|
36
48
|
"types": "./dist/types/ssr-runtime/injectDataFetchFunctionPlugin.d.ts",
|
|
37
|
-
"default": "./dist/esm/ssr-runtime/injectDataFetchFunctionPlugin.
|
|
49
|
+
"default": "./dist/esm/ssr-runtime/injectDataFetchFunctionPlugin.mjs"
|
|
38
50
|
},
|
|
39
51
|
"./config-plugin": {
|
|
40
52
|
"types": "./dist/types/cli/configPlugin.d.ts",
|
|
41
|
-
"import": "./dist/esm/cli/configPlugin.
|
|
53
|
+
"import": "./dist/esm/cli/configPlugin.mjs",
|
|
42
54
|
"require": "./dist/cjs/cli/configPlugin.js"
|
|
43
55
|
},
|
|
44
56
|
"./ssr-plugin": {
|
|
45
57
|
"types": "./dist/types/cli/ssrPlugin.d.ts",
|
|
46
|
-
"import": "./dist/esm/cli/ssrPlugin.
|
|
58
|
+
"import": "./dist/esm/cli/ssrPlugin.mjs",
|
|
47
59
|
"require": "./dist/cjs/cli/ssrPlugin.js"
|
|
48
60
|
},
|
|
49
61
|
"./shared-strategy": {
|
|
50
62
|
"types": "./dist/types/cli/mfRuntimePlugins/shared-strategy.d.ts",
|
|
51
|
-
"import": "./dist/esm/cli/mfRuntimePlugins/shared-strategy.
|
|
63
|
+
"import": "./dist/esm/cli/mfRuntimePlugins/shared-strategy.mjs",
|
|
52
64
|
"require": "./dist/cjs/cli/mfRuntimePlugins/shared-strategy.js"
|
|
53
65
|
},
|
|
54
66
|
"./resolve-entry-ipv4": {
|
|
55
67
|
"types": "./dist/types/cli/mfRuntimePlugins/resolve-entry-ipv4.d.ts",
|
|
56
|
-
"import": "./dist/esm/cli/mfRuntimePlugins/resolve-entry-ipv4.
|
|
68
|
+
"import": "./dist/esm/cli/mfRuntimePlugins/resolve-entry-ipv4.mjs",
|
|
57
69
|
"require": "./dist/cjs/cli/mfRuntimePlugins/resolve-entry-ipv4.js"
|
|
58
70
|
},
|
|
59
71
|
"./inject-node-fetch": {
|
|
60
72
|
"types": "./dist/types/cli/mfRuntimePlugins/inject-node-fetch.d.ts",
|
|
61
|
-
"import": "./dist/esm/cli/mfRuntimePlugins/inject-node-fetch.
|
|
73
|
+
"import": "./dist/esm/cli/mfRuntimePlugins/inject-node-fetch.mjs",
|
|
62
74
|
"require": "./dist/cjs/cli/mfRuntimePlugins/inject-node-fetch.js"
|
|
63
75
|
},
|
|
64
76
|
"./data-fetch-server-plugin": {
|
|
@@ -81,6 +93,15 @@
|
|
|
81
93
|
"react": [
|
|
82
94
|
"./dist/types/react/index.d.ts"
|
|
83
95
|
],
|
|
96
|
+
"react-v18": [
|
|
97
|
+
"./dist/types/react/v18.d.ts"
|
|
98
|
+
],
|
|
99
|
+
"react-v19": [
|
|
100
|
+
"./dist/types/react/v19.d.ts"
|
|
101
|
+
],
|
|
102
|
+
"react-plugin": [
|
|
103
|
+
"./dist/types/react/plugin.d.ts"
|
|
104
|
+
],
|
|
84
105
|
"config-plugin": [
|
|
85
106
|
"./dist/types/cli/configPlugin.d.ts"
|
|
86
107
|
],
|
|
@@ -112,38 +133,41 @@
|
|
|
112
133
|
"author": "hanric <hanric.zhang@gmail.com>",
|
|
113
134
|
"license": "MIT",
|
|
114
135
|
"dependencies": {
|
|
115
|
-
"@modern-js/utils": "2.
|
|
116
|
-
"@modern-js/node-bundle-require": "2.
|
|
136
|
+
"@modern-js/utils": "2.69.3",
|
|
137
|
+
"@modern-js/node-bundle-require": "2.69.3",
|
|
117
138
|
"fs-extra": "11.3.0",
|
|
118
139
|
"lru-cache": "10.4.3",
|
|
119
140
|
"@swc/helpers": "^0.5.17",
|
|
120
141
|
"node-fetch": "~3.3.0",
|
|
121
142
|
"react-error-boundary": "4.1.2",
|
|
122
|
-
"@module-federation/
|
|
123
|
-
"@module-federation/
|
|
124
|
-
"@module-federation/
|
|
125
|
-
"@module-federation/node": "0.0.0-
|
|
126
|
-
"@module-federation/
|
|
127
|
-
"@module-federation/
|
|
128
|
-
"@module-federation/
|
|
143
|
+
"@module-federation/bridge-react": "0.0.0-perf-devtools-20260107043700",
|
|
144
|
+
"@module-federation/rsbuild-plugin": "0.0.0-perf-devtools-20260107043700",
|
|
145
|
+
"@module-federation/enhanced": "0.0.0-perf-devtools-20260107043700",
|
|
146
|
+
"@module-federation/node": "0.0.0-perf-devtools-20260107043700",
|
|
147
|
+
"@module-federation/runtime": "0.0.0-perf-devtools-20260107043700",
|
|
148
|
+
"@module-federation/sdk": "0.0.0-perf-devtools-20260107043700",
|
|
149
|
+
"@module-federation/cli": "0.0.0-perf-devtools-20260107043700"
|
|
129
150
|
},
|
|
130
151
|
"devDependencies": {
|
|
131
|
-
"@
|
|
152
|
+
"@rsbuild/plugin-react": "1.4.2",
|
|
153
|
+
"@rslib/core": "0.18.5",
|
|
132
154
|
"@rsbuild/core": "1.3.21",
|
|
133
|
-
"@modern-js/app-tools": "2.
|
|
134
|
-
"@modern-js/server-runtime": "2.
|
|
135
|
-
"@modern-js/module-tools": "2.
|
|
136
|
-
"@modern-js/runtime": "2.
|
|
137
|
-
"@modern-js/tsconfig": "2.
|
|
155
|
+
"@modern-js/app-tools": "2.69.3",
|
|
156
|
+
"@modern-js/server-runtime": "2.69.3",
|
|
157
|
+
"@modern-js/module-tools": "2.69.3",
|
|
158
|
+
"@modern-js/runtime": "2.69.3",
|
|
159
|
+
"@modern-js/tsconfig": "2.69.3",
|
|
138
160
|
"@types/react": "^18.3.11",
|
|
139
161
|
"@types/react-dom": "^18.3.0",
|
|
140
|
-
"@module-federation/manifest": "0.0.0-
|
|
162
|
+
"@module-federation/manifest": "0.0.0-perf-devtools-20260107043700"
|
|
141
163
|
},
|
|
142
164
|
"peerDependencies": {
|
|
143
165
|
"react": ">=17",
|
|
144
166
|
"react-dom": ">=17",
|
|
145
167
|
"typescript": "^4.9.0 || ^5.0.0",
|
|
146
|
-
"vue-tsc": "^1.0.24"
|
|
168
|
+
"vue-tsc": "^1.0.24",
|
|
169
|
+
"react-router-dom": "^4 || ^5 || ^6 || ^7",
|
|
170
|
+
"react-router": "^7"
|
|
147
171
|
},
|
|
148
172
|
"peerDependenciesMeta": {
|
|
149
173
|
"typescript": {
|
|
@@ -151,9 +175,15 @@
|
|
|
151
175
|
},
|
|
152
176
|
"vue-tsc": {
|
|
153
177
|
"optional": true
|
|
178
|
+
},
|
|
179
|
+
"react-router-dom": {
|
|
180
|
+
"optional": true
|
|
181
|
+
},
|
|
182
|
+
"react-router": {
|
|
183
|
+
"optional": true
|
|
154
184
|
}
|
|
155
185
|
},
|
|
156
186
|
"scripts": {
|
|
157
|
-
"build": "
|
|
187
|
+
"build": "rslib build"
|
|
158
188
|
}
|
|
159
189
|
}
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
-
for (let key of __getOwnPropNames(from))
|
|
11
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
12
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
-
}
|
|
14
|
-
return to;
|
|
15
|
-
};
|
|
16
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
18
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
19
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
20
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
-
mod
|
|
23
|
-
));
|
|
24
|
-
var import_vitest = require("vitest");
|
|
25
|
-
var import_configPlugin = require("./configPlugin");
|
|
26
|
-
var import_utils = require("./utils");
|
|
27
|
-
const mfConfig = {
|
|
28
|
-
name: "host",
|
|
29
|
-
filename: "remoteEntry.js",
|
|
30
|
-
remotes: {
|
|
31
|
-
remote: "http://localhost:3000/remoteEntry.js"
|
|
32
|
-
},
|
|
33
|
-
shared: {
|
|
34
|
-
react: {
|
|
35
|
-
singleton: true,
|
|
36
|
-
eager: true
|
|
37
|
-
},
|
|
38
|
-
"react-dom": {
|
|
39
|
-
singleton: true,
|
|
40
|
-
eager: true
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
(0, import_vitest.describe)("patchMFConfig", async () => {
|
|
45
|
-
(0, import_vitest.it)("patchMFConfig: server", async () => {
|
|
46
|
-
const patchedConfig = JSON.parse(JSON.stringify(mfConfig));
|
|
47
|
-
(0, import_configPlugin.patchMFConfig)(patchedConfig, true);
|
|
48
|
-
const ipv4 = (0, import_utils.getIPV4)();
|
|
49
|
-
(0, import_vitest.expect)(patchedConfig).toStrictEqual({
|
|
50
|
-
dev: false,
|
|
51
|
-
dts: false,
|
|
52
|
-
filename: "remoteEntry.js",
|
|
53
|
-
library: {
|
|
54
|
-
name: "host",
|
|
55
|
-
type: "commonjs-module"
|
|
56
|
-
},
|
|
57
|
-
name: "host",
|
|
58
|
-
remotes: {
|
|
59
|
-
remote: `http://${ipv4}:3000/remoteEntry.js`
|
|
60
|
-
},
|
|
61
|
-
remoteType: "script",
|
|
62
|
-
runtimePlugins: [
|
|
63
|
-
require.resolve("@module-federation/modern-js/shared-strategy"),
|
|
64
|
-
require.resolve("@module-federation/node/runtimePlugin"),
|
|
65
|
-
require.resolve("@module-federation/modern-js/inject-node-fetch")
|
|
66
|
-
],
|
|
67
|
-
shared: {
|
|
68
|
-
react: {
|
|
69
|
-
eager: true,
|
|
70
|
-
singleton: true
|
|
71
|
-
},
|
|
72
|
-
"react-dom": {
|
|
73
|
-
eager: true,
|
|
74
|
-
singleton: true
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
(0, import_vitest.it)("patchMFConfig: client", async () => {
|
|
80
|
-
const patchedConfig = JSON.parse(JSON.stringify(mfConfig));
|
|
81
|
-
(0, import_configPlugin.patchMFConfig)(patchedConfig, false);
|
|
82
|
-
const ipv4 = (0, import_utils.getIPV4)();
|
|
83
|
-
(0, import_vitest.expect)(patchedConfig).toStrictEqual({
|
|
84
|
-
filename: "remoteEntry.js",
|
|
85
|
-
name: "host",
|
|
86
|
-
remotes: {
|
|
87
|
-
remote: `http://${ipv4}:3000/remoteEntry.js`
|
|
88
|
-
},
|
|
89
|
-
remoteType: "script",
|
|
90
|
-
runtimePlugins: [
|
|
91
|
-
require.resolve("@module-federation/modern-js/shared-strategy")
|
|
92
|
-
],
|
|
93
|
-
shared: {
|
|
94
|
-
react: {
|
|
95
|
-
eager: true,
|
|
96
|
-
singleton: true
|
|
97
|
-
},
|
|
98
|
-
"react-dom": {
|
|
99
|
-
eager: true,
|
|
100
|
-
singleton: true
|
|
101
|
-
}
|
|
102
|
-
},
|
|
103
|
-
dts: {
|
|
104
|
-
consumeTypes: {
|
|
105
|
-
runtimePkgs: [
|
|
106
|
-
"@module-federation/modern-js/runtime"
|
|
107
|
-
]
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
});
|
|
112
|
-
});
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var import_vitest = require("vitest");
|
|
3
|
-
var import_fileCache = require("./fileCache");
|
|
4
|
-
(0, import_vitest.beforeAll)(() => {
|
|
5
|
-
import_vitest.vi.mock("fs-extra", () => ({
|
|
6
|
-
default: {
|
|
7
|
-
pathExists: () => {
|
|
8
|
-
return true;
|
|
9
|
-
},
|
|
10
|
-
lstat: () => {
|
|
11
|
-
return {
|
|
12
|
-
mtimeMs: Date.now(),
|
|
13
|
-
size: 4
|
|
14
|
-
};
|
|
15
|
-
},
|
|
16
|
-
readFile: () => {
|
|
17
|
-
return "test";
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}));
|
|
21
|
-
});
|
|
22
|
-
(0, import_vitest.describe)("modern serve static file cache", async () => {
|
|
23
|
-
(0, import_vitest.it)("should cache file", async () => {
|
|
24
|
-
const cache = new import_fileCache.FileCache();
|
|
25
|
-
const result = await cache.getFile("test.txt");
|
|
26
|
-
(0, import_vitest.expect)(result === null || result === void 0 ? void 0 : result.content).toBe("test");
|
|
27
|
-
});
|
|
28
|
-
});
|
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
-
for (let key of __getOwnPropNames(from))
|
|
11
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
12
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
-
}
|
|
14
|
-
return to;
|
|
15
|
-
};
|
|
16
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
18
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
19
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
20
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
-
mod
|
|
23
|
-
));
|
|
24
|
-
var import_vitest = require("vitest");
|
|
25
|
-
var import_staticMiddleware = require("./staticMiddleware");
|
|
26
|
-
var import_fs_extra = __toESM(require("fs-extra"));
|
|
27
|
-
var import_fileCache = require("./fileCache");
|
|
28
|
-
import_vitest.vi.mock("fs-extra", () => ({
|
|
29
|
-
default: {
|
|
30
|
-
pathExists: import_vitest.vi.fn()
|
|
31
|
-
}
|
|
32
|
-
}));
|
|
33
|
-
import_vitest.vi.mock("./fileCache", () => ({
|
|
34
|
-
fileCache: {
|
|
35
|
-
getFile: import_vitest.vi.fn()
|
|
36
|
-
}
|
|
37
|
-
}));
|
|
38
|
-
(0, import_vitest.describe)("staticMiddleware", () => {
|
|
39
|
-
let middleware;
|
|
40
|
-
let mockContext;
|
|
41
|
-
let nextSpy;
|
|
42
|
-
(0, import_vitest.beforeEach)(() => {
|
|
43
|
-
import_vitest.vi.clearAllMocks();
|
|
44
|
-
middleware = (0, import_staticMiddleware.createStaticMiddleware)({
|
|
45
|
-
assetPrefix: "",
|
|
46
|
-
pwd: "/test/path"
|
|
47
|
-
});
|
|
48
|
-
nextSpy = import_vitest.vi.fn();
|
|
49
|
-
mockContext = {
|
|
50
|
-
req: {
|
|
51
|
-
path: ""
|
|
52
|
-
},
|
|
53
|
-
header: import_vitest.vi.fn(),
|
|
54
|
-
body: import_vitest.vi.fn()
|
|
55
|
-
};
|
|
56
|
-
});
|
|
57
|
-
(0, import_vitest.describe)("file extension filtering", () => {
|
|
58
|
-
(0, import_vitest.it)("should call next() for non-js files", async () => {
|
|
59
|
-
mockContext.req.path = "/bundles/test.css";
|
|
60
|
-
await middleware(mockContext, nextSpy);
|
|
61
|
-
(0, import_vitest.expect)(nextSpy).toHaveBeenCalledOnce();
|
|
62
|
-
(0, import_vitest.expect)(mockContext.header).not.toHaveBeenCalled();
|
|
63
|
-
(0, import_vitest.expect)(mockContext.body).not.toHaveBeenCalled();
|
|
64
|
-
});
|
|
65
|
-
(0, import_vitest.it)("should call next() for files without extension", async () => {
|
|
66
|
-
mockContext.req.path = "/bundles/test";
|
|
67
|
-
await middleware(mockContext, nextSpy);
|
|
68
|
-
(0, import_vitest.expect)(nextSpy).toHaveBeenCalledOnce();
|
|
69
|
-
(0, import_vitest.expect)(mockContext.header).not.toHaveBeenCalled();
|
|
70
|
-
(0, import_vitest.expect)(mockContext.body).not.toHaveBeenCalled();
|
|
71
|
-
});
|
|
72
|
-
(0, import_vitest.it)("should process .js files", async () => {
|
|
73
|
-
mockContext.req.path = "/bundles/test.js";
|
|
74
|
-
import_fs_extra.default.pathExists.mockResolvedValue(false);
|
|
75
|
-
await middleware(mockContext, nextSpy);
|
|
76
|
-
(0, import_vitest.expect)(import_fs_extra.default.pathExists).toHaveBeenCalled();
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
(0, import_vitest.describe)("asset prefix filtering", () => {
|
|
80
|
-
(0, import_vitest.it)("should call next() for paths not starting with /bundles", async () => {
|
|
81
|
-
mockContext.req.path = "/assets/test.js";
|
|
82
|
-
await middleware(mockContext, nextSpy);
|
|
83
|
-
(0, import_vitest.expect)(nextSpy).toHaveBeenCalledOnce();
|
|
84
|
-
(0, import_vitest.expect)(import_fs_extra.default.pathExists).not.toHaveBeenCalled();
|
|
85
|
-
(0, import_vitest.expect)(mockContext.header).not.toHaveBeenCalled();
|
|
86
|
-
(0, import_vitest.expect)(mockContext.body).not.toHaveBeenCalled();
|
|
87
|
-
});
|
|
88
|
-
(0, import_vitest.it)("should call next() for root path", async () => {
|
|
89
|
-
mockContext.req.path = "/test.js";
|
|
90
|
-
await middleware(mockContext, nextSpy);
|
|
91
|
-
(0, import_vitest.expect)(nextSpy).toHaveBeenCalledOnce();
|
|
92
|
-
(0, import_vitest.expect)(import_fs_extra.default.pathExists).not.toHaveBeenCalled();
|
|
93
|
-
});
|
|
94
|
-
(0, import_vitest.it)("should process paths starting with /bundles", async () => {
|
|
95
|
-
mockContext.req.path = "/bundles/test.js";
|
|
96
|
-
import_fs_extra.default.pathExists.mockResolvedValue(false);
|
|
97
|
-
await middleware(mockContext, nextSpy);
|
|
98
|
-
(0, import_vitest.expect)(import_fs_extra.default.pathExists).toHaveBeenCalledWith("/test/path/bundles/test.js");
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
(0, import_vitest.describe)("file existence check", () => {
|
|
102
|
-
(0, import_vitest.it)("should call next() when file does not exist", async () => {
|
|
103
|
-
mockContext.req.path = "/bundles/nonexistent.js";
|
|
104
|
-
import_fs_extra.default.pathExists.mockResolvedValue(false);
|
|
105
|
-
await middleware(mockContext, nextSpy);
|
|
106
|
-
(0, import_vitest.expect)(import_fs_extra.default.pathExists).toHaveBeenCalledWith("/test/path/bundles/nonexistent.js");
|
|
107
|
-
(0, import_vitest.expect)(nextSpy).toHaveBeenCalledOnce();
|
|
108
|
-
(0, import_vitest.expect)(import_fileCache.fileCache.getFile).not.toHaveBeenCalled();
|
|
109
|
-
(0, import_vitest.expect)(mockContext.header).not.toHaveBeenCalled();
|
|
110
|
-
(0, import_vitest.expect)(mockContext.body).not.toHaveBeenCalled();
|
|
111
|
-
});
|
|
112
|
-
(0, import_vitest.it)("should proceed to file cache when file exists", async () => {
|
|
113
|
-
mockContext.req.path = "/bundles/existing.js";
|
|
114
|
-
import_fs_extra.default.pathExists.mockResolvedValue(true);
|
|
115
|
-
import_fileCache.fileCache.getFile.mockResolvedValue(null);
|
|
116
|
-
await middleware(mockContext, nextSpy);
|
|
117
|
-
(0, import_vitest.expect)(import_fs_extra.default.pathExists).toHaveBeenCalledWith("/test/path/bundles/existing.js");
|
|
118
|
-
(0, import_vitest.expect)(import_fileCache.fileCache.getFile).toHaveBeenCalledWith("/test/path/bundles/existing.js");
|
|
119
|
-
});
|
|
120
|
-
});
|
|
121
|
-
(0, import_vitest.describe)("successful file serving", () => {
|
|
122
|
-
(0, import_vitest.it)("should serve file content with correct headers", async () => {
|
|
123
|
-
const mockFileContent = 'console.log("test");';
|
|
124
|
-
const mockFileResult = {
|
|
125
|
-
content: mockFileContent,
|
|
126
|
-
lastModified: Date.now()
|
|
127
|
-
};
|
|
128
|
-
mockContext.req.path = "/bundles/app.js";
|
|
129
|
-
import_fs_extra.default.pathExists.mockResolvedValue(true);
|
|
130
|
-
import_fileCache.fileCache.getFile.mockResolvedValue(mockFileResult);
|
|
131
|
-
mockContext.body.mockReturnValue("response");
|
|
132
|
-
const result = await middleware(mockContext, nextSpy);
|
|
133
|
-
(0, import_vitest.expect)(import_fs_extra.default.pathExists).toHaveBeenCalledWith("/test/path/bundles/app.js");
|
|
134
|
-
(0, import_vitest.expect)(import_fileCache.fileCache.getFile).toHaveBeenCalledWith("/test/path/bundles/app.js");
|
|
135
|
-
(0, import_vitest.expect)(nextSpy).not.toHaveBeenCalled();
|
|
136
|
-
(0, import_vitest.expect)(mockContext.header).toHaveBeenCalledWith("Content-Type", "application/javascript");
|
|
137
|
-
(0, import_vitest.expect)(mockContext.header).toHaveBeenCalledWith("Content-Length", String(mockFileResult.content.length));
|
|
138
|
-
(0, import_vitest.expect)(mockContext.body).toHaveBeenCalledWith(mockFileResult.content, 200);
|
|
139
|
-
(0, import_vitest.expect)(result).toBe("response");
|
|
140
|
-
});
|
|
141
|
-
(0, import_vitest.it)("should handle empty file content", async () => {
|
|
142
|
-
const mockFileResult = {
|
|
143
|
-
content: "",
|
|
144
|
-
lastModified: Date.now()
|
|
145
|
-
};
|
|
146
|
-
mockContext.req.path = "/bundles/empty.js";
|
|
147
|
-
import_fs_extra.default.pathExists.mockResolvedValue(true);
|
|
148
|
-
import_fileCache.fileCache.getFile.mockResolvedValue(mockFileResult);
|
|
149
|
-
mockContext.body.mockReturnValue("empty-response");
|
|
150
|
-
const result = await middleware(mockContext, nextSpy);
|
|
151
|
-
(0, import_vitest.expect)(mockContext.header).toHaveBeenCalledWith("Content-Length", "0");
|
|
152
|
-
(0, import_vitest.expect)(mockContext.body).toHaveBeenCalledWith(mockFileResult.content, 200);
|
|
153
|
-
(0, import_vitest.expect)(result).toBe("empty-response");
|
|
154
|
-
(0, import_vitest.expect)(nextSpy).not.toHaveBeenCalled();
|
|
155
|
-
});
|
|
156
|
-
});
|
|
157
|
-
(0, import_vitest.describe)("asset prefix handling", () => {
|
|
158
|
-
(0, import_vitest.it)("should handle custom asset prefix correctly", async () => {
|
|
159
|
-
const customMiddleware = (0, import_staticMiddleware.createStaticMiddleware)({
|
|
160
|
-
assetPrefix: "/custom-prefix",
|
|
161
|
-
pwd: "/test/path"
|
|
162
|
-
});
|
|
163
|
-
mockContext.req.path = "/bundles/test.js";
|
|
164
|
-
await customMiddleware(mockContext, nextSpy);
|
|
165
|
-
(0, import_vitest.expect)(nextSpy).toHaveBeenCalledOnce();
|
|
166
|
-
(0, import_vitest.expect)(mockContext.header).not.toHaveBeenCalled();
|
|
167
|
-
(0, import_vitest.expect)(mockContext.body).not.toHaveBeenCalled();
|
|
168
|
-
});
|
|
169
|
-
(0, import_vitest.it)("should handle asset prefix removal correctly", async () => {
|
|
170
|
-
const customMiddleware = (0, import_staticMiddleware.createStaticMiddleware)({
|
|
171
|
-
assetPrefix: "/prefix",
|
|
172
|
-
pwd: "/test/path"
|
|
173
|
-
});
|
|
174
|
-
const mockFileResult = {
|
|
175
|
-
content: "test content",
|
|
176
|
-
lastModified: Date.now()
|
|
177
|
-
};
|
|
178
|
-
mockContext.req.path = "/prefix/bundles/test.js";
|
|
179
|
-
import_fs_extra.default.pathExists.mockResolvedValue(true);
|
|
180
|
-
import_fileCache.fileCache.getFile.mockResolvedValue(mockFileResult);
|
|
181
|
-
await customMiddleware(mockContext, nextSpy);
|
|
182
|
-
(0, import_vitest.expect)(import_fs_extra.default.pathExists).toHaveBeenCalledWith("/test/path/bundles/test.js");
|
|
183
|
-
});
|
|
184
|
-
});
|
|
185
|
-
});
|