@module-federation/modern-js 0.0.0-next-20250618045528 → 0.0.0-next-20250618090118
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/LICENSE +21 -0
- package/dist/cjs/cli/configPlugin.js +381 -0
- package/dist/cjs/cli/configPlugin.spec.js +114 -0
- package/dist/cjs/cli/index.js +95 -0
- package/dist/cjs/cli/mfRuntimePlugins/inject-node-fetch.js +44 -0
- package/dist/cjs/cli/mfRuntimePlugins/resolve-entry-ipv4.js +82 -0
- package/dist/cjs/cli/mfRuntimePlugins/shared-strategy.js +43 -0
- package/dist/cjs/cli/server/data-fetch-server-plugin.js +48 -0
- package/dist/cjs/cli/ssrPlugin.js +236 -0
- package/dist/cjs/cli/utils.js +90 -0
- package/dist/cjs/constant.js +31 -0
- package/dist/cjs/interfaces/bundler.js +16 -0
- package/dist/cjs/logger.js +27 -0
- package/dist/cjs/react/index.js +67 -0
- package/dist/cjs/runtime/index.js +22 -0
- package/dist/cjs/server/fileCache.js +84 -0
- package/dist/cjs/server/fileCache.spec.js +28 -0
- package/dist/cjs/server/index.js +58 -0
- package/dist/cjs/server/staticMiddleware.js +77 -0
- package/dist/cjs/server/staticMiddleware.spec.js +185 -0
- package/dist/cjs/ssr-runtime/SSRLiveReload.js +43 -0
- package/dist/cjs/ssr-runtime/devPlugin.js +71 -0
- package/dist/cjs/ssr-runtime/injectDataFetchFunctionPlugin.js +41 -0
- package/dist/cjs/types/index.js +16 -0
- package/dist/esm/cli/configPlugin.js +388 -0
- package/dist/esm/cli/configPlugin.spec.js +110 -0
- package/dist/esm/cli/index.js +90 -0
- package/dist/esm/cli/mfRuntimePlugins/inject-node-fetch.js +16 -0
- package/dist/esm/cli/mfRuntimePlugins/resolve-entry-ipv4.js +74 -0
- package/dist/esm/cli/mfRuntimePlugins/shared-strategy.js +25 -0
- package/dist/esm/cli/server/data-fetch-server-plugin.js +20 -0
- package/dist/esm/cli/ssrPlugin.js +219 -0
- package/dist/esm/cli/utils.js +53 -0
- package/dist/esm/constant.js +6 -0
- package/dist/esm/interfaces/bundler.js +0 -0
- package/dist/esm/logger.js +7 -0
- package/dist/esm/react/index.js +28 -0
- package/dist/esm/runtime/index.js +1 -0
- package/dist/esm/server/fileCache.js +98 -0
- package/dist/esm/server/fileCache.spec.js +50 -0
- package/dist/esm/server/index.js +36 -0
- package/dist/esm/server/staticMiddleware.js +81 -0
- package/dist/esm/server/staticMiddleware.spec.js +328 -0
- package/dist/esm/ssr-runtime/SSRLiveReload.js +26 -0
- package/dist/esm/ssr-runtime/devPlugin.js +73 -0
- package/dist/esm/ssr-runtime/injectDataFetchFunctionPlugin.js +35 -0
- package/dist/esm/types/index.js +0 -0
- package/dist/esm-node/cli/configPlugin.js +340 -0
- package/dist/esm-node/cli/configPlugin.spec.js +91 -0
- package/dist/esm-node/cli/index.js +70 -0
- package/dist/esm-node/cli/mfRuntimePlugins/inject-node-fetch.js +14 -0
- package/dist/esm-node/cli/mfRuntimePlugins/resolve-entry-ipv4.js +62 -0
- package/dist/esm-node/cli/mfRuntimePlugins/shared-strategy.js +23 -0
- package/dist/esm-node/cli/server/data-fetch-server-plugin.js +18 -0
- package/dist/esm-node/cli/ssrPlugin.js +200 -0
- package/dist/esm-node/cli/utils.js +53 -0
- package/dist/esm-node/constant.js +6 -0
- package/dist/esm-node/interfaces/bundler.js +0 -0
- package/dist/esm-node/logger.js +7 -0
- package/dist/esm-node/react/index.js +29 -0
- package/dist/esm-node/runtime/index.js +1 -0
- package/dist/esm-node/server/fileCache.js +49 -0
- package/dist/esm-node/server/fileCache.spec.js +27 -0
- package/dist/esm-node/server/index.js +34 -0
- package/dist/esm-node/server/staticMiddleware.js +43 -0
- package/dist/esm-node/server/staticMiddleware.spec.js +162 -0
- package/dist/esm-node/ssr-runtime/SSRLiveReload.js +19 -0
- package/dist/esm-node/ssr-runtime/devPlugin.js +37 -0
- package/dist/esm-node/ssr-runtime/injectDataFetchFunctionPlugin.js +17 -0
- package/dist/esm-node/types/index.js +0 -0
- package/dist/types/cli/configPlugin.d.ts +21 -0
- package/dist/types/cli/configPlugin.spec.d.ts +1 -0
- package/dist/types/cli/index.d.ts +6 -0
- package/dist/types/cli/mfRuntimePlugins/inject-node-fetch.d.ts +3 -0
- package/dist/types/cli/mfRuntimePlugins/resolve-entry-ipv4.d.ts +3 -0
- package/dist/types/cli/mfRuntimePlugins/shared-strategy.d.ts +3 -0
- package/dist/types/cli/server/data-fetch-server-plugin.d.ts +3 -0
- package/dist/types/cli/ssrPlugin.d.ts +6 -0
- package/dist/types/cli/utils.d.ts +6 -0
- package/dist/types/constant.d.ts +2 -0
- package/dist/types/interfaces/bundler.d.ts +18 -0
- package/dist/types/logger.d.ts +2 -0
- package/dist/types/react/index.d.ts +10 -0
- package/dist/types/runtime/index.d.ts +1 -0
- package/dist/types/server/fileCache.d.ts +14 -0
- package/dist/types/server/fileCache.spec.d.ts +1 -0
- package/dist/types/server/index.d.ts +4 -0
- package/dist/types/server/staticMiddleware.d.ts +6 -0
- package/dist/types/server/staticMiddleware.spec.d.ts +1 -0
- package/dist/types/ssr-runtime/SSRLiveReload.d.ts +1 -0
- package/dist/types/ssr-runtime/devPlugin.d.ts +2 -0
- package/dist/types/ssr-runtime/injectDataFetchFunctionPlugin.d.ts +4 -0
- package/dist/types/types/index.d.ts +24 -0
- package/package.json +37 -12
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { callDataFetch, injectDataFetch } from "@module-federation/bridge-react/data-fetch-utils";
|
|
2
|
+
import { setSSREnv } from "@module-federation/bridge-react/lazy-utils";
|
|
3
|
+
const injectDataFetchFunctionPlugin = ({ fetchServerQuery }) => ({
|
|
4
|
+
name: "@module-federation/inject-data-fetch-function-plugin",
|
|
5
|
+
setup: (api) => {
|
|
6
|
+
api.onBeforeRender(async () => {
|
|
7
|
+
setSSREnv({
|
|
8
|
+
fetchServerQuery
|
|
9
|
+
});
|
|
10
|
+
injectDataFetch();
|
|
11
|
+
await callDataFetch();
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
export {
|
|
16
|
+
injectDataFetchFunctionPlugin
|
|
17
|
+
};
|
|
File without changes
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { isWebTarget, skipByTarget } from './utils';
|
|
2
|
+
import { moduleFederationPlugin } from '@module-federation/sdk';
|
|
3
|
+
import { PluginOptions } from '../types';
|
|
4
|
+
import type { InternalModernPluginOptions } from '../types';
|
|
5
|
+
import type { AppTools, webpack, UserConfig, Rspack, CliPluginFuture } from '@modern-js/app-tools';
|
|
6
|
+
import type { BundlerChainConfig } from '../interfaces/bundler';
|
|
7
|
+
export type ConfigType<T> = T extends 'webpack' ? webpack.Configuration : T extends 'rspack' ? Rspack.Configuration : never;
|
|
8
|
+
export declare function setEnv(enableSSR: boolean): void;
|
|
9
|
+
export declare const getMFConfig: (userConfig: PluginOptions) => Promise<moduleFederationPlugin.ModuleFederationPluginOptions>;
|
|
10
|
+
export declare const patchMFConfig: (mfConfig: moduleFederationPlugin.ModuleFederationPluginOptions, isServer: boolean, remoteIpStrategy?: "ipv4" | "inherit", enableSSR?: boolean) => moduleFederationPlugin.ModuleFederationPluginOptions;
|
|
11
|
+
export declare function addMyTypes2Ignored(chain: BundlerChainConfig, mfConfig: moduleFederationPlugin.ModuleFederationPluginOptions): void;
|
|
12
|
+
export declare function patchBundlerConfig(options: {
|
|
13
|
+
chain: BundlerChainConfig;
|
|
14
|
+
isServer: boolean;
|
|
15
|
+
modernjsConfig: UserConfig<AppTools>;
|
|
16
|
+
mfConfig: moduleFederationPlugin.ModuleFederationPluginOptions;
|
|
17
|
+
enableSSR: boolean;
|
|
18
|
+
}): void;
|
|
19
|
+
export declare const moduleFederationConfigPlugin: (userConfig: InternalModernPluginOptions) => CliPluginFuture<AppTools>;
|
|
20
|
+
export default moduleFederationConfigPlugin;
|
|
21
|
+
export { isWebTarget, skipByTarget };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { CliPluginFuture, AppTools } from '@modern-js/app-tools';
|
|
2
|
+
import type { PluginOptions } from '../types';
|
|
3
|
+
export declare const moduleFederationPlugin: (userConfig?: PluginOptions) => CliPluginFuture<AppTools>;
|
|
4
|
+
export default moduleFederationPlugin;
|
|
5
|
+
export { createModuleFederationConfig } from '@module-federation/enhanced';
|
|
6
|
+
export type { FederationRuntimePlugin } from '@module-federation/enhanced/runtime';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { CliPluginFuture, AppTools } from '@modern-js/app-tools';
|
|
2
|
+
import type { InternalModernPluginOptions } from '../types';
|
|
3
|
+
export declare function setEnv(): void;
|
|
4
|
+
export declare const CHAIN_MF_PLUGIN_ID = "plugin-module-federation-server";
|
|
5
|
+
export declare const moduleFederationSSRPlugin: (pluginOptions: Required<InternalModernPluginOptions>) => CliPluginFuture<AppTools>;
|
|
6
|
+
export default moduleFederationSSRPlugin;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { webpack, Rspack } from '@modern-js/app-tools';
|
|
2
|
+
export type ConfigType<T> = T extends 'webpack' ? webpack.Configuration : T extends 'rspack' ? Rspack.Configuration : never;
|
|
3
|
+
export declare const getIPV4: () => string;
|
|
4
|
+
export declare const isWebTarget: (target: string[] | string) => boolean;
|
|
5
|
+
export declare const skipByTarget: (target: string[] | string) => boolean;
|
|
6
|
+
export declare function isDev(): boolean;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { AppTools, Bundler, UserConfig } from '@modern-js/app-tools';
|
|
2
|
+
type AppToolsUserConfig<T extends Bundler> = AppTools<T>['userConfig']['tools'];
|
|
3
|
+
type ExcludeUndefined<T> = T extends undefined ? never : T;
|
|
4
|
+
type ExtractObjectType<T> = T extends (...args: any[]) => any ? never : T;
|
|
5
|
+
type OmitArrayConfiguration<T> = T extends Array<any> ? (T extends (infer U)[] ? U : T) : ExtractObjectType<T>;
|
|
6
|
+
type WebpackConfigs = ExcludeUndefined<AppToolsUserConfig<'webpack'>> extends {
|
|
7
|
+
webpack?: infer U;
|
|
8
|
+
} ? U : never;
|
|
9
|
+
type ObjectWebpack = ExtractObjectType<OmitArrayConfiguration<WebpackConfigs>>;
|
|
10
|
+
type RspackConfigs = ExcludeUndefined<AppToolsUserConfig<'rspack'>> extends {
|
|
11
|
+
rspack?: infer U;
|
|
12
|
+
} ? U : never;
|
|
13
|
+
type ObjectRspack = ExtractObjectType<OmitArrayConfiguration<RspackConfigs>>;
|
|
14
|
+
type BundlerChain = ExcludeUndefined<ExcludeUndefined<UserConfig<AppTools>['tools']>['bundlerChain']>;
|
|
15
|
+
type BundlerChainFunc = Extract<BundlerChain, (chain: any, utils: any) => any>;
|
|
16
|
+
export type BundlerChainConfig = Parameters<BundlerChainFunc>[0];
|
|
17
|
+
export type BundlerConfig<T extends Bundler> = T extends 'rspack' ? ObjectRspack : ObjectWebpack;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ERROR_TYPE, createLazyComponent as rawCreateLazyComponent, collectSSRAssets as rawCollectSsrAssets, injectDataFetch } from '@module-federation/bridge-react';
|
|
2
|
+
import type { CollectSSRAssetsOptions, CreateLazyComponentOptions } from '@module-federation/bridge-react';
|
|
3
|
+
export { ERROR_TYPE };
|
|
4
|
+
type NewCreateLazyComponentOptions<T, E extends keyof T> = Omit<CreateLazyComponentOptions<T, E>, 'runtime'>;
|
|
5
|
+
type NewCreateLazyComponent = <T, E extends keyof T>(options: NewCreateLazyComponentOptions<T, E>) => ReturnType<typeof rawCreateLazyComponent<T, E>>;
|
|
6
|
+
export declare const createLazyComponent: NewCreateLazyComponent;
|
|
7
|
+
export declare const collectSSRAssets: (options: Omit<CollectSSRAssetsOptions, 'runtime'>) => ReturnType<typeof rawCollectSsrAssets>;
|
|
8
|
+
export declare function wrapNoSSR<T, E extends keyof T>(createLazyComponentFn: typeof createLazyComponent<T, E>): (options: Omit<NewCreateLazyComponentOptions<T, E>, 'noSSR'>) => ReturnType<typeof createLazyComponent<T, E>>;
|
|
9
|
+
export { injectDataFetch };
|
|
10
|
+
export type { DataFetchParams } from '@module-federation/bridge-react';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@module-federation/enhanced/runtime';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface FileResult {
|
|
2
|
+
content: string;
|
|
3
|
+
lastModified: number;
|
|
4
|
+
}
|
|
5
|
+
export declare class FileCache {
|
|
6
|
+
private cache;
|
|
7
|
+
/**
|
|
8
|
+
* Check if file exists and return file info
|
|
9
|
+
* @param filepath Path to the file
|
|
10
|
+
* @returns FileResult or null if file doesn't exist
|
|
11
|
+
*/
|
|
12
|
+
getFile(filepath: string): Promise<FileResult | null>;
|
|
13
|
+
}
|
|
14
|
+
export declare const fileCache: FileCache;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function SSRLiveReload(): import("react").JSX.Element | null;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { moduleFederationPlugin } from '@module-federation/sdk';
|
|
2
|
+
import type { ModuleFederationPlugin as WebpackModuleFederationPlugin } from '@module-federation/enhanced';
|
|
3
|
+
import type { ModuleFederationPlugin as RspackModuleFederationPlugin } from '@module-federation/enhanced/rspack';
|
|
4
|
+
export interface PluginOptions {
|
|
5
|
+
config?: moduleFederationPlugin.ModuleFederationPluginOptions;
|
|
6
|
+
configPath?: string;
|
|
7
|
+
ssr?: {
|
|
8
|
+
distOutputDir?: string;
|
|
9
|
+
} | boolean;
|
|
10
|
+
remoteIpStrategy?: 'ipv4' | 'inherit';
|
|
11
|
+
fetchServerQuery?: Record<string, unknown>;
|
|
12
|
+
}
|
|
13
|
+
export interface InternalModernPluginOptions {
|
|
14
|
+
csrConfig?: moduleFederationPlugin.ModuleFederationPluginOptions;
|
|
15
|
+
ssrConfig?: moduleFederationPlugin.ModuleFederationPluginOptions;
|
|
16
|
+
distOutputDir: string;
|
|
17
|
+
originPluginOptions: PluginOptions;
|
|
18
|
+
browserPlugin?: BundlerPlugin;
|
|
19
|
+
nodePlugin?: BundlerPlugin;
|
|
20
|
+
remoteIpStrategy?: 'ipv4' | 'inherit';
|
|
21
|
+
userConfig?: PluginOptions;
|
|
22
|
+
fetchServerQuery?: Record<string, unknown>;
|
|
23
|
+
}
|
|
24
|
+
export type BundlerPlugin = WebpackModuleFederationPlugin | RspackModuleFederationPlugin;
|
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-20250618090118",
|
|
4
4
|
"files": [
|
|
5
5
|
"dist/",
|
|
6
6
|
"types.d.ts",
|
|
@@ -24,9 +24,17 @@
|
|
|
24
24
|
"types": "./dist/types/runtime/index.d.ts",
|
|
25
25
|
"default": "./dist/esm/runtime/index.js"
|
|
26
26
|
},
|
|
27
|
-
"./
|
|
28
|
-
"types": "./dist/types/
|
|
29
|
-
"default": "./dist/esm/
|
|
27
|
+
"./react": {
|
|
28
|
+
"types": "./dist/types/react/index.d.ts",
|
|
29
|
+
"default": "./dist/esm/react/index.js"
|
|
30
|
+
},
|
|
31
|
+
"./ssr-dev-plugin": {
|
|
32
|
+
"types": "./dist/types/ssr-runtime/devPlugin.d.ts",
|
|
33
|
+
"default": "./dist/esm/ssr-runtime/devPlugin.js"
|
|
34
|
+
},
|
|
35
|
+
"./ssr-inject-data-fetch-function-plugin": {
|
|
36
|
+
"types": "./dist/types/ssr-runtime/injectDataFetchFunctionPlugin.d.ts",
|
|
37
|
+
"default": "./dist/esm/ssr-runtime/injectDataFetchFunctionPlugin.js"
|
|
30
38
|
},
|
|
31
39
|
"./config-plugin": {
|
|
32
40
|
"types": "./dist/types/cli/configPlugin.d.ts",
|
|
@@ -53,6 +61,10 @@
|
|
|
53
61
|
"import": "./dist/esm/cli/mfRuntimePlugins/inject-node-fetch.js",
|
|
54
62
|
"require": "./dist/esm/cli/mfRuntimePlugins/inject-node-fetch.js"
|
|
55
63
|
},
|
|
64
|
+
"./data-fetch-server-plugin": {
|
|
65
|
+
"types": "./dist/types/cli/server/data-fetch-server-plugin.d.ts",
|
|
66
|
+
"default": "./dist/cjs/cli/server/data-fetch-server-plugin.js"
|
|
67
|
+
},
|
|
56
68
|
"./server": {
|
|
57
69
|
"types": "./dist/types/server/index.d.ts",
|
|
58
70
|
"default": "./dist/cjs/server/index.js"
|
|
@@ -66,6 +78,9 @@
|
|
|
66
78
|
"runtime": [
|
|
67
79
|
"./dist/types/runtime/index.d.ts"
|
|
68
80
|
],
|
|
81
|
+
"react": [
|
|
82
|
+
"./dist/types/react/index.d.ts"
|
|
83
|
+
],
|
|
69
84
|
"config-plugin": [
|
|
70
85
|
"./dist/types/cli/configPlugin.d.ts"
|
|
71
86
|
],
|
|
@@ -81,6 +96,12 @@
|
|
|
81
96
|
"inject-node-fetch": [
|
|
82
97
|
"./dist/types/cli/mfRuntimePlugins/inject-node-fetch.d.ts"
|
|
83
98
|
],
|
|
99
|
+
"data-fetch-server-plugin": [
|
|
100
|
+
"./dist/types/cli/server/data-fetch-server-plugin.d.ts"
|
|
101
|
+
],
|
|
102
|
+
"ssr-inject-data-fetch-function-plugin": [
|
|
103
|
+
"./dist/types/ssr-runtime/injectDataFetchFunctionPlugin.d.ts"
|
|
104
|
+
],
|
|
84
105
|
"server": [
|
|
85
106
|
"./dist/types/server/index.d.ts"
|
|
86
107
|
]
|
|
@@ -91,26 +112,30 @@
|
|
|
91
112
|
"author": "hanric <hanric.zhang@gmail.com>",
|
|
92
113
|
"license": "MIT",
|
|
93
114
|
"dependencies": {
|
|
115
|
+
"@modern-js/utils": "2.67.5",
|
|
94
116
|
"@modern-js/node-bundle-require": "2.67.6",
|
|
95
117
|
"fs-extra": "11.3.0",
|
|
96
118
|
"lru-cache": "10.4.3",
|
|
97
|
-
"@swc/helpers": "0.5.
|
|
119
|
+
"@swc/helpers": "^0.5.17",
|
|
98
120
|
"node-fetch": "~3.3.0",
|
|
99
121
|
"react-error-boundary": "4.1.2",
|
|
100
|
-
"@module-federation/rsbuild-plugin": "0.0.0-next-
|
|
101
|
-
"@module-federation/
|
|
102
|
-
"@module-federation/
|
|
103
|
-
"@module-federation/
|
|
104
|
-
"@module-federation/
|
|
122
|
+
"@module-federation/rsbuild-plugin": "0.0.0-next-20250618090118",
|
|
123
|
+
"@module-federation/bridge-react": "0.0.0-next-20250618090118",
|
|
124
|
+
"@module-federation/enhanced": "0.0.0-next-20250618090118",
|
|
125
|
+
"@module-federation/runtime": "0.0.0-next-20250618090118",
|
|
126
|
+
"@module-federation/node": "0.0.0-next-20250618090118",
|
|
127
|
+
"@module-federation/sdk": "0.0.0-next-20250618090118",
|
|
128
|
+
"@module-federation/cli": "0.0.0-next-20250618090118"
|
|
105
129
|
},
|
|
106
130
|
"devDependencies": {
|
|
107
|
-
"@
|
|
131
|
+
"@modern-js/core": "2.67.5",
|
|
132
|
+
"@rsbuild/core": "1.3.21",
|
|
108
133
|
"@modern-js/app-tools": "2.67.6",
|
|
109
134
|
"@modern-js/server-runtime": "2.67.6",
|
|
110
135
|
"@modern-js/module-tools": "2.67.6",
|
|
111
136
|
"@modern-js/runtime": "2.67.6",
|
|
112
137
|
"@modern-js/tsconfig": "2.67.6",
|
|
113
|
-
"@module-federation/manifest": "0.0.0-next-
|
|
138
|
+
"@module-federation/manifest": "0.0.0-next-20250618090118"
|
|
114
139
|
},
|
|
115
140
|
"peerDependencies": {
|
|
116
141
|
"react": ">=17",
|