@module-federation/modern-js 0.0.0-next-20250613163655 → 0.0.0-next-20250616091910

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 (90) hide show
  1. package/dist/LICENSE +21 -0
  2. package/dist/cjs/cli/configPlugin.js +381 -0
  3. package/dist/cjs/cli/configPlugin.spec.js +114 -0
  4. package/dist/cjs/cli/index.js +95 -0
  5. package/dist/cjs/cli/mfRuntimePlugins/inject-node-fetch.js +44 -0
  6. package/dist/cjs/cli/mfRuntimePlugins/resolve-entry-ipv4.js +82 -0
  7. package/dist/cjs/cli/mfRuntimePlugins/shared-strategy.js +43 -0
  8. package/dist/cjs/cli/server/data-fetch-server-plugin.js +188 -0
  9. package/dist/cjs/cli/ssrPlugin.js +236 -0
  10. package/dist/cjs/cli/utils.js +90 -0
  11. package/dist/cjs/constant.js +31 -0
  12. package/dist/cjs/interfaces/bundler.js +16 -0
  13. package/dist/cjs/logger.js +27 -0
  14. package/dist/cjs/runtime/index.js +33 -0
  15. package/dist/cjs/server/fileCache.js +84 -0
  16. package/dist/cjs/server/fileCache.spec.js +28 -0
  17. package/dist/cjs/server/index.js +58 -0
  18. package/dist/cjs/server/staticMiddleware.js +77 -0
  19. package/dist/cjs/server/staticMiddleware.spec.js +185 -0
  20. package/dist/cjs/ssr-runtime/SSRLiveReload.js +43 -0
  21. package/dist/cjs/ssr-runtime/devPlugin.js +71 -0
  22. package/dist/cjs/ssr-runtime/injectDataFetchFunctionPlugin.js +41 -0
  23. package/dist/cjs/types/index.js +16 -0
  24. package/dist/esm/cli/configPlugin.js +388 -0
  25. package/dist/esm/cli/configPlugin.spec.js +110 -0
  26. package/dist/esm/cli/index.js +90 -0
  27. package/dist/esm/cli/mfRuntimePlugins/inject-node-fetch.js +16 -0
  28. package/dist/esm/cli/mfRuntimePlugins/resolve-entry-ipv4.js +74 -0
  29. package/dist/esm/cli/mfRuntimePlugins/shared-strategy.js +25 -0
  30. package/dist/esm/cli/server/data-fetch-server-plugin.js +236 -0
  31. package/dist/esm/cli/ssrPlugin.js +219 -0
  32. package/dist/esm/cli/utils.js +53 -0
  33. package/dist/esm/constant.js +6 -0
  34. package/dist/esm/interfaces/bundler.js +0 -0
  35. package/dist/esm/logger.js +7 -0
  36. package/dist/esm/runtime/index.js +6 -0
  37. package/dist/esm/server/fileCache.js +98 -0
  38. package/dist/esm/server/fileCache.spec.js +50 -0
  39. package/dist/esm/server/index.js +36 -0
  40. package/dist/esm/server/staticMiddleware.js +81 -0
  41. package/dist/esm/server/staticMiddleware.spec.js +328 -0
  42. package/dist/esm/ssr-runtime/SSRLiveReload.js +26 -0
  43. package/dist/esm/ssr-runtime/devPlugin.js +73 -0
  44. package/dist/esm/ssr-runtime/injectDataFetchFunctionPlugin.js +35 -0
  45. package/dist/esm/types/index.js +0 -0
  46. package/dist/esm-node/cli/configPlugin.js +340 -0
  47. package/dist/esm-node/cli/configPlugin.spec.js +91 -0
  48. package/dist/esm-node/cli/index.js +70 -0
  49. package/dist/esm-node/cli/mfRuntimePlugins/inject-node-fetch.js +14 -0
  50. package/dist/esm-node/cli/mfRuntimePlugins/resolve-entry-ipv4.js +62 -0
  51. package/dist/esm-node/cli/mfRuntimePlugins/shared-strategy.js +23 -0
  52. package/dist/esm-node/cli/server/data-fetch-server-plugin.js +158 -0
  53. package/dist/esm-node/cli/ssrPlugin.js +200 -0
  54. package/dist/esm-node/cli/utils.js +53 -0
  55. package/dist/esm-node/constant.js +6 -0
  56. package/dist/esm-node/interfaces/bundler.js +0 -0
  57. package/dist/esm-node/logger.js +7 -0
  58. package/dist/esm-node/runtime/index.js +6 -0
  59. package/dist/esm-node/server/fileCache.js +49 -0
  60. package/dist/esm-node/server/fileCache.spec.js +27 -0
  61. package/dist/esm-node/server/index.js +34 -0
  62. package/dist/esm-node/server/staticMiddleware.js +43 -0
  63. package/dist/esm-node/server/staticMiddleware.spec.js +162 -0
  64. package/dist/esm-node/ssr-runtime/SSRLiveReload.js +19 -0
  65. package/dist/esm-node/ssr-runtime/devPlugin.js +37 -0
  66. package/dist/esm-node/ssr-runtime/injectDataFetchFunctionPlugin.js +17 -0
  67. package/dist/esm-node/types/index.js +0 -0
  68. package/dist/types/cli/configPlugin.d.ts +21 -0
  69. package/dist/types/cli/configPlugin.spec.d.ts +1 -0
  70. package/dist/types/cli/index.d.ts +6 -0
  71. package/dist/types/cli/mfRuntimePlugins/inject-node-fetch.d.ts +3 -0
  72. package/dist/types/cli/mfRuntimePlugins/resolve-entry-ipv4.d.ts +3 -0
  73. package/dist/types/cli/mfRuntimePlugins/shared-strategy.d.ts +3 -0
  74. package/dist/types/cli/server/data-fetch-server-plugin.d.ts +3 -0
  75. package/dist/types/cli/ssrPlugin.d.ts +6 -0
  76. package/dist/types/cli/utils.d.ts +6 -0
  77. package/dist/types/constant.d.ts +2 -0
  78. package/dist/types/interfaces/bundler.d.ts +18 -0
  79. package/dist/types/logger.d.ts +2 -0
  80. package/dist/types/runtime/index.d.ts +3 -0
  81. package/dist/types/server/fileCache.d.ts +14 -0
  82. package/dist/types/server/fileCache.spec.d.ts +1 -0
  83. package/dist/types/server/index.d.ts +4 -0
  84. package/dist/types/server/staticMiddleware.d.ts +6 -0
  85. package/dist/types/server/staticMiddleware.spec.d.ts +1 -0
  86. package/dist/types/ssr-runtime/SSRLiveReload.d.ts +1 -0
  87. package/dist/types/ssr-runtime/devPlugin.d.ts +2 -0
  88. package/dist/types/ssr-runtime/injectDataFetchFunctionPlugin.d.ts +4 -0
  89. package/dist/types/types/index.d.ts +24 -0
  90. package/package.json +9 -16
@@ -0,0 +1,162 @@
1
+ import { it, expect, describe, vi, beforeEach } from "vitest";
2
+ import { createStaticMiddleware } from "./staticMiddleware";
3
+ vi.mock("fs-extra", () => ({
4
+ default: {
5
+ pathExists: vi.fn()
6
+ }
7
+ }));
8
+ vi.mock("./fileCache", () => ({
9
+ fileCache: {
10
+ getFile: vi.fn()
11
+ }
12
+ }));
13
+ import fs from "fs-extra";
14
+ import { fileCache } from "./fileCache";
15
+ describe("staticMiddleware", () => {
16
+ let middleware;
17
+ let mockContext;
18
+ let nextSpy;
19
+ beforeEach(() => {
20
+ vi.clearAllMocks();
21
+ middleware = createStaticMiddleware({
22
+ assetPrefix: "",
23
+ pwd: "/test/path"
24
+ });
25
+ nextSpy = vi.fn();
26
+ mockContext = {
27
+ req: {
28
+ path: ""
29
+ },
30
+ header: vi.fn(),
31
+ body: vi.fn()
32
+ };
33
+ });
34
+ describe("file extension filtering", () => {
35
+ it("should call next() for non-js files", async () => {
36
+ mockContext.req.path = "/bundles/test.css";
37
+ await middleware(mockContext, nextSpy);
38
+ expect(nextSpy).toHaveBeenCalledOnce();
39
+ expect(mockContext.header).not.toHaveBeenCalled();
40
+ expect(mockContext.body).not.toHaveBeenCalled();
41
+ });
42
+ it("should call next() for files without extension", async () => {
43
+ mockContext.req.path = "/bundles/test";
44
+ await middleware(mockContext, nextSpy);
45
+ expect(nextSpy).toHaveBeenCalledOnce();
46
+ expect(mockContext.header).not.toHaveBeenCalled();
47
+ expect(mockContext.body).not.toHaveBeenCalled();
48
+ });
49
+ it("should process .js files", async () => {
50
+ mockContext.req.path = "/bundles/test.js";
51
+ fs.pathExists.mockResolvedValue(false);
52
+ await middleware(mockContext, nextSpy);
53
+ expect(fs.pathExists).toHaveBeenCalled();
54
+ });
55
+ });
56
+ describe("asset prefix filtering", () => {
57
+ it("should call next() for paths not starting with /bundles", async () => {
58
+ mockContext.req.path = "/assets/test.js";
59
+ await middleware(mockContext, nextSpy);
60
+ expect(nextSpy).toHaveBeenCalledOnce();
61
+ expect(fs.pathExists).not.toHaveBeenCalled();
62
+ expect(mockContext.header).not.toHaveBeenCalled();
63
+ expect(mockContext.body).not.toHaveBeenCalled();
64
+ });
65
+ it("should call next() for root path", async () => {
66
+ mockContext.req.path = "/test.js";
67
+ await middleware(mockContext, nextSpy);
68
+ expect(nextSpy).toHaveBeenCalledOnce();
69
+ expect(fs.pathExists).not.toHaveBeenCalled();
70
+ });
71
+ it("should process paths starting with /bundles", async () => {
72
+ mockContext.req.path = "/bundles/test.js";
73
+ fs.pathExists.mockResolvedValue(false);
74
+ await middleware(mockContext, nextSpy);
75
+ expect(fs.pathExists).toHaveBeenCalledWith("/test/path/bundles/test.js");
76
+ });
77
+ });
78
+ describe("file existence check", () => {
79
+ it("should call next() when file does not exist", async () => {
80
+ mockContext.req.path = "/bundles/nonexistent.js";
81
+ fs.pathExists.mockResolvedValue(false);
82
+ await middleware(mockContext, nextSpy);
83
+ expect(fs.pathExists).toHaveBeenCalledWith("/test/path/bundles/nonexistent.js");
84
+ expect(nextSpy).toHaveBeenCalledOnce();
85
+ expect(fileCache.getFile).not.toHaveBeenCalled();
86
+ expect(mockContext.header).not.toHaveBeenCalled();
87
+ expect(mockContext.body).not.toHaveBeenCalled();
88
+ });
89
+ it("should proceed to file cache when file exists", async () => {
90
+ mockContext.req.path = "/bundles/existing.js";
91
+ fs.pathExists.mockResolvedValue(true);
92
+ fileCache.getFile.mockResolvedValue(null);
93
+ await middleware(mockContext, nextSpy);
94
+ expect(fs.pathExists).toHaveBeenCalledWith("/test/path/bundles/existing.js");
95
+ expect(fileCache.getFile).toHaveBeenCalledWith("/test/path/bundles/existing.js");
96
+ });
97
+ });
98
+ describe("successful file serving", () => {
99
+ it("should serve file content with correct headers", async () => {
100
+ const mockFileContent = 'console.log("test");';
101
+ const mockFileResult = {
102
+ content: mockFileContent,
103
+ lastModified: Date.now()
104
+ };
105
+ mockContext.req.path = "/bundles/app.js";
106
+ fs.pathExists.mockResolvedValue(true);
107
+ fileCache.getFile.mockResolvedValue(mockFileResult);
108
+ mockContext.body.mockReturnValue("response");
109
+ const result = await middleware(mockContext, nextSpy);
110
+ expect(fs.pathExists).toHaveBeenCalledWith("/test/path/bundles/app.js");
111
+ expect(fileCache.getFile).toHaveBeenCalledWith("/test/path/bundles/app.js");
112
+ expect(nextSpy).not.toHaveBeenCalled();
113
+ expect(mockContext.header).toHaveBeenCalledWith("Content-Type", "application/javascript");
114
+ expect(mockContext.header).toHaveBeenCalledWith("Content-Length", String(mockFileResult.content.length));
115
+ expect(mockContext.body).toHaveBeenCalledWith(mockFileResult.content, 200);
116
+ expect(result).toBe("response");
117
+ });
118
+ it("should handle empty file content", async () => {
119
+ const mockFileResult = {
120
+ content: "",
121
+ lastModified: Date.now()
122
+ };
123
+ mockContext.req.path = "/bundles/empty.js";
124
+ fs.pathExists.mockResolvedValue(true);
125
+ fileCache.getFile.mockResolvedValue(mockFileResult);
126
+ mockContext.body.mockReturnValue("empty-response");
127
+ const result = await middleware(mockContext, nextSpy);
128
+ expect(mockContext.header).toHaveBeenCalledWith("Content-Length", "0");
129
+ expect(mockContext.body).toHaveBeenCalledWith(mockFileResult.content, 200);
130
+ expect(result).toBe("empty-response");
131
+ expect(nextSpy).not.toHaveBeenCalled();
132
+ });
133
+ });
134
+ describe("asset prefix handling", () => {
135
+ it("should handle custom asset prefix correctly", async () => {
136
+ const customMiddleware = createStaticMiddleware({
137
+ assetPrefix: "/custom-prefix",
138
+ pwd: "/test/path"
139
+ });
140
+ mockContext.req.path = "/bundles/test.js";
141
+ await customMiddleware(mockContext, nextSpy);
142
+ expect(nextSpy).toHaveBeenCalledOnce();
143
+ expect(mockContext.header).not.toHaveBeenCalled();
144
+ expect(mockContext.body).not.toHaveBeenCalled();
145
+ });
146
+ it("should handle asset prefix removal correctly", async () => {
147
+ const customMiddleware = createStaticMiddleware({
148
+ assetPrefix: "/prefix",
149
+ pwd: "/test/path"
150
+ });
151
+ const mockFileResult = {
152
+ content: "test content",
153
+ lastModified: Date.now()
154
+ };
155
+ mockContext.req.path = "/prefix/bundles/test.js";
156
+ fs.pathExists.mockResolvedValue(true);
157
+ fileCache.getFile.mockResolvedValue(mockFileResult);
158
+ await customMiddleware(mockContext, nextSpy);
159
+ expect(fs.pathExists).toHaveBeenCalledWith("/test/path/bundles/test.js");
160
+ });
161
+ });
162
+ });
@@ -0,0 +1,19 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ function SSRLiveReload() {
3
+ if (process.env.NODE_ENV !== "development") {
4
+ return null;
5
+ }
6
+ return /* @__PURE__ */ _jsx("script", {
7
+ suppressHydrationWarning: true,
8
+ dangerouslySetInnerHTML: {
9
+ __html: String.raw`
10
+ if(${globalThis.shouldUpdate}){
11
+ location.reload();
12
+ }
13
+ `
14
+ }
15
+ });
16
+ }
17
+ export {
18
+ SSRLiveReload
19
+ };
@@ -0,0 +1,37 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { SSRLiveReload } from "./SSRLiveReload";
3
+ import { flushDataFetch } from "@module-federation/bridge-react/data-fetch-utils";
4
+ const mfSSRDevPlugin = () => ({
5
+ name: "@module-federation/modern-js",
6
+ setup: (api) => {
7
+ api.onBeforeRender(async () => {
8
+ if (typeof window !== "undefined") {
9
+ return;
10
+ }
11
+ globalThis.shouldUpdate = false;
12
+ const nodeUtils = await import("@module-federation/node/utils");
13
+ const shouldUpdate = await nodeUtils.revalidate();
14
+ console.log("shouldUpdate: ", shouldUpdate);
15
+ if (shouldUpdate) {
16
+ console.log("should RELOAD", shouldUpdate);
17
+ await nodeUtils.flushChunks();
18
+ flushDataFetch();
19
+ globalThis.shouldUpdate = true;
20
+ }
21
+ });
22
+ api.wrapRoot((App) => {
23
+ const AppWrapper = (props) => /* @__PURE__ */ _jsxs(_Fragment, {
24
+ children: [
25
+ /* @__PURE__ */ _jsx(SSRLiveReload, {}),
26
+ /* @__PURE__ */ _jsx(App, {
27
+ ...props
28
+ })
29
+ ]
30
+ });
31
+ return AppWrapper;
32
+ });
33
+ }
34
+ });
35
+ export {
36
+ mfSSRDevPlugin
37
+ };
@@ -0,0 +1,17 @@
1
+ import { kit } from "@module-federation/bridge-react";
2
+ const { callDataFetch, injectDataFetch, setSSREnv } = kit;
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,3 @@
1
+ import type { FederationRuntimePlugin } from '@module-federation/enhanced/runtime';
2
+ declare const injectNodeFetchPlugin: () => FederationRuntimePlugin;
3
+ export default injectNodeFetchPlugin;
@@ -0,0 +1,3 @@
1
+ import type { FederationRuntimePlugin } from '@module-federation/enhanced/runtime';
2
+ declare const resolveEntryIpv4Plugin: () => FederationRuntimePlugin;
3
+ export default resolveEntryIpv4Plugin;
@@ -0,0 +1,3 @@
1
+ import type { FederationRuntimePlugin } from '@module-federation/enhanced/runtime';
2
+ declare const sharedStrategy: () => FederationRuntimePlugin;
3
+ export default sharedStrategy;
@@ -0,0 +1,3 @@
1
+ import type { ServerPlugin } from '@modern-js/server-runtime';
2
+ declare const dataFetchServePlugin: () => ServerPlugin;
3
+ export default dataFetchServePlugin;
@@ -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,2 @@
1
+ export declare const LOCALHOST = "localhost";
2
+ export declare const PLUGIN_IDENTIFIER = "[ Modern.js Module Federation ]";
@@ -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,2 @@
1
+ declare const logger: import("@module-federation/sdk").Logger;
2
+ export default logger;
@@ -0,0 +1,3 @@
1
+ export * from '@module-federation/enhanced/runtime';
2
+ export { kit, ERROR_TYPE } from '@module-federation/bridge-react';
3
+ export type { DataFetchParams } from '@module-federation/bridge-react';
@@ -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,4 @@
1
+ import type { ServerPlugin } from '@modern-js/server-runtime';
2
+ declare const staticServePlugin: () => ServerPlugin;
3
+ export default staticServePlugin;
4
+ export { staticServePlugin };
@@ -0,0 +1,6 @@
1
+ import type { MiddlewareHandler } from '@modern-js/server-runtime';
2
+ declare const createStaticMiddleware: (options: {
3
+ assetPrefix: string;
4
+ pwd: string;
5
+ }) => MiddlewareHandler;
6
+ export { createStaticMiddleware };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export declare function SSRLiveReload(): import("react").JSX.Element | null;
@@ -0,0 +1,2 @@
1
+ import type { RuntimePluginFuture } from '@modern-js/runtime';
2
+ export declare const mfSSRDevPlugin: () => RuntimePluginFuture;
@@ -0,0 +1,4 @@
1
+ import type { RuntimePluginFuture } from '@modern-js/runtime';
2
+ export declare const injectDataFetchFunctionPlugin: ({ fetchServerQuery, }: {
3
+ fetchServerQuery?: Record<string, unknown>;
4
+ }) => RuntimePluginFuture;
@@ -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-20250613163655",
3
+ "version": "0.0.0-next-20250616091910",
4
4
  "files": [
5
5
  "dist/",
6
6
  "types.d.ts",
@@ -52,11 +52,6 @@
52
52
  "import": "./dist/esm/cli/mfRuntimePlugins/resolve-entry-ipv4.js",
53
53
  "require": "./dist/esm/cli/mfRuntimePlugins/resolve-entry-ipv4.js"
54
54
  },
55
- "./auto-fetch-data": {
56
- "types": "./dist/types/cli/mfRuntimePlugins/auto-fetch-data.d.ts",
57
- "import": "./dist/esm/cli/mfRuntimePlugins/auto-fetch-data.js",
58
- "require": "./dist/esm/cli/mfRuntimePlugins/auto-fetch-data.js"
59
- },
60
55
  "./inject-node-fetch": {
61
56
  "types": "./dist/types/cli/mfRuntimePlugins/inject-node-fetch.d.ts",
62
57
  "import": "./dist/esm/cli/mfRuntimePlugins/inject-node-fetch.js",
@@ -91,9 +86,6 @@
91
86
  "resolve-entry-ipv4": [
92
87
  "./dist/types/cli/mfRuntimePlugins/resolve-entry-ipv4.d.ts"
93
88
  ],
94
- "auto-fetch-data": [
95
- "./dist/types/cli/mfRuntimePlugins/auto-fetch-data.d.ts"
96
- ],
97
89
  "inject-node-fetch": [
98
90
  "./dist/types/cli/mfRuntimePlugins/inject-node-fetch.d.ts"
99
91
  ],
@@ -120,12 +112,13 @@
120
112
  "@swc/helpers": "^0.5.17",
121
113
  "node-fetch": "~3.3.0",
122
114
  "react-error-boundary": "4.1.2",
123
- "@module-federation/rsbuild-plugin": "0.0.0-next-20250613163655",
124
- "@module-federation/enhanced": "0.0.0-next-20250613163655",
125
- "@module-federation/runtime": "0.0.0-next-20250613163655",
126
- "@module-federation/node": "0.0.0-next-20250613163655",
127
- "@module-federation/sdk": "0.0.0-next-20250613163655",
128
- "@module-federation/cli": "0.0.0-next-20250613163655"
115
+ "@module-federation/rsbuild-plugin": "0.0.0-next-20250616091910",
116
+ "@module-federation/bridge-react": "0.0.0-next-20250616091910",
117
+ "@module-federation/enhanced": "0.0.0-next-20250616091910",
118
+ "@module-federation/runtime": "0.0.0-next-20250616091910",
119
+ "@module-federation/node": "0.0.0-next-20250616091910",
120
+ "@module-federation/sdk": "0.0.0-next-20250616091910",
121
+ "@module-federation/cli": "0.0.0-next-20250616091910"
129
122
  },
130
123
  "devDependencies": {
131
124
  "@modern-js/core": "2.67.5",
@@ -135,7 +128,7 @@
135
128
  "@modern-js/module-tools": "2.67.6",
136
129
  "@modern-js/runtime": "2.67.6",
137
130
  "@modern-js/tsconfig": "2.67.6",
138
- "@module-federation/manifest": "0.0.0-next-20250613163655"
131
+ "@module-federation/manifest": "0.0.0-next-20250616091910"
139
132
  },
140
133
  "peerDependencies": {
141
134
  "react": ">=17",