@module-federation/modern-js 0.14.2 → 0.14.3
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 +377 -0
- package/dist/cjs/cli/configPlugin.spec.js +112 -0
- package/dist/cjs/cli/constant.js +28 -0
- package/dist/cjs/cli/index.js +93 -0
- package/dist/cjs/cli/logger.js +27 -0
- package/dist/cjs/cli/manifest.js +75 -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/ssrPlugin.js +217 -0
- package/dist/cjs/cli/utils.js +85 -0
- package/dist/cjs/constant.js +31 -0
- package/dist/cjs/interfaces/bundler.js +16 -0
- package/dist/cjs/runtime/createRemoteSSRComponent.js +201 -0
- package/dist/cjs/runtime/index.js +38 -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/index.js +22 -0
- package/dist/cjs/ssr-runtime/plugin.js +68 -0
- package/dist/cjs/types/index.js +16 -0
- package/dist/esm/cli/configPlugin.js +384 -0
- package/dist/esm/cli/configPlugin.spec.js +108 -0
- package/dist/esm/cli/constant.js +4 -0
- package/dist/esm/cli/index.js +88 -0
- package/dist/esm/cli/logger.js +7 -0
- package/dist/esm/cli/manifest.js +41 -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/ssrPlugin.js +199 -0
- package/dist/esm/cli/utils.js +49 -0
- package/dist/esm/constant.js +6 -0
- package/dist/esm/interfaces/bundler.js +0 -0
- package/dist/esm/runtime/createRemoteSSRComponent.js +191 -0
- package/dist/esm/runtime/index.js +12 -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/index.js +1 -0
- package/dist/esm/ssr-runtime/plugin.js +70 -0
- package/dist/esm/types/index.js +0 -0
- package/dist/esm-node/cli/configPlugin.js +336 -0
- package/dist/esm-node/cli/configPlugin.spec.js +89 -0
- package/dist/esm-node/cli/constant.js +4 -0
- package/dist/esm-node/cli/index.js +68 -0
- package/dist/esm-node/cli/logger.js +7 -0
- package/dist/esm-node/cli/manifest.js +41 -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/ssrPlugin.js +181 -0
- package/dist/esm-node/cli/utils.js +49 -0
- package/dist/esm-node/constant.js +6 -0
- package/dist/esm-node/interfaces/bundler.js +0 -0
- package/dist/esm-node/runtime/createRemoteSSRComponent.js +166 -0
- package/dist/esm-node/runtime/index.js +12 -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/index.js +1 -0
- package/dist/esm-node/ssr-runtime/plugin.js +34 -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/constant.d.ts +1 -0
- package/dist/types/cli/index.d.ts +5 -0
- package/dist/types/cli/logger.d.ts +2 -0
- package/dist/types/cli/manifest.d.ts +2 -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/ssrPlugin.d.ts +6 -0
- package/dist/types/cli/utils.d.ts +5 -0
- package/dist/types/constant.d.ts +2 -0
- package/dist/types/interfaces/bundler.d.ts +18 -0
- package/dist/types/runtime/createRemoteSSRComponent.d.ts +18 -0
- package/dist/types/runtime/index.d.ts +5 -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/index.d.ts +1 -0
- package/dist/types/ssr-runtime/plugin.d.ts +2 -0
- package/dist/types/types/index.d.ts +22 -0
- package/package.json +7 -7
|
@@ -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 @@
|
|
|
1
|
+
export * from "./plugin";
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { SSRLiveReload } from "./SSRLiveReload";
|
|
3
|
+
const mfSSRPlugin = () => ({
|
|
4
|
+
name: "@module-federation/modern-js",
|
|
5
|
+
setup: (api) => {
|
|
6
|
+
api.onBeforeRender(async () => {
|
|
7
|
+
if (typeof window !== "undefined") {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
globalThis.shouldUpdate = false;
|
|
11
|
+
const nodeUtils = await import("@module-federation/node/utils");
|
|
12
|
+
const shouldUpdate = await nodeUtils.revalidate();
|
|
13
|
+
if (shouldUpdate) {
|
|
14
|
+
console.log("should RELOAD", shouldUpdate);
|
|
15
|
+
await nodeUtils.flushChunks();
|
|
16
|
+
globalThis.shouldUpdate = true;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
api.wrapRoot((App) => {
|
|
20
|
+
const AppWrapper = (props) => /* @__PURE__ */ _jsxs(_Fragment, {
|
|
21
|
+
children: [
|
|
22
|
+
/* @__PURE__ */ _jsx(SSRLiveReload, {}),
|
|
23
|
+
/* @__PURE__ */ _jsx(App, {
|
|
24
|
+
...props
|
|
25
|
+
})
|
|
26
|
+
]
|
|
27
|
+
});
|
|
28
|
+
return AppWrapper;
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
export {
|
|
33
|
+
mfSSRPlugin
|
|
34
|
+
};
|
|
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") => 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 @@
|
|
|
1
|
+
export declare const isDev: boolean;
|
|
@@ -0,0 +1,5 @@
|
|
|
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';
|
|
@@ -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,5 @@
|
|
|
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;
|
|
@@ -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,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ErrorBoundaryPropsWithComponent } from 'react-error-boundary';
|
|
3
|
+
type IProps = {
|
|
4
|
+
id: string;
|
|
5
|
+
injectScript?: boolean;
|
|
6
|
+
injectLink?: boolean;
|
|
7
|
+
};
|
|
8
|
+
type ReactKey = {
|
|
9
|
+
key?: React.Key | null;
|
|
10
|
+
};
|
|
11
|
+
export declare function collectSSRAssets(options: IProps): React.ReactNode[];
|
|
12
|
+
export declare function createRemoteSSRComponent<T, E extends keyof T>(info: {
|
|
13
|
+
loader: () => Promise<T>;
|
|
14
|
+
loading: React.ReactNode;
|
|
15
|
+
fallback: ErrorBoundaryPropsWithComponent['FallbackComponent'];
|
|
16
|
+
export?: E;
|
|
17
|
+
}): (props: T[E] extends (...args: any) => any ? Parameters<T[E]>[0] extends undefined ? ReactKey : Parameters<T[E]>[0] & ReactKey : ReactKey) => React.JSX.Element;
|
|
18
|
+
export {};
|
|
@@ -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 @@
|
|
|
1
|
+
export * from './plugin';
|
|
@@ -0,0 +1,22 @@
|
|
|
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
|
+
}
|
|
12
|
+
export interface InternalModernPluginOptions {
|
|
13
|
+
csrConfig?: moduleFederationPlugin.ModuleFederationPluginOptions;
|
|
14
|
+
ssrConfig?: moduleFederationPlugin.ModuleFederationPluginOptions;
|
|
15
|
+
distOutputDir: string;
|
|
16
|
+
originPluginOptions: PluginOptions;
|
|
17
|
+
browserPlugin?: BundlerPlugin;
|
|
18
|
+
nodePlugin?: BundlerPlugin;
|
|
19
|
+
remoteIpStrategy?: 'ipv4' | 'inherit';
|
|
20
|
+
userConfig?: PluginOptions;
|
|
21
|
+
}
|
|
22
|
+
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.14.
|
|
3
|
+
"version": "0.14.3",
|
|
4
4
|
"files": [
|
|
5
5
|
"dist/",
|
|
6
6
|
"types.d.ts",
|
|
@@ -97,11 +97,11 @@
|
|
|
97
97
|
"@swc/helpers": "0.5.13",
|
|
98
98
|
"node-fetch": "~3.3.0",
|
|
99
99
|
"react-error-boundary": "4.1.2",
|
|
100
|
-
"@module-federation/rsbuild-plugin": "0.14.
|
|
101
|
-
"@module-federation/enhanced": "0.14.
|
|
102
|
-
"@module-federation/node": "2.7.
|
|
103
|
-
"@module-federation/sdk": "0.14.
|
|
104
|
-
"@module-federation/cli": "0.14.
|
|
100
|
+
"@module-federation/rsbuild-plugin": "0.14.3",
|
|
101
|
+
"@module-federation/enhanced": "0.14.3",
|
|
102
|
+
"@module-federation/node": "2.7.6",
|
|
103
|
+
"@module-federation/sdk": "0.14.3",
|
|
104
|
+
"@module-federation/cli": "0.14.3"
|
|
105
105
|
},
|
|
106
106
|
"devDependencies": {
|
|
107
107
|
"@rsbuild/core": "1.2.8",
|
|
@@ -110,7 +110,7 @@
|
|
|
110
110
|
"@modern-js/module-tools": "2.67.6",
|
|
111
111
|
"@modern-js/runtime": "2.67.6",
|
|
112
112
|
"@modern-js/tsconfig": "2.67.6",
|
|
113
|
-
"@module-federation/manifest": "0.14.
|
|
113
|
+
"@module-federation/manifest": "0.14.3"
|
|
114
114
|
},
|
|
115
115
|
"peerDependencies": {
|
|
116
116
|
"react": ">=17",
|