@module-federation/modern-js 0.0.0-next-20240813065037 → 0.0.0-next-20240814073142

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.
Files changed (66) hide show
  1. package/dist/cjs/cli/ast/constant.js +46 -0
  2. package/dist/cjs/cli/ast/generateRoutes.js +140 -0
  3. package/dist/cjs/cli/ast/generateSlimRoutes.js +106 -0
  4. package/dist/cjs/cli/ast/index.js +31 -0
  5. package/dist/cjs/cli/configPlugin.js +1 -0
  6. package/dist/cjs/cli/constant.js +3 -0
  7. package/dist/cjs/cli/dataLoaderPlugin.js +205 -0
  8. package/dist/cjs/cli/index.js +6 -1
  9. package/dist/cjs/cli/server/dataLoaderPlugin.js +87 -0
  10. package/dist/cjs/cli/ssrPlugin.js +4 -4
  11. package/dist/cjs/interfaces/route.js +16 -0
  12. package/dist/cjs/runtime/constant.js +34 -0
  13. package/dist/cjs/runtime/dataLoader.js +87 -0
  14. package/dist/cjs/runtime/index.js +4 -1
  15. package/dist/cjs/runtime/utils.js +43 -0
  16. package/dist/cjs/runtime/withMFRouteId.js +31 -0
  17. package/dist/cjs/ssr-runtime/plugin.js +5 -7
  18. package/dist/esm/cli/ast/constant.js +16 -0
  19. package/dist/esm/cli/ast/generateRoutes.js +107 -0
  20. package/dist/esm/cli/ast/generateSlimRoutes.js +75 -0
  21. package/dist/esm/cli/ast/index.js +6 -0
  22. package/dist/esm/cli/configPlugin.js +1 -0
  23. package/dist/esm/cli/constant.js +2 -0
  24. package/dist/esm/cli/dataLoaderPlugin.js +191 -0
  25. package/dist/esm/cli/index.js +6 -1
  26. package/dist/esm/cli/server/dataLoaderPlugin.js +132 -0
  27. package/dist/esm/cli/ssrPlugin.js +2 -2
  28. package/dist/esm/interfaces/route.js +0 -0
  29. package/dist/esm/runtime/constant.js +8 -0
  30. package/dist/esm/runtime/dataLoader.js +125 -0
  31. package/dist/esm/runtime/index.js +3 -1
  32. package/dist/esm/runtime/utils.js +16 -0
  33. package/dist/esm/runtime/withMFRouteId.js +7 -0
  34. package/dist/esm/ssr-runtime/plugin.js +5 -10
  35. package/dist/esm-node/cli/ast/constant.js +16 -0
  36. package/dist/esm-node/cli/ast/generateRoutes.js +106 -0
  37. package/dist/esm-node/cli/ast/generateSlimRoutes.js +72 -0
  38. package/dist/esm-node/cli/ast/index.js +6 -0
  39. package/dist/esm-node/cli/configPlugin.js +1 -0
  40. package/dist/esm-node/cli/constant.js +2 -0
  41. package/dist/esm-node/cli/dataLoaderPlugin.js +169 -0
  42. package/dist/esm-node/cli/index.js +6 -1
  43. package/dist/esm-node/cli/server/dataLoaderPlugin.js +67 -0
  44. package/dist/esm-node/cli/ssrPlugin.js +2 -2
  45. package/dist/esm-node/interfaces/route.js +0 -0
  46. package/dist/esm-node/runtime/constant.js +8 -0
  47. package/dist/esm-node/runtime/dataLoader.js +63 -0
  48. package/dist/esm-node/runtime/index.js +3 -1
  49. package/dist/esm-node/runtime/utils.js +19 -0
  50. package/dist/esm-node/runtime/withMFRouteId.js +7 -0
  51. package/dist/esm-node/ssr-runtime/plugin.js +5 -7
  52. package/dist/types/cli/ast/constant.d.ts +7 -0
  53. package/dist/types/cli/ast/generateRoutes.d.ts +7 -0
  54. package/dist/types/cli/ast/generateSlimRoutes.d.ts +7 -0
  55. package/dist/types/cli/ast/index.d.ts +2 -0
  56. package/dist/types/cli/constant.d.ts +1 -0
  57. package/dist/types/cli/dataLoaderPlugin.d.ts +6 -0
  58. package/dist/types/cli/server/dataLoaderPlugin.d.ts +4 -0
  59. package/dist/types/interfaces/route.d.ts +13 -0
  60. package/dist/types/runtime/constant.d.ts +3 -0
  61. package/dist/types/runtime/dataLoader.d.ts +7 -0
  62. package/dist/types/runtime/index.d.ts +1 -0
  63. package/dist/types/runtime/utils.d.ts +1 -0
  64. package/dist/types/runtime/withMFRouteId.d.ts +1 -0
  65. package/dist/types/types/index.d.ts +15 -0
  66. package/package.json +37 -11
@@ -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,3 @@
1
+ export declare const MF_SLIM_ROUTES = "mf-slim-routes";
2
+ export declare const MF_FULL_ROUTES = "mf-full-routes";
3
+ export declare const MF_ROUTES_META = "mf-routes-meta";
@@ -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;
@@ -1,2 +1,3 @@
1
1
  export * from '@module-federation/enhanced/runtime';
2
2
  export { createRemoteSSRComponent } from './createRemoteSSRComponent';
3
+ export { withMFRouteId } from './withMFRouteId';
@@ -0,0 +1 @@
1
+ export declare function transformName2Prefix(name: string): string;
@@ -0,0 +1 @@
1
+ export declare function withMFRouteId(id: string): string;
@@ -5,6 +5,7 @@ export interface PluginOptions {
5
5
  config?: moduleFederationPlugin.ModuleFederationPluginOptions;
6
6
  configPath?: string;
7
7
  remoteIpStrategy?: 'ipv4' | 'inherit';
8
+ dataLoader?: false | Pick<DataLoaderOptions, 'baseName' | 'partialSSRRemotes'>;
8
9
  }
9
10
  export interface InternalModernPluginOptions {
10
11
  csrConfig?: moduleFederationPlugin.ModuleFederationPluginOptions;
@@ -16,3 +17,17 @@ export interface InternalModernPluginOptions {
16
17
  remoteIpStrategy?: 'ipv4' | 'inherit';
17
18
  }
18
19
  export type BundlerPlugin = WebpackModuleFederationPlugin | RspackModuleFederationPlugin;
20
+ export type DataLoaderOptions = {
21
+ baseName: string;
22
+ partialSSRRemotes?: string[];
23
+ pkgName?: string;
24
+ serverPlugin?: string;
25
+ fetchSSRByRouteIds?: (partialSSRRemotes: string[], mfConfig: moduleFederationPlugin.ModuleFederationPluginOptions) => Promise<string[] | undefined>;
26
+ patchMFConfig?: (options: {
27
+ mfConfig: moduleFederationPlugin.ModuleFederationPluginOptions;
28
+ baseName: string;
29
+ pkgName: string;
30
+ isServer: boolean;
31
+ routesFilePath: string;
32
+ }) => void;
33
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/modern-js",
3
- "version": "0.0.0-next-20240813065037",
3
+ "version": "0.0.0-next-20240814073142",
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.12",
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
- "@module-federation/sdk": "0.0.0-next-20240813065037",
65
- "@module-federation/enhanced": "0.0.0-next-20240813065037",
66
- "@module-federation/node": "0.0.0-next-20240813065037"
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-20240814073142",
88
+ "@module-federation/enhanced": "0.0.0-next-20240814073142",
89
+ "@module-federation/node": "0.0.0-next-20240814073142"
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/app-tools": "2.57.0",
71
- "@modern-js/core": "2.57.0",
72
- "@modern-js/runtime": "2.57.0",
73
- "@modern-js/module-tools": "2.57.0",
74
- "@modern-js/tsconfig": "2.57.0",
75
- "@module-federation/manifest": "0.0.0-next-20240813065037"
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-20240814073142"
76
102
  },
77
103
  "peerDependencies": {
78
104
  "react": ">=17",