@module-federation/modern-js 0.0.0-docs-remove-invalid-lark-link-20251205062649
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/LICENSE +21 -0
- package/README.md +5 -0
- package/dist/LICENSE +21 -0
- package/dist/cjs/cli/configPlugin.js +325 -0
- package/dist/cjs/cli/index.js +105 -0
- package/dist/cjs/cli/mfRuntimePlugins/inject-node-fetch.js +54 -0
- package/dist/cjs/cli/mfRuntimePlugins/resolve-entry-ipv4.js +80 -0
- package/dist/cjs/cli/mfRuntimePlugins/shared-strategy.js +53 -0
- package/dist/cjs/cli/server/data-fetch-server-plugin.js +59 -0
- package/dist/cjs/cli/ssrPlugin.js +287 -0
- package/dist/cjs/cli/utils.js +93 -0
- package/dist/cjs/constant.js +40 -0
- package/dist/cjs/interfaces/bundler.js +18 -0
- package/dist/cjs/logger.js +39 -0
- package/dist/cjs/react/index.js +60 -0
- package/dist/cjs/react/plugin.js +67 -0
- package/dist/cjs/react/v18.js +60 -0
- package/dist/cjs/react/v19.js +60 -0
- package/dist/cjs/runtime/index.js +60 -0
- package/dist/cjs/server/fileCache.js +84 -0
- package/dist/cjs/server/index.js +71 -0
- package/dist/cjs/server/staticMiddleware.js +90 -0
- package/dist/cjs/ssr-runtime/SSRLiveReload.js +48 -0
- package/dist/cjs/ssr-runtime/devPlugin.js +59 -0
- package/dist/cjs/ssr-runtime/injectDataFetchFunctionPlugin.js +48 -0
- package/dist/cjs/types/index.js +18 -0
- package/dist/esm/cli/configPlugin.mjs +298 -0
- package/dist/esm/cli/index.mjs +82 -0
- package/dist/esm/cli/mfRuntimePlugins/inject-node-fetch.mjs +12 -0
- package/dist/esm/cli/mfRuntimePlugins/resolve-entry-ipv4.mjs +58 -0
- package/dist/esm/cli/mfRuntimePlugins/shared-strategy.mjs +21 -0
- package/dist/esm/cli/server/data-fetch-server-plugin.mjs +17 -0
- package/dist/esm/cli/ssrPlugin.mjs +257 -0
- package/dist/esm/cli/utils.mjs +40 -0
- package/dist/esm/constant.mjs +3 -0
- package/dist/esm/interfaces/bundler.mjs +0 -0
- package/dist/esm/logger.mjs +5 -0
- package/dist/esm/react/index.mjs +1 -0
- package/dist/esm/react/plugin.mjs +3 -0
- package/dist/esm/react/v18.mjs +1 -0
- package/dist/esm/react/v19.mjs +1 -0
- package/dist/esm/runtime/index.mjs +1 -0
- package/dist/esm/server/fileCache.mjs +90 -0
- package/dist/esm/server/index.mjs +36 -0
- package/dist/esm/server/staticMiddleware.mjs +87 -0
- package/dist/esm/ssr-runtime/SSRLiveReload.mjs +21 -0
- package/dist/esm/ssr-runtime/devPlugin.mjs +63 -0
- package/dist/esm/ssr-runtime/injectDataFetchFunctionPlugin.mjs +34 -0
- package/dist/esm/types/index.mjs +0 -0
- package/dist/esm-node/cli/configPlugin.mjs +256 -0
- package/dist/esm-node/cli/index.mjs +65 -0
- package/dist/esm-node/cli/mfRuntimePlugins/inject-node-fetch.mjs +10 -0
- package/dist/esm-node/cli/mfRuntimePlugins/resolve-entry-ipv4.mjs +46 -0
- package/dist/esm-node/cli/mfRuntimePlugins/shared-strategy.mjs +19 -0
- package/dist/esm-node/cli/server/data-fetch-server-plugin.mjs +15 -0
- package/dist/esm-node/cli/ssrPlugin.mjs +231 -0
- package/dist/esm-node/cli/utils.mjs +40 -0
- package/dist/esm-node/constant.mjs +3 -0
- package/dist/esm-node/interfaces/bundler.mjs +0 -0
- package/dist/esm-node/logger.mjs +5 -0
- package/dist/esm-node/react/index.mjs +1 -0
- package/dist/esm-node/react/plugin.mjs +3 -0
- package/dist/esm-node/react/v18.mjs +1 -0
- package/dist/esm-node/react/v19.mjs +1 -0
- package/dist/esm-node/runtime/index.mjs +1 -0
- package/dist/esm-node/server/fileCache.mjs +37 -0
- package/dist/esm-node/server/index.mjs +34 -0
- package/dist/esm-node/server/staticMiddleware.mjs +42 -0
- package/dist/esm-node/ssr-runtime/SSRLiveReload.mjs +14 -0
- package/dist/esm-node/ssr-runtime/devPlugin.mjs +25 -0
- package/dist/esm-node/ssr-runtime/injectDataFetchFunctionPlugin.mjs +14 -0
- package/dist/esm-node/types/index.mjs +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 +1 -0
- package/dist/types/react/plugin.d.ts +2 -0
- package/dist/types/react/v18.d.ts +1 -0
- package/dist/types/react/v19.d.ts +1 -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 +7 -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 +35 -0
- package/package.json +189 -0
- package/types.d.ts +6 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import os from "os";
|
|
2
|
+
const localIpv4 = '127.0.0.1';
|
|
3
|
+
const getIpv4Interfaces = ()=>{
|
|
4
|
+
try {
|
|
5
|
+
const interfaces = os.networkInterfaces();
|
|
6
|
+
const ipv4Interfaces = [];
|
|
7
|
+
Object.values(interfaces).forEach((detail)=>{
|
|
8
|
+
null == detail || detail.forEach((detail)=>{
|
|
9
|
+
const familyV4Value = 'string' == typeof detail.family ? 'IPv4' : 4;
|
|
10
|
+
if (detail.family === familyV4Value && detail.address !== localIpv4) ipv4Interfaces.push(detail);
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
|
+
return ipv4Interfaces;
|
|
14
|
+
} catch (_err) {
|
|
15
|
+
return [];
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
const getIPV4 = ()=>{
|
|
19
|
+
const ipv4Interfaces = getIpv4Interfaces();
|
|
20
|
+
const ipv4Interface = ipv4Interfaces[0] || {
|
|
21
|
+
address: localIpv4
|
|
22
|
+
};
|
|
23
|
+
return ipv4Interface.address;
|
|
24
|
+
};
|
|
25
|
+
const isWebTarget = (target)=>{
|
|
26
|
+
const WEB_TARGET = 'web';
|
|
27
|
+
if (Array.isArray(target)) return target.includes(WEB_TARGET);
|
|
28
|
+
if ('string' == typeof target) return target === WEB_TARGET;
|
|
29
|
+
return false;
|
|
30
|
+
};
|
|
31
|
+
const skipByTarget = (target)=>{
|
|
32
|
+
const IGNORE_TARGET = 'webworker';
|
|
33
|
+
if (Array.isArray(target)) return target.includes(IGNORE_TARGET);
|
|
34
|
+
if ('string' == typeof target) return target === IGNORE_TARGET;
|
|
35
|
+
return false;
|
|
36
|
+
};
|
|
37
|
+
function isDev() {
|
|
38
|
+
return 'development' === process.env.NODE_ENV;
|
|
39
|
+
}
|
|
40
|
+
export { getIPV4, isDev, isWebTarget, skipByTarget };
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@module-federation/bridge-react";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@module-federation/bridge-react/v18";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@module-federation/bridge-react/v19";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@module-federation/enhanced/runtime";
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import fs_extra from "fs-extra";
|
|
2
|
+
import { LRUCache } from "lru-cache";
|
|
3
|
+
class FileCache {
|
|
4
|
+
async getFile(filepath) {
|
|
5
|
+
if (!await fs_extra.pathExists(filepath)) return null;
|
|
6
|
+
try {
|
|
7
|
+
const stat = await fs_extra.lstat(filepath);
|
|
8
|
+
const currentModified = stat.mtimeMs;
|
|
9
|
+
const cachedEntry = this.cache.get(filepath);
|
|
10
|
+
if (cachedEntry && currentModified <= cachedEntry.lastModified) return {
|
|
11
|
+
content: cachedEntry.content,
|
|
12
|
+
lastModified: cachedEntry.lastModified
|
|
13
|
+
};
|
|
14
|
+
const content = await fs_extra.readFile(filepath, 'utf-8');
|
|
15
|
+
const newEntry = {
|
|
16
|
+
content,
|
|
17
|
+
lastModified: currentModified
|
|
18
|
+
};
|
|
19
|
+
this.cache.set(filepath, newEntry, {
|
|
20
|
+
size: stat.size || content.length
|
|
21
|
+
});
|
|
22
|
+
return {
|
|
23
|
+
content,
|
|
24
|
+
lastModified: currentModified
|
|
25
|
+
};
|
|
26
|
+
} catch (err) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
constructor(){
|
|
31
|
+
this.cache = new LRUCache({
|
|
32
|
+
maxSize: 209715200
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const fileCache = new FileCache();
|
|
37
|
+
export { FileCache, fileCache };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { createCorsMiddleware, createStaticMiddleware } from "./staticMiddleware.mjs";
|
|
2
|
+
const staticServePlugin = ()=>({
|
|
3
|
+
name: '@modern-js/module-federation/server',
|
|
4
|
+
setup: (api)=>{
|
|
5
|
+
api.onPrepare(()=>{
|
|
6
|
+
var _config_output, _config_server;
|
|
7
|
+
if ('development' === process.env.NODE_ENV) return;
|
|
8
|
+
const { middlewares } = api.getServerContext();
|
|
9
|
+
const config = api.getServerConfig();
|
|
10
|
+
const assetPrefix = (null == (_config_output = config.output) ? void 0 : _config_output.assetPrefix) || '';
|
|
11
|
+
if (null == (_config_server = config.server) ? void 0 : _config_server.ssr) {
|
|
12
|
+
const context = api.getServerContext();
|
|
13
|
+
const pwd = context.distDirectory;
|
|
14
|
+
const serverStaticMiddleware = createStaticMiddleware({
|
|
15
|
+
assetPrefix,
|
|
16
|
+
pwd
|
|
17
|
+
});
|
|
18
|
+
middlewares.push({
|
|
19
|
+
name: 'module-federation-serve-manifest',
|
|
20
|
+
handler: serverStaticMiddleware
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
if (process.env.MODERN_MF_AUTO_CORS) {
|
|
24
|
+
const corsMiddleware = createCorsMiddleware();
|
|
25
|
+
middlewares.push({
|
|
26
|
+
name: 'module-federation-cors',
|
|
27
|
+
handler: corsMiddleware
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
const server = staticServePlugin;
|
|
34
|
+
export { server as default, staticServePlugin };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import fs_extra from "fs-extra";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { fileCache } from "./fileCache.mjs";
|
|
4
|
+
const bundlesAssetPrefix = '/bundles';
|
|
5
|
+
const removeHost = (url)=>{
|
|
6
|
+
try {
|
|
7
|
+
const hasProtocol = url.includes('://');
|
|
8
|
+
const hasDomain = hasProtocol || url.startsWith('//');
|
|
9
|
+
const pathname = hasDomain ? new URL(hasProtocol ? url : `http:${url}`).pathname : url;
|
|
10
|
+
return pathname;
|
|
11
|
+
} catch (e) {
|
|
12
|
+
return url;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
const createStaticMiddleware = (options)=>{
|
|
16
|
+
const { assetPrefix, pwd } = options;
|
|
17
|
+
return async (c, next)=>{
|
|
18
|
+
const pathname = c.req.path;
|
|
19
|
+
if ('.js' !== path.extname(pathname)) return next();
|
|
20
|
+
const prefixWithoutHost = removeHost(assetPrefix);
|
|
21
|
+
const prefixWithBundle = path.join(prefixWithoutHost, bundlesAssetPrefix);
|
|
22
|
+
if (!pathname.startsWith(prefixWithBundle)) return next();
|
|
23
|
+
const pathnameWithoutPrefix = pathname.replace(prefixWithBundle, '');
|
|
24
|
+
const filepath = path.join(pwd, bundlesAssetPrefix, pathnameWithoutPrefix);
|
|
25
|
+
if (!await fs_extra.pathExists(filepath)) return next();
|
|
26
|
+
const fileResult = await fileCache.getFile(filepath);
|
|
27
|
+
if (!fileResult) return next();
|
|
28
|
+
c.header('Content-Type', "application/javascript");
|
|
29
|
+
c.header('Content-Length', String(fileResult.content.length));
|
|
30
|
+
return c.body(fileResult.content, 200);
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
const createCorsMiddleware = ()=>async (c, next)=>{
|
|
34
|
+
const pathname = c.req.path;
|
|
35
|
+
if (path.extname(pathname)) {
|
|
36
|
+
c.header('Access-Control-Allow-Origin', '*');
|
|
37
|
+
c.header('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, PATCH, OPTIONS');
|
|
38
|
+
c.header('Access-Control-Allow-Headers', '*');
|
|
39
|
+
}
|
|
40
|
+
return next();
|
|
41
|
+
};
|
|
42
|
+
export { createCorsMiddleware, createStaticMiddleware };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
function SSRLiveReload() {
|
|
2
|
+
if ('development' !== process.env.NODE_ENV) return null;
|
|
3
|
+
return /*#__PURE__*/ React.createElement("script", {
|
|
4
|
+
suppressHydrationWarning: true,
|
|
5
|
+
dangerouslySetInnerHTML: {
|
|
6
|
+
__html: String.raw`
|
|
7
|
+
if(${globalThis.shouldUpdate}){
|
|
8
|
+
location.reload();
|
|
9
|
+
}
|
|
10
|
+
`
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
export { SSRLiveReload };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { SSRLiveReload } from "./SSRLiveReload.mjs";
|
|
2
|
+
import { flushDataFetch } from "@module-federation/bridge-react/lazy-utils";
|
|
3
|
+
const mfSSRDevPlugin = ()=>({
|
|
4
|
+
name: '@module-federation/modern-js',
|
|
5
|
+
setup: (api)=>{
|
|
6
|
+
api.onBeforeRender(async ()=>{
|
|
7
|
+
if ('undefined' != typeof window) return;
|
|
8
|
+
globalThis.shouldUpdate = false;
|
|
9
|
+
const nodeUtils = await import("@module-federation/node/utils");
|
|
10
|
+
const shouldUpdate = await nodeUtils.revalidate();
|
|
11
|
+
console.log('shouldUpdate: ', shouldUpdate);
|
|
12
|
+
if (shouldUpdate) {
|
|
13
|
+
console.log('should RELOAD', shouldUpdate);
|
|
14
|
+
await nodeUtils.flushChunks();
|
|
15
|
+
flushDataFetch();
|
|
16
|
+
globalThis.shouldUpdate = true;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
api.wrapRoot((App)=>{
|
|
20
|
+
const AppWrapper = (props)=>/*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement(SSRLiveReload, null), /*#__PURE__*/ React.createElement(App, props));
|
|
21
|
+
return AppWrapper;
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
export { mfSSRDevPlugin };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { callDataFetch } 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
|
+
await callDataFetch();
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
export { injectDataFetchFunctionPlugin };
|
|
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 { ModuleFederationRuntimePlugin } 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 @@
|
|
|
1
|
+
export * from '@module-federation/bridge-react';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@module-federation/bridge-react/v18';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@module-federation/bridge-react/v19';
|
|
@@ -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,7 @@
|
|
|
1
|
+
import type { MiddlewareHandler } from '@modern-js/server-runtime';
|
|
2
|
+
declare const createStaticMiddleware: (options: {
|
|
3
|
+
assetPrefix: string;
|
|
4
|
+
pwd: string;
|
|
5
|
+
}) => MiddlewareHandler;
|
|
6
|
+
declare const createCorsMiddleware: () => MiddlewareHandler;
|
|
7
|
+
export { createStaticMiddleware, createCorsMiddleware };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function SSRLiveReload(): import("react").JSX.Element | null;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { moduleFederationPlugin } from '@module-federation/sdk';
|
|
2
|
+
import type { StatsAssetResource } from '@module-federation/rsbuild-plugin/utils';
|
|
3
|
+
export interface PluginOptions {
|
|
4
|
+
config?: moduleFederationPlugin.ModuleFederationPluginOptions;
|
|
5
|
+
configPath?: string;
|
|
6
|
+
ssr?: {
|
|
7
|
+
distOutputDir?: string;
|
|
8
|
+
} | boolean;
|
|
9
|
+
remoteIpStrategy?: 'ipv4' | 'inherit';
|
|
10
|
+
fetchServerQuery?: Record<string, unknown>;
|
|
11
|
+
}
|
|
12
|
+
export type AssetFileNames = {
|
|
13
|
+
statsFileName: string;
|
|
14
|
+
manifestFileName: string;
|
|
15
|
+
};
|
|
16
|
+
export interface InternalModernPluginOptions {
|
|
17
|
+
csrConfig?: moduleFederationPlugin.ModuleFederationPluginOptions;
|
|
18
|
+
ssrConfig?: moduleFederationPlugin.ModuleFederationPluginOptions;
|
|
19
|
+
distOutputDir: string;
|
|
20
|
+
originPluginOptions: PluginOptions;
|
|
21
|
+
browserPlugin?: BundlerPlugin;
|
|
22
|
+
nodePlugin?: BundlerPlugin;
|
|
23
|
+
assetFileNames: {
|
|
24
|
+
node?: AssetFileNames;
|
|
25
|
+
browser?: AssetFileNames;
|
|
26
|
+
};
|
|
27
|
+
assetResources: {
|
|
28
|
+
browser?: StatsAssetResource;
|
|
29
|
+
node?: StatsAssetResource;
|
|
30
|
+
};
|
|
31
|
+
remoteIpStrategy?: 'ipv4' | 'inherit';
|
|
32
|
+
userConfig?: PluginOptions;
|
|
33
|
+
fetchServerQuery?: Record<string, unknown>;
|
|
34
|
+
}
|
|
35
|
+
export type BundlerPlugin = any;
|
package/package.json
ADDED
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@module-federation/modern-js",
|
|
3
|
+
"version": "0.0.0-docs-remove-invalid-lark-link-20251205062649",
|
|
4
|
+
"files": [
|
|
5
|
+
"dist/",
|
|
6
|
+
"types.d.ts",
|
|
7
|
+
"README.md"
|
|
8
|
+
],
|
|
9
|
+
"publishConfig": {
|
|
10
|
+
"access": "public"
|
|
11
|
+
},
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://github.com/module-federation/core.git",
|
|
15
|
+
"directory": "packages/modernjs"
|
|
16
|
+
},
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./dist/types/cli/index.d.ts",
|
|
20
|
+
"import": "./dist/esm/cli/index.mjs",
|
|
21
|
+
"require": "./dist/cjs/cli/index.js"
|
|
22
|
+
},
|
|
23
|
+
"./runtime": {
|
|
24
|
+
"types": "./dist/types/runtime/index.d.ts",
|
|
25
|
+
"default": "./dist/esm/runtime/index.mjs"
|
|
26
|
+
},
|
|
27
|
+
"./react": {
|
|
28
|
+
"types": "./dist/types/react/index.d.ts",
|
|
29
|
+
"default": "./dist/esm/react/index.mjs"
|
|
30
|
+
},
|
|
31
|
+
"./react-v18": {
|
|
32
|
+
"types": "./dist/types/react/v18.d.ts",
|
|
33
|
+
"default": "./dist/esm/react/v18.mjs"
|
|
34
|
+
},
|
|
35
|
+
"./react-v19": {
|
|
36
|
+
"types": "./dist/types/react/v19.d.ts",
|
|
37
|
+
"default": "./dist/esm/react/v19.mjs"
|
|
38
|
+
},
|
|
39
|
+
"./react-plugin": {
|
|
40
|
+
"types": "./dist/types/react/plugin.d.ts",
|
|
41
|
+
"default": "./dist/esm/react/plugin.mjs"
|
|
42
|
+
},
|
|
43
|
+
"./ssr-dev-plugin": {
|
|
44
|
+
"types": "./dist/types/ssr-runtime/devPlugin.d.ts",
|
|
45
|
+
"default": "./dist/esm/ssr-runtime/devPlugin.mjs"
|
|
46
|
+
},
|
|
47
|
+
"./ssr-inject-data-fetch-function-plugin": {
|
|
48
|
+
"types": "./dist/types/ssr-runtime/injectDataFetchFunctionPlugin.d.ts",
|
|
49
|
+
"default": "./dist/esm/ssr-runtime/injectDataFetchFunctionPlugin.mjs"
|
|
50
|
+
},
|
|
51
|
+
"./config-plugin": {
|
|
52
|
+
"types": "./dist/types/cli/configPlugin.d.ts",
|
|
53
|
+
"import": "./dist/esm/cli/configPlugin.mjs",
|
|
54
|
+
"require": "./dist/cjs/cli/configPlugin.js"
|
|
55
|
+
},
|
|
56
|
+
"./ssr-plugin": {
|
|
57
|
+
"types": "./dist/types/cli/ssrPlugin.d.ts",
|
|
58
|
+
"import": "./dist/esm/cli/ssrPlugin.mjs",
|
|
59
|
+
"require": "./dist/cjs/cli/ssrPlugin.js"
|
|
60
|
+
},
|
|
61
|
+
"./shared-strategy": {
|
|
62
|
+
"types": "./dist/types/cli/mfRuntimePlugins/shared-strategy.d.ts",
|
|
63
|
+
"import": "./dist/esm/cli/mfRuntimePlugins/shared-strategy.mjs",
|
|
64
|
+
"require": "./dist/cjs/cli/mfRuntimePlugins/shared-strategy.js"
|
|
65
|
+
},
|
|
66
|
+
"./resolve-entry-ipv4": {
|
|
67
|
+
"types": "./dist/types/cli/mfRuntimePlugins/resolve-entry-ipv4.d.ts",
|
|
68
|
+
"import": "./dist/esm/cli/mfRuntimePlugins/resolve-entry-ipv4.mjs",
|
|
69
|
+
"require": "./dist/cjs/cli/mfRuntimePlugins/resolve-entry-ipv4.js"
|
|
70
|
+
},
|
|
71
|
+
"./inject-node-fetch": {
|
|
72
|
+
"types": "./dist/types/cli/mfRuntimePlugins/inject-node-fetch.d.ts",
|
|
73
|
+
"import": "./dist/esm/cli/mfRuntimePlugins/inject-node-fetch.mjs",
|
|
74
|
+
"require": "./dist/cjs/cli/mfRuntimePlugins/inject-node-fetch.js"
|
|
75
|
+
},
|
|
76
|
+
"./data-fetch-server-plugin": {
|
|
77
|
+
"types": "./dist/types/cli/server/data-fetch-server-plugin.d.ts",
|
|
78
|
+
"default": "./dist/cjs/cli/server/data-fetch-server-plugin.js"
|
|
79
|
+
},
|
|
80
|
+
"./server": {
|
|
81
|
+
"types": "./dist/types/server/index.d.ts",
|
|
82
|
+
"default": "./dist/cjs/server/index.js"
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
"typesVersions": {
|
|
86
|
+
"*": {
|
|
87
|
+
".": [
|
|
88
|
+
"./dist/types/cli/index.d.ts"
|
|
89
|
+
],
|
|
90
|
+
"runtime": [
|
|
91
|
+
"./dist/types/runtime/index.d.ts"
|
|
92
|
+
],
|
|
93
|
+
"react": [
|
|
94
|
+
"./dist/types/react/index.d.ts"
|
|
95
|
+
],
|
|
96
|
+
"react-v18": [
|
|
97
|
+
"./dist/types/react/v18.d.ts"
|
|
98
|
+
],
|
|
99
|
+
"react-v19": [
|
|
100
|
+
"./dist/types/react/v19.d.ts"
|
|
101
|
+
],
|
|
102
|
+
"react-plugin": [
|
|
103
|
+
"./dist/types/react/plugin.d.ts"
|
|
104
|
+
],
|
|
105
|
+
"config-plugin": [
|
|
106
|
+
"./dist/types/cli/configPlugin.d.ts"
|
|
107
|
+
],
|
|
108
|
+
"ssr-plugin": [
|
|
109
|
+
"./dist/types/cli/ssrPlugin.d.ts"
|
|
110
|
+
],
|
|
111
|
+
"shared-strategy": [
|
|
112
|
+
"./dist/types/cli/mfRuntimePlugins/shared-strategy.d.ts"
|
|
113
|
+
],
|
|
114
|
+
"resolve-entry-ipv4": [
|
|
115
|
+
"./dist/types/cli/mfRuntimePlugins/resolve-entry-ipv4.d.ts"
|
|
116
|
+
],
|
|
117
|
+
"inject-node-fetch": [
|
|
118
|
+
"./dist/types/cli/mfRuntimePlugins/inject-node-fetch.d.ts"
|
|
119
|
+
],
|
|
120
|
+
"data-fetch-server-plugin": [
|
|
121
|
+
"./dist/types/cli/server/data-fetch-server-plugin.d.ts"
|
|
122
|
+
],
|
|
123
|
+
"ssr-inject-data-fetch-function-plugin": [
|
|
124
|
+
"./dist/types/ssr-runtime/injectDataFetchFunctionPlugin.d.ts"
|
|
125
|
+
],
|
|
126
|
+
"server": [
|
|
127
|
+
"./dist/types/server/index.d.ts"
|
|
128
|
+
]
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
"main": "./dist/cjs/cli/index.js",
|
|
132
|
+
"types": "./dist/types/cli/index.d.ts",
|
|
133
|
+
"author": "hanric <hanric.zhang@gmail.com>",
|
|
134
|
+
"license": "MIT",
|
|
135
|
+
"dependencies": {
|
|
136
|
+
"@modern-js/utils": "2.68.2",
|
|
137
|
+
"@modern-js/node-bundle-require": "2.68.2",
|
|
138
|
+
"fs-extra": "11.3.0",
|
|
139
|
+
"lru-cache": "10.4.3",
|
|
140
|
+
"@swc/helpers": "^0.5.17",
|
|
141
|
+
"node-fetch": "~3.3.0",
|
|
142
|
+
"react-error-boundary": "4.1.2",
|
|
143
|
+
"@module-federation/rsbuild-plugin": "0.0.0-docs-remove-invalid-lark-link-20251205062649",
|
|
144
|
+
"@module-federation/runtime": "0.0.0-docs-remove-invalid-lark-link-20251205062649",
|
|
145
|
+
"@module-federation/node": "0.0.0-docs-remove-invalid-lark-link-20251205062649",
|
|
146
|
+
"@module-federation/bridge-react": "0.0.0-docs-remove-invalid-lark-link-20251205062649",
|
|
147
|
+
"@module-federation/enhanced": "0.0.0-docs-remove-invalid-lark-link-20251205062649",
|
|
148
|
+
"@module-federation/sdk": "0.0.0-docs-remove-invalid-lark-link-20251205062649",
|
|
149
|
+
"@module-federation/cli": "0.0.0-docs-remove-invalid-lark-link-20251205062649"
|
|
150
|
+
},
|
|
151
|
+
"devDependencies": {
|
|
152
|
+
"@rslib/core": "^0.18.1",
|
|
153
|
+
"@modern-js/core": "2.68.2",
|
|
154
|
+
"@rsbuild/core": "1.3.21",
|
|
155
|
+
"@modern-js/app-tools": "2.68.2",
|
|
156
|
+
"@modern-js/server-runtime": "2.68.2",
|
|
157
|
+
"@modern-js/module-tools": "2.68.2",
|
|
158
|
+
"@modern-js/runtime": "2.68.2",
|
|
159
|
+
"@modern-js/tsconfig": "2.68.2",
|
|
160
|
+
"@types/react": "^18.3.11",
|
|
161
|
+
"@types/react-dom": "^18.3.0",
|
|
162
|
+
"@module-federation/manifest": "0.0.0-docs-remove-invalid-lark-link-20251205062649"
|
|
163
|
+
},
|
|
164
|
+
"peerDependencies": {
|
|
165
|
+
"react": ">=17",
|
|
166
|
+
"react-dom": ">=17",
|
|
167
|
+
"typescript": "^4.9.0 || ^5.0.0",
|
|
168
|
+
"vue-tsc": "^1.0.24",
|
|
169
|
+
"react-router-dom": "^4 || ^5 || ^6 || ^7",
|
|
170
|
+
"react-router": "^7"
|
|
171
|
+
},
|
|
172
|
+
"peerDependenciesMeta": {
|
|
173
|
+
"typescript": {
|
|
174
|
+
"optional": true
|
|
175
|
+
},
|
|
176
|
+
"vue-tsc": {
|
|
177
|
+
"optional": true
|
|
178
|
+
},
|
|
179
|
+
"react-router-dom": {
|
|
180
|
+
"optional": true
|
|
181
|
+
},
|
|
182
|
+
"react-router": {
|
|
183
|
+
"optional": true
|
|
184
|
+
}
|
|
185
|
+
},
|
|
186
|
+
"scripts": {
|
|
187
|
+
"build": "rslib build"
|
|
188
|
+
}
|
|
189
|
+
}
|