@module-federation/modern-js 0.0.0-next-20240813065037 → 0.0.0-next-20240814082511
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/ast/constant.js +46 -0
- package/dist/cjs/cli/ast/generateRoutes.js +140 -0
- package/dist/cjs/cli/ast/generateSlimRoutes.js +106 -0
- package/dist/cjs/cli/ast/index.js +31 -0
- package/dist/cjs/cli/configPlugin.js +1 -0
- package/dist/cjs/cli/constant.js +6 -0
- package/dist/cjs/cli/dataLoaderPlugin.js +220 -0
- package/dist/cjs/cli/index.js +6 -1
- package/dist/cjs/cli/server/dataLoaderPlugin.js +78 -0
- package/dist/cjs/cli/ssrPlugin.js +4 -4
- package/dist/cjs/interfaces/route.js +16 -0
- package/dist/cjs/runtime/constant.js +34 -0
- package/dist/cjs/runtime/dataLoader.js +87 -0
- package/dist/cjs/runtime/index.js +4 -1
- package/dist/cjs/runtime/utils.js +43 -0
- package/dist/cjs/runtime/withMFRouteId.js +31 -0
- package/dist/cjs/ssr-runtime/plugin.js +5 -7
- package/dist/esm/cli/ast/constant.js +16 -0
- package/dist/esm/cli/ast/generateRoutes.js +107 -0
- package/dist/esm/cli/ast/generateSlimRoutes.js +75 -0
- package/dist/esm/cli/ast/index.js +6 -0
- package/dist/esm/cli/configPlugin.js +1 -0
- package/dist/esm/cli/constant.js +4 -0
- package/dist/esm/cli/dataLoaderPlugin.js +207 -0
- package/dist/esm/cli/index.js +6 -1
- package/dist/esm/cli/server/dataLoaderPlugin.js +122 -0
- package/dist/esm/cli/ssrPlugin.js +2 -2
- package/dist/esm/interfaces/route.js +0 -0
- package/dist/esm/runtime/constant.js +8 -0
- package/dist/esm/runtime/dataLoader.js +125 -0
- package/dist/esm/runtime/index.js +3 -1
- package/dist/esm/runtime/utils.js +16 -0
- package/dist/esm/runtime/withMFRouteId.js +7 -0
- package/dist/esm/ssr-runtime/plugin.js +5 -10
- package/dist/esm-node/cli/ast/constant.js +16 -0
- package/dist/esm-node/cli/ast/generateRoutes.js +106 -0
- package/dist/esm-node/cli/ast/generateSlimRoutes.js +72 -0
- package/dist/esm-node/cli/ast/index.js +6 -0
- package/dist/esm-node/cli/configPlugin.js +1 -0
- package/dist/esm-node/cli/constant.js +4 -0
- package/dist/esm-node/cli/dataLoaderPlugin.js +184 -0
- package/dist/esm-node/cli/index.js +6 -1
- package/dist/esm-node/cli/server/dataLoaderPlugin.js +58 -0
- package/dist/esm-node/cli/ssrPlugin.js +2 -2
- package/dist/esm-node/interfaces/route.js +0 -0
- package/dist/esm-node/runtime/constant.js +8 -0
- package/dist/esm-node/runtime/dataLoader.js +63 -0
- package/dist/esm-node/runtime/index.js +3 -1
- package/dist/esm-node/runtime/utils.js +19 -0
- package/dist/esm-node/runtime/withMFRouteId.js +7 -0
- package/dist/esm-node/ssr-runtime/plugin.js +5 -7
- package/dist/types/cli/ast/constant.d.ts +7 -0
- package/dist/types/cli/ast/generateRoutes.d.ts +7 -0
- package/dist/types/cli/ast/generateSlimRoutes.d.ts +7 -0
- package/dist/types/cli/ast/index.d.ts +2 -0
- package/dist/types/cli/constant.d.ts +2 -0
- package/dist/types/cli/dataLoaderPlugin.d.ts +6 -0
- package/dist/types/cli/server/dataLoaderPlugin.d.ts +5 -0
- package/dist/types/interfaces/route.d.ts +13 -0
- package/dist/types/runtime/constant.d.ts +3 -0
- package/dist/types/runtime/dataLoader.d.ts +7 -0
- package/dist/types/runtime/index.d.ts +1 -0
- package/dist/types/runtime/utils.d.ts +1 -0
- package/dist/types/runtime/withMFRouteId.d.ts +1 -0
- package/dist/types/types/index.d.ts +17 -0
- package/package.json +37 -11
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ServerPlugin } from '@modern-js/server-core';
|
|
2
|
+
import { init } from '@module-federation/enhanced/runtime';
|
|
3
|
+
type MFRuntimeOptions = Parameters<typeof init>[0];
|
|
4
|
+
declare const _default: (mfRuntimeOptions: MFRuntimeOptions) => ServerPlugin;
|
|
5
|
+
export default _default;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type Route = {
|
|
2
|
+
id: string;
|
|
3
|
+
type: string;
|
|
4
|
+
loader?: boolean;
|
|
5
|
+
index?: boolean;
|
|
6
|
+
isRoot?: boolean;
|
|
7
|
+
children?: Route[];
|
|
8
|
+
};
|
|
9
|
+
export type MFModernRouteJson = {
|
|
10
|
+
baseName: string;
|
|
11
|
+
routes: Record<string, Route[]>;
|
|
12
|
+
prefix: string;
|
|
13
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Plugin } from '@modern-js/runtime';
|
|
2
|
+
import { type RouteObject } from '@modern-js/runtime/router';
|
|
3
|
+
declare global {
|
|
4
|
+
var mfRemoteRoutes: RouteObject[];
|
|
5
|
+
var mfHasLoadedRemoteRoutes: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare const ssrDataLoaderPlugin: () => Plugin;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function transformName2Prefix(name: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function withMFRouteId(id: string): string;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { moduleFederationPlugin } from '@module-federation/sdk';
|
|
2
2
|
import type { ModuleFederationPlugin as WebpackModuleFederationPlugin } from '@module-federation/enhanced';
|
|
3
3
|
import type { ModuleFederationPlugin as RspackModuleFederationPlugin } from '@module-federation/enhanced/rspack';
|
|
4
|
+
import type { init } from '@module-federation/enhanced/runtime';
|
|
4
5
|
export interface PluginOptions {
|
|
5
6
|
config?: moduleFederationPlugin.ModuleFederationPluginOptions;
|
|
6
7
|
configPath?: string;
|
|
7
8
|
remoteIpStrategy?: 'ipv4' | 'inherit';
|
|
9
|
+
dataLoader?: false | Pick<DataLoaderOptions, 'baseName' | 'partialSSRRemotes'>;
|
|
8
10
|
}
|
|
9
11
|
export interface InternalModernPluginOptions {
|
|
10
12
|
csrConfig?: moduleFederationPlugin.ModuleFederationPluginOptions;
|
|
@@ -16,3 +18,18 @@ export interface InternalModernPluginOptions {
|
|
|
16
18
|
remoteIpStrategy?: 'ipv4' | 'inherit';
|
|
17
19
|
}
|
|
18
20
|
export type BundlerPlugin = WebpackModuleFederationPlugin | RspackModuleFederationPlugin;
|
|
21
|
+
export type DataLoaderOptions = {
|
|
22
|
+
baseName: string;
|
|
23
|
+
partialSSRRemotes?: string[];
|
|
24
|
+
metaName?: string;
|
|
25
|
+
serverPlugin?: string;
|
|
26
|
+
runtimeOptions?: Parameters<typeof init>[0];
|
|
27
|
+
fetchSSRByRouteIds?: (partialSSRRemotes: string[], mfConfig: moduleFederationPlugin.ModuleFederationPluginOptions) => Promise<string[] | undefined>;
|
|
28
|
+
patchMFConfig?: (options: {
|
|
29
|
+
mfConfig: moduleFederationPlugin.ModuleFederationPluginOptions;
|
|
30
|
+
baseName: string;
|
|
31
|
+
metaName: string;
|
|
32
|
+
isServer: boolean;
|
|
33
|
+
routesFilePath: string;
|
|
34
|
+
}) => void;
|
|
35
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@module-federation/modern-js",
|
|
3
|
-
"version": "0.0.0-next-
|
|
3
|
+
"version": "0.0.0-next-20240814082511",
|
|
4
4
|
"files": [
|
|
5
5
|
"dist/",
|
|
6
6
|
"types.d.ts",
|
|
@@ -23,6 +23,19 @@
|
|
|
23
23
|
"types": "./dist/types/ssr-runtime/index.d.ts",
|
|
24
24
|
"default": "./dist/esm/ssr-runtime/index.js"
|
|
25
25
|
},
|
|
26
|
+
"./data-loader": {
|
|
27
|
+
"types": "./dist/types/runtime/dataLoader.d.ts",
|
|
28
|
+
"default": "./dist/esm/runtime/dataLoader.js"
|
|
29
|
+
},
|
|
30
|
+
"./data-loader-server": {
|
|
31
|
+
"types": "./dist/types/cli/server/dataLoaderPlugin.d.ts",
|
|
32
|
+
"default": "./dist/cjs/cli/server/dataLoaderPlugin.js"
|
|
33
|
+
},
|
|
34
|
+
"./data-loader-plugin": {
|
|
35
|
+
"import": "./dist/esm/cli/dataLoaderPlugin.js",
|
|
36
|
+
"require": "./dist/cjs/cli/dataLoaderPlugin.js",
|
|
37
|
+
"types": "./dist/types/cli/dataLoaderPlugin.d.ts"
|
|
38
|
+
},
|
|
26
39
|
"./config-plugin": {
|
|
27
40
|
"import": "./dist/esm/cli/configPlugin.js",
|
|
28
41
|
"require": "./dist/cjs/cli/configPlugin.js",
|
|
@@ -47,6 +60,12 @@
|
|
|
47
60
|
],
|
|
48
61
|
"ssr-plugin": [
|
|
49
62
|
"./dist/types/cli/ssrPlugin.d.ts"
|
|
63
|
+
],
|
|
64
|
+
"data-loader-plugin": [
|
|
65
|
+
"./dist/types/cli/dataLoaderPlugin.d.ts"
|
|
66
|
+
],
|
|
67
|
+
"data-loader": [
|
|
68
|
+
"./dist/types/runtime/dataLoader.d.ts"
|
|
50
69
|
]
|
|
51
70
|
}
|
|
52
71
|
},
|
|
@@ -55,24 +74,31 @@
|
|
|
55
74
|
"author": "hanric <hanric.zhang@gmail.com>",
|
|
56
75
|
"license": "MIT",
|
|
57
76
|
"dependencies": {
|
|
58
|
-
"@swc/helpers": "0.5.
|
|
77
|
+
"@swc/helpers": "0.5.3",
|
|
59
78
|
"@modern-js/utils": "2.54.2",
|
|
60
79
|
"@modern-js/node-bundle-require": "2.54.2",
|
|
61
80
|
"node-fetch": "~3.3.0",
|
|
62
81
|
"react-error-boundary": "4.0.13",
|
|
63
82
|
"hoist-non-react-statics": "3.3.2",
|
|
64
|
-
"@
|
|
65
|
-
"@
|
|
66
|
-
"@
|
|
83
|
+
"@babel/generator": "7.25.0",
|
|
84
|
+
"@babel/parser": "7.25.3",
|
|
85
|
+
"@babel/traverse": "7.25.3",
|
|
86
|
+
"@babel/types": "7.25.2",
|
|
87
|
+
"@module-federation/sdk": "0.0.0-next-20240814082511",
|
|
88
|
+
"@module-federation/enhanced": "0.0.0-next-20240814082511",
|
|
89
|
+
"@module-federation/node": "0.0.0-next-20240814082511"
|
|
67
90
|
},
|
|
68
91
|
"devDependencies": {
|
|
92
|
+
"@types/babel__traverse": "7.20.6",
|
|
93
|
+
"@types/babel__generator": "7.6.8",
|
|
69
94
|
"@types/hoist-non-react-statics": "3.3.2",
|
|
70
|
-
"@modern-js/
|
|
71
|
-
"@modern-js/
|
|
72
|
-
"@modern-js/
|
|
73
|
-
"@modern-js/
|
|
74
|
-
"@modern-js/
|
|
75
|
-
"@
|
|
95
|
+
"@modern-js/server-core": "0.0.0-next-20240814063139",
|
|
96
|
+
"@modern-js/app-tools": "0.0.0-next-20240814063139",
|
|
97
|
+
"@modern-js/core": "0.0.0-next-20240814063139",
|
|
98
|
+
"@modern-js/runtime": "0.0.0-next-20240814063139",
|
|
99
|
+
"@modern-js/module-tools": "0.0.0-next-20240814063139",
|
|
100
|
+
"@modern-js/tsconfig": "0.0.0-next-20240814063139",
|
|
101
|
+
"@module-federation/manifest": "0.0.0-next-20240814082511"
|
|
76
102
|
},
|
|
77
103
|
"peerDependencies": {
|
|
78
104
|
"react": ">=17",
|