@fulgurjs/federation 5.7.1 → 5.9.0
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/CHANGELOG.md +23 -4
- package/DESIGN.md +3 -0
- package/README.en.md +350 -367
- package/README.md +293 -1179
- package/dist/cli.js +327 -29
- package/dist/index.cjs +72 -11
- package/dist/index.js +72 -11
- package/dist/runtime.js +1 -1
- package/docs/API.en.md +339 -0
- package/docs/API.md +914 -0
- package/docs/webpack-mf-/345/257/271/347/205/247/344/270/216/347/274/272/345/217/243.md +64 -37
- package/examples/README.md +3 -67
- package/examples/templates/README.md +88 -0
- package/examples/templates/react-host-vue-remote/README.md +18 -0
- package/examples/templates/react-host-vue-remote/package.json +11 -0
- package/examples/templates/react-host-vue-remote/pnpm-lock.yaml +1627 -0
- package/examples/templates/react-host-vue-remote/pnpm-workspace.yaml +10 -0
- package/examples/{bridge → templates/react-host-vue-remote}/react-host/README.md +8 -7
- package/examples/{bridge → templates/react-host-vue-remote}/react-host/package.json +1 -1
- package/examples/templates/react-host-vue-remote/react-host/src/fulgurjs/types/bridge-vue-remote.d/_paths.d.ts +4 -0
- package/examples/templates/react-host-vue-remote/react-host/src/fulgurjs/types/bridge-vue-remote.d/bridge.ts +3 -0
- package/examples/templates/react-host-vue-remote/react-host/src/fulgurjs/types/bridge-vue-remote.d.ts +9 -0
- package/examples/templates/react-host-vue-remote/scripts/dev.config.json +6 -0
- package/examples/templates/react-host-vue-remote/scripts/dev.mjs +173 -0
- package/examples/{bridge → templates/react-host-vue-remote}/vue-remote/README.md +10 -5
- package/examples/{bridge → templates/react-host-vue-remote}/vue-remote/package.json +1 -1
- package/examples/{react → templates/react-react}/README.md +9 -13
- package/examples/{react → templates/react-react}/host/README.md +6 -8
- package/examples/{react → templates/react-react}/host/package.json +1 -1
- package/examples/templates/react-react/host/src/fulgurjs/types/react-remote.d/ClickButton.ts +3 -0
- package/examples/templates/react-react/host/src/fulgurjs/types/react-remote.d/_paths.d.ts +4 -0
- package/examples/templates/react-react/host/src/fulgurjs/types/react-remote.d/pages/DetailPage.ts +3 -0
- package/examples/templates/react-react/host/src/fulgurjs/types/react-remote.d/pages/HomePage.ts +3 -0
- package/examples/templates/react-react/host/src/fulgurjs/types/react-remote.d/utils.ts +2 -0
- package/examples/templates/react-react/host/src/fulgurjs/types/react-remote.d.ts +26 -0
- package/examples/templates/react-react/package.json +11 -0
- package/examples/templates/react-react/pnpm-lock.yaml +1537 -0
- package/examples/templates/react-react/pnpm-workspace.yaml +10 -0
- package/examples/{react → templates/react-react}/remote/README.md +7 -6
- package/examples/{react → templates/react-react}/remote/package.json +1 -1
- package/examples/templates/react-react/scripts/dev.config.json +6 -0
- package/examples/templates/react-react/scripts/dev.mjs +173 -0
- package/examples/templates/showcase/README.md +109 -0
- package/examples/templates/showcase/package.json +13 -0
- package/examples/templates/showcase/pnpm-lock.yaml +1858 -0
- package/examples/templates/showcase/pnpm-workspace.yaml +12 -0
- package/examples/templates/showcase/react-host/fulgurjs.config.ts +21 -0
- package/examples/templates/showcase/react-host/index.html +13 -0
- package/examples/templates/showcase/react-host/package.json +26 -0
- package/examples/templates/showcase/react-host/src/GuardBanner.tsx +33 -0
- package/examples/templates/showcase/react-host/src/Layout.tsx +42 -0
- package/examples/templates/showcase/react-host/src/ObsPanel.tsx +44 -0
- package/examples/templates/showcase/react-host/src/demo-log.ts +74 -0
- package/examples/templates/showcase/react-host/src/fulgurjs/types/vue-remote.d/_paths.d.ts +4 -0
- package/examples/templates/showcase/react-host/src/fulgurjs/types/vue-remote.d/bridge.ts +3 -0
- package/examples/templates/showcase/react-host/src/fulgurjs/types/vue-remote.d.ts +7 -0
- package/examples/templates/showcase/react-host/src/main.tsx +33 -0
- package/examples/templates/showcase/react-host/src/pages/AboutPage.tsx +18 -0
- package/examples/templates/showcase/react-host/src/pages/BridgeVuePage.tsx +77 -0
- package/examples/templates/showcase/react-host/src/pages/HomePage.tsx +14 -0
- package/examples/templates/showcase/react-host/src/routing.ts +30 -0
- package/examples/templates/showcase/react-host/tsconfig.json +15 -0
- package/examples/templates/showcase/react-host/vite.config.ts +8 -0
- package/examples/templates/showcase/react-remote/fulgurjs.config.ts +18 -0
- package/examples/templates/showcase/react-remote/index.html +13 -0
- package/examples/templates/showcase/react-remote/package.json +25 -0
- package/examples/templates/showcase/react-remote/src/ChildLayout.tsx +48 -0
- package/examples/templates/showcase/react-remote/src/bridge.tsx +62 -0
- package/examples/templates/showcase/react-remote/src/child-bus.ts +32 -0
- package/examples/templates/showcase/react-remote/src/main.tsx +18 -0
- package/examples/templates/showcase/react-remote/src/pages/Locked.tsx +23 -0
- package/examples/templates/showcase/react-remote/src/pages/OrderDetail.tsx +36 -0
- package/examples/templates/showcase/react-remote/src/pages/OrderList.tsx +110 -0
- package/examples/templates/showcase/react-remote/src/pages/Settings.tsx +50 -0
- package/examples/templates/showcase/react-remote/src/settings-store.ts +11 -0
- package/examples/templates/showcase/react-remote/tsconfig.json +14 -0
- package/examples/templates/showcase/react-remote/vite.config.ts +14 -0
- package/examples/templates/showcase/scripts/dev.config.json +8 -0
- package/examples/templates/showcase/scripts/dev.mjs +173 -0
- package/examples/templates/showcase/vue-host/fulgurjs.config.ts +21 -0
- package/examples/templates/showcase/vue-host/index.html +13 -0
- package/examples/templates/showcase/vue-host/package.json +25 -0
- package/examples/templates/showcase/vue-host/src/App.vue +50 -0
- package/examples/templates/showcase/vue-host/src/GuardBanner.vue +24 -0
- package/examples/templates/showcase/vue-host/src/ObsPanel.vue +60 -0
- package/examples/templates/showcase/vue-host/src/demo-log.ts +49 -0
- package/examples/templates/showcase/vue-host/src/fulgurjs/types/react-remote.d/_paths.d.ts +4 -0
- package/examples/templates/showcase/vue-host/src/fulgurjs/types/react-remote.d/bridge.ts +3 -0
- package/examples/templates/showcase/vue-host/src/fulgurjs/types/react-remote.d.ts +7 -0
- package/examples/templates/showcase/vue-host/src/guard.ts +47 -0
- package/examples/templates/showcase/vue-host/src/main.ts +30 -0
- package/examples/templates/showcase/vue-host/src/pages/AboutPage.vue +17 -0
- package/examples/templates/showcase/vue-host/src/pages/BridgeReactPage.vue +74 -0
- package/examples/templates/showcase/vue-host/src/pages/HomePage.vue +13 -0
- package/examples/templates/showcase/vue-host/src/routing.ts +31 -0
- package/examples/templates/showcase/vue-host/tsconfig.json +14 -0
- package/examples/templates/showcase/vue-remote/fulgurjs.config.ts +17 -0
- package/examples/templates/showcase/vue-remote/index.html +13 -0
- package/examples/templates/showcase/vue-remote/package.json +23 -0
- package/examples/templates/showcase/vue-remote/src/ChildLayout.vue +54 -0
- package/examples/templates/showcase/vue-remote/src/bridge.ts +48 -0
- package/examples/templates/showcase/vue-remote/src/child-bus.ts +32 -0
- package/examples/templates/showcase/vue-remote/src/main.ts +16 -0
- package/examples/templates/showcase/vue-remote/src/pages/Locked.vue +28 -0
- package/examples/templates/showcase/vue-remote/src/pages/OrderDetail.vue +46 -0
- package/examples/templates/showcase/vue-remote/src/pages/OrderList.vue +116 -0
- package/examples/templates/showcase/vue-remote/src/pages/Settings.vue +34 -0
- package/examples/templates/showcase/vue-remote/src/settings-store.ts +13 -0
- package/examples/templates/showcase/vue-remote/tsconfig.json +14 -0
- package/examples/templates/showcase/vue-remote/vite.config.ts +14 -0
- package/examples/templates/vue-host-react-remote/README.md +18 -0
- package/examples/templates/vue-host-react-remote/package.json +11 -0
- package/examples/templates/vue-host-react-remote/pnpm-lock.yaml +1663 -0
- package/examples/templates/vue-host-react-remote/pnpm-workspace.yaml +10 -0
- package/examples/{bridge → templates/vue-host-react-remote}/react-remote/README.md +9 -4
- package/examples/{bridge → templates/vue-host-react-remote}/react-remote/package.json +1 -1
- package/examples/templates/vue-host-react-remote/scripts/dev.config.json +6 -0
- package/examples/templates/vue-host-react-remote/scripts/dev.mjs +173 -0
- package/examples/{bridge → templates/vue-host-react-remote}/vue-host/README.md +8 -7
- package/examples/{bridge → templates/vue-host-react-remote}/vue-host/package.json +1 -1
- package/examples/{bridge → templates/vue-host-react-remote}/vue-host/src/App.vue +1 -1
- package/examples/templates/vue-host-react-remote/vue-host/src/fulgurjs/types/bridge-react-remote.d/_paths.d.ts +4 -0
- package/examples/templates/vue-host-react-remote/vue-host/src/fulgurjs/types/bridge-react-remote.d/bridge.ts +3 -0
- package/examples/templates/vue-host-react-remote/vue-host/src/fulgurjs/types/bridge-react-remote.d.ts +9 -0
- package/examples/{vue → templates/vue-vue}/README.md +9 -13
- package/examples/{vue → templates/vue-vue}/host/README.md +6 -8
- package/examples/{vue → templates/vue-vue}/host/package.json +1 -1
- package/examples/templates/vue-vue/host/src/fulgurjs/types/vue-remote.d/ClickButton.ts +4 -0
- package/examples/templates/vue-vue/host/src/fulgurjs/types/vue-remote.d/_paths.d.ts +4 -0
- package/examples/templates/vue-vue/host/src/fulgurjs/types/vue-remote.d/pages/DetailPage.ts +4 -0
- package/examples/templates/vue-vue/host/src/fulgurjs/types/vue-remote.d/pages/HomePage.ts +4 -0
- package/examples/templates/vue-vue/host/src/fulgurjs/types/vue-remote.d/utils.ts +2 -0
- package/examples/templates/vue-vue/host/src/fulgurjs/types/vue-remote.d.ts +29 -0
- package/examples/templates/vue-vue/host/vite.config.ts +8 -0
- package/examples/templates/vue-vue/package.json +11 -0
- package/examples/templates/vue-vue/pnpm-lock.yaml +1199 -0
- package/examples/templates/vue-vue/pnpm-workspace.yaml +10 -0
- package/examples/{vue → templates/vue-vue}/remote/README.md +7 -6
- package/examples/{vue → templates/vue-vue}/remote/package.json +1 -1
- package/examples/{vue → templates/vue-vue}/remote/src/App.vue +1 -1
- package/examples/templates/vue-vue/scripts/dev.config.json +6 -0
- package/examples/templates/vue-vue/scripts/dev.mjs +173 -0
- package/package.json +8 -6
- package/examples/README.en.md +0 -67
- package/examples/bridge/README.md +0 -36
- package/examples/bridge/react-host/package-lock.json +0 -2466
- package/examples/bridge/react-remote/package-lock.json +0 -2391
- package/examples/bridge/vue-host/package-lock.json +0 -1894
- package/examples/bridge/vue-remote/package-lock.json +0 -1865
- package/examples/react/host/package-lock.json +0 -2391
- package/examples/react/remote/package-lock.json +0 -2333
- package/examples/vue/host/package-lock.json +0 -1865
- package/examples/vue/remote/package-lock.json +0 -1843
- /package/examples/{bridge → templates/react-host-vue-remote}/react-host/fulgurjs.config.ts +0 -0
- /package/examples/{bridge → templates/react-host-vue-remote}/react-host/index.html +0 -0
- /package/examples/{bridge → templates/react-host-vue-remote}/react-host/src/env.d.ts +0 -0
- /package/examples/{bridge → templates/react-host-vue-remote}/react-host/src/host-session.ts +0 -0
- /package/examples/{bridge → templates/react-host-vue-remote}/react-host/src/main.tsx +0 -0
- /package/examples/{bridge → templates/react-host-vue-remote}/react-host/tsconfig.json +0 -0
- /package/examples/{bridge → templates/react-host-vue-remote}/react-host/vite.config.ts +0 -0
- /package/examples/{bridge → templates/react-host-vue-remote}/vue-remote/fulgurjs.config.ts +0 -0
- /package/examples/{bridge → templates/react-host-vue-remote}/vue-remote/index.html +0 -0
- /package/examples/{bridge → templates/react-host-vue-remote}/vue-remote/src/App.vue +0 -0
- /package/examples/{bridge → templates/react-host-vue-remote}/vue-remote/src/bridge.ts +0 -0
- /package/examples/{bridge/react-remote → templates/react-host-vue-remote/vue-remote}/src/env.d.ts +0 -0
- /package/examples/{bridge → templates/react-host-vue-remote}/vue-remote/src/main.ts +0 -0
- /package/examples/{bridge/vue-host → templates/react-host-vue-remote/vue-remote}/tsconfig.json +0 -0
- /package/examples/{bridge → templates/react-host-vue-remote}/vue-remote/vite.config.ts +0 -0
- /package/examples/{react → templates/react-react}/host/fulgurjs.config.ts +0 -0
- /package/examples/{react → templates/react-react}/host/index.html +0 -0
- /package/examples/{react → templates/react-react}/host/src/App.tsx +0 -0
- /package/examples/{react → templates/react-react}/host/src/main.tsx +0 -0
- /package/examples/{react → templates/react-react}/host/src/pages/UtilsDemo.tsx +0 -0
- /package/examples/{react → templates/react-react}/host/src/remotePages.tsx +0 -0
- /package/examples/{bridge/react-remote → templates/react-react/host}/tsconfig.json +0 -0
- /package/examples/{react → templates/react-react}/host/vite.config.ts +0 -0
- /package/examples/{react → templates/react-react}/remote/fulgurjs.config.ts +0 -0
- /package/examples/{react → templates/react-react}/remote/index.html +0 -0
- /package/examples/{react → templates/react-react}/remote/src/App.tsx +0 -0
- /package/examples/{react → templates/react-react}/remote/src/exposes/ClickButton.tsx +0 -0
- /package/examples/{react → templates/react-react}/remote/src/exposes/pages/DetailPage.tsx +0 -0
- /package/examples/{react → templates/react-react}/remote/src/exposes/pages/HomePage.tsx +0 -0
- /package/examples/{react → templates/react-react}/remote/src/exposes/utils.ts +0 -0
- /package/examples/{react → templates/react-react}/remote/src/main.tsx +0 -0
- /package/examples/{react/host → templates/react-react/remote}/tsconfig.json +0 -0
- /package/examples/{react → templates/react-react}/remote/vite.config.ts +0 -0
- /package/examples/{vue/host → templates/showcase/vue-host}/vite.config.ts +0 -0
- /package/examples/{bridge → templates/vue-host-react-remote}/react-remote/fulgurjs.config.ts +0 -0
- /package/examples/{bridge → templates/vue-host-react-remote}/react-remote/index.html +0 -0
- /package/examples/{bridge → templates/vue-host-react-remote}/react-remote/src/bridge.tsx +0 -0
- /package/examples/{bridge/vue-host → templates/vue-host-react-remote/react-remote}/src/env.d.ts +0 -0
- /package/examples/{bridge → templates/vue-host-react-remote}/react-remote/src/main.tsx +0 -0
- /package/examples/{react/remote → templates/vue-host-react-remote/react-remote}/tsconfig.json +0 -0
- /package/examples/{bridge → templates/vue-host-react-remote}/react-remote/vite.config.ts +0 -0
- /package/examples/{bridge → templates/vue-host-react-remote}/vue-host/fulgurjs.config.ts +0 -0
- /package/examples/{bridge → templates/vue-host-react-remote}/vue-host/index.html +0 -0
- /package/examples/{bridge/vue-remote → templates/vue-host-react-remote/vue-host}/src/env.d.ts +0 -0
- /package/examples/{bridge → templates/vue-host-react-remote}/vue-host/src/host-session.ts +0 -0
- /package/examples/{bridge → templates/vue-host-react-remote}/vue-host/src/main.ts +0 -0
- /package/examples/{bridge/vue-remote → templates/vue-host-react-remote/vue-host}/tsconfig.json +0 -0
- /package/examples/{bridge → templates/vue-host-react-remote}/vue-host/vite.config.ts +0 -0
- /package/examples/{vue → templates/vue-vue}/host/fulgurjs.config.ts +0 -0
- /package/examples/{vue → templates/vue-vue}/host/index.html +0 -0
- /package/examples/{vue → templates/vue-vue}/host/src/App.vue +0 -0
- /package/examples/{vue → templates/vue-vue}/host/src/main.ts +0 -0
- /package/examples/{vue → templates/vue-vue}/host/src/pages/HomePage.vue +0 -0
- /package/examples/{vue → templates/vue-vue}/host/src/pages/UtilsDemo.vue +0 -0
- /package/examples/{vue → templates/vue-vue}/host/tsconfig.json +0 -0
- /package/examples/{vue → templates/vue-vue}/remote/fulgurjs.config.ts +0 -0
- /package/examples/{vue → templates/vue-vue}/remote/index.html +0 -0
- /package/examples/{vue → templates/vue-vue}/remote/src/exposes/ClickButton.vue +0 -0
- /package/examples/{vue → templates/vue-vue}/remote/src/exposes/pages/DetailPage.vue +0 -0
- /package/examples/{vue → templates/vue-vue}/remote/src/exposes/pages/HomePage.vue +0 -0
- /package/examples/{vue → templates/vue-vue}/remote/src/exposes/utils.ts +0 -0
- /package/examples/{vue → templates/vue-vue}/remote/src/main.ts +0 -0
- /package/examples/{vue → templates/vue-vue}/remote/tsconfig.json +0 -0
- /package/examples/{vue → templates/vue-vue}/remote/vite.config.ts +0 -0
|
@@ -1,37 +1,64 @@
|
|
|
1
|
-
# webpack Module Federation
|
|
2
|
-
|
|
3
|
-
>
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
| remotes
|
|
11
|
-
|
|
|
12
|
-
|
|
|
13
|
-
|
|
|
14
|
-
|
|
|
15
|
-
|
|
|
16
|
-
|
|
|
17
|
-
|
|
|
18
|
-
|
|
|
19
|
-
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
|
28
|
-
|
|
29
|
-
|
|
|
30
|
-
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
1
|
+
# webpack Module Federation:当前能力与使用边界对照
|
|
2
|
+
|
|
3
|
+
> 核对版本:`@fulgurjs/federation@5.7.1`(2026-10-03)。本页描述当前能力;早期任务书、设计方案及分版本验收报告保留历史记录,不作为当前支持范围。
|
|
4
|
+
> 对照对象是 webpack 5 内置 `ModuleFederationPlugin`;Module Federation enhanced runtime、Bridge、DevTools 等独立生态工具不是 webpack 内置插件的同一功能面。本插件不承诺完整配置或产物互操作兼容。
|
|
5
|
+
|
|
6
|
+
## 一、已经实现
|
|
7
|
+
|
|
8
|
+
| 能力 | 本插件当前状态 | 使用说明 |
|
|
9
|
+
|---|---|---|
|
|
10
|
+
| exposes / remotes | 支持 | dev 容器直连;production 生成 ESM remoteEntry 与 manifest |
|
|
11
|
+
| 动态远程 | 支持 | `registerRemote` / `registerRemotes`;promise remote 解析容器或地址 |
|
|
12
|
+
| shared 版本协商 | 支持 | `requiredVersion`、singleton、strictVersion、eager、shareKey、多 shareScope;真实实例版本登记与并发保护 |
|
|
13
|
+
| `shared.import: false` | 支持 | 纯消费,不提供本地 fallback;不能与 eager 同时使用 |
|
|
14
|
+
| 双向联邦与嵌套容器 | 支持 | 各应用可同时提供和消费模块;这不等于自动代理任意层级的桥接路由 |
|
|
15
|
+
| Vue 3 / React 18–19 | 支持浏览器客户端 | 各框架组件加载、页面适配器;纯 TS 模块可跨框架消费 |
|
|
16
|
+
| Vue ↔ React 子应用桥接 | 支持 | `/bridge` 整站挂载/卸载、props/context、会话切换、错误占位 |
|
|
17
|
+
| 子应用路由 ↔ 宿主 URL | 支持,显式启用 | `/bridge/router/vue`、`/bridge/router/react`;深链、刷新、push/replace、前进后退与导航取消;默认关闭 |
|
|
18
|
+
| React 18/19 隔离共存 | 支持按作用域隔离 | 整组 React、renderer 和消费者使用相应 scope;跨树传普通 props/回调,不能混用 ReactElement/Context |
|
|
19
|
+
| 运行时策略 | 支持 | `runtimePlugins`;HTML 入口/expose 执行前准备异步共享策略。无 HTML 的入口及启动后修改策略须先协商再导入新消费者 |
|
|
20
|
+
| 加载恢复与诊断 | 支持 | 超时、重试、熔断、显式 fallback、错误码;静态依赖失败的恢复边界见 §三 |
|
|
21
|
+
| 工程辅助 | 支持 | dts、manifest 预载、setup/onSession、CLI 检查与 Demo |
|
|
22
|
+
|
|
23
|
+
入门步骤见 [中文 README](../README.md)、[英文 README](../README.en.md);公开签名及默认值见 [中文 API 手册](API.md)、[English API reference](API.en.md)。版本隔离与恢复例子见 [examples/demos/react-versions](../examples/demos/react-versions/README.md)。
|
|
24
|
+
|
|
25
|
+
## 二、当前不提供的能力
|
|
26
|
+
|
|
27
|
+
| 能力 | 当前范围 | 与 webpack 的关系 |
|
|
28
|
+
|---|---|---|
|
|
29
|
+
| SSR / Node 服务端联邦、RSC、Next.js 全栈 | 不支持 | webpack 联邦概念支持 web/Node 等环境;不意味着自动获得完整 SSR/RSC 集成。本插件当前仅支持浏览器客户端 |
|
|
30
|
+
| webpack `script` / `var` 容器互操作 | 不支持 | 本插件产出 ESM remote;不要因为都有 init/get 就直接混用两种产物。remoteType/library 已删除,传入报迁移错误 |
|
|
31
|
+
| Vue/React 组件级直接混渲染 | 不提供转换层 | webpack 核心负责模块加载,不转换框架组件;本插件的子应用桥接允许两个框架各自管理组件树 |
|
|
32
|
+
| JS 沙箱 / 自动 CSS 隔离 | 不提供 | 普通同页面联邦不会自动隔离全局变量、全局 CSS、Portal/Teleport 的容器外 DOM;需要额外隔离方案 |
|
|
33
|
+
| 独立浏览器 DevTools 扩展 | 无 | 本插件提供 `window.__FULGURJS_SCOPE__ / __FULGURJS_INFO__`。其他联邦生态工具的扩展不能计为 webpack 内置能力 |
|
|
34
|
+
| React 页面 KeepAlive | 不承诺 | 已下载模块可复用;组件状态保活需要应用或专门库实现 |
|
|
35
|
+
| 其他框架与路由库的内置适配 | 无 | URL 同步内置 Vue Router / React Router data router;其他库可实现导航端口。多层桥接路由自动代理、跨窗口同步不在当前支持面 |
|
|
36
|
+
|
|
37
|
+
## 三、使用限制与 webpack 的区别
|
|
38
|
+
|
|
39
|
+
以下区分实例正确性、网络开销和失败恢复,不将“已测场景”扩大成所有工程保证。
|
|
40
|
+
|
|
41
|
+
| 场景 | 本插件当前表现 | webpack 5 内置 MF 的对应表现 | 处理方法 |
|
|
42
|
+
|---|---|---|---|
|
|
43
|
+
| 共享库额外网络副本 | Vite 8 同步消费门面可能把未采用的本地副本也拉入模块图;已测双版本场景 ≤2 份。这不是所有应用图的数量上限;同 singleton scope 的实例身份仍统一 | 不是 webpack 的必然限制。异步 shared 可按协商结果加载;eager/fallback、未共享路径或不同 scope 也可能增加下载量,不能宣称 webpack 永远只下载一份 | 区分网络文件数与运行时实例数,按实际构建图评估;不要将本插件这项代价归为所有 MF 实现共有 |
|
|
44
|
+
| dev 冷启动依赖优化重载 | Vite 新发现依赖时可能重新预构建并 full reload(DEV-010);稳定态需等优化完成 | webpack dev 也有编译/HMR 等待,但没有同一套 Vite 依赖优化机制 | 排查冷/热态区别,按需配置预构建;这不是生产限制,也不是 webpack MF 的相同缺陷 |
|
|
45
|
+
| expose 的静态 ESM 依赖下载失败 | 已缓存失败的依赖 URL 可能阻止同页恢复;只变换 expose 入口 URL 不会改写静态依赖 URL,提供用户主动刷新恢复 | 常见 script/JSONP chunk loader 失败后清掉该 chunk 的加载状态,后续请求可以重新加载;仍需调用方触发重试。404 旧产物、持续网络故障等不保证靠重试恢复;使用原生 ESM 路径时需单独评估 | 不笼统写“webpack 也只能刷新”。本插件控制的入口/动态加载边界可变换 URL;静态依赖失败仍保留刷新操作 |
|
|
46
|
+
| React 与 renderer 不兼容或实例不一致 | React 18 的 renderer 不能因 singleton 协商就自动兼容 React 19。对齐版本,或分 scope 隔离整组依赖及消费者 | 同样受 React 的版本与实例要求约束;singleton 不会转换框架 ABI,strictVersion 可拒绝冲突 | 共享树使用兼容 React/renderer;不同大版本使用独立树和作用域,传普通数据/回调 |
|
|
47
|
+
|
|
48
|
+
异步协商的启动时序同样需要关注:webpack 推荐异步 bootstrap 边界。本插件对 HTML 入口自动处理相关边界;自定义入口仍应先 `await loadShare`,再动态导入消费者。已经求值的静态绑定不能追溯替换。
|
|
49
|
+
|
|
50
|
+
### 官方依据
|
|
51
|
+
|
|
52
|
+
- [webpack 联邦概念与异步 bootstrap](https://webpack.js.org/concepts/module-federation/):容器、shareScope、已加载实例、eager 下载代价及不同运行环境。
|
|
53
|
+
- [webpack shared 配置](https://webpack.js.org/plugins/module-federation-plugin/):singleton / requiredVersion / strictVersion / eager。
|
|
54
|
+
- [webpack 5.102.1 JSONP chunk loader 源码](https://github.com/webpack/webpack/blob/v5.102.1/lib/web/JsonpChunkLoadingRuntimeModule.js):失败时清除 installedChunks 状态。此结论针对该加载器,由源码推导,不代表所有加载器或任意故障都能自动恢复。
|
|
55
|
+
- [HTML 标准:模块脚本加载](https://html.spec.whatwg.org/multipage/webappapis.html#fetch-a-single-module-script):原生 ESM 的 module map 与失败记录。
|
|
56
|
+
- [Vite 依赖预构建](https://vite.dev/guide/dep-pre-bundling):新依赖触发重新优化及必要的页面重载。
|
|
57
|
+
- [React 的版本与重复实例诊断](https://react.dev/warnings/invalid-hook-call-warning):消费方与 renderer 必须使用一致的 React 模块实例。
|
|
58
|
+
|
|
59
|
+
## 四、迁移入口
|
|
60
|
+
|
|
61
|
+
- Vite 工程按 [README](../README.md) 配置 remotes/exposes/shared,不照搬已经删除的 webpack 配置字段。
|
|
62
|
+
- 从 iframe/其他微前端方案迁移:先选择模块/页面加载或子应用桥接;需要地址恢复时显式开启 URL 同步。
|
|
63
|
+
- React 18/19 同页运行:先运行 [版本隔离 Demo](../examples/demos/react-versions/README.md),再按实际应用依赖图配置作用域。
|
|
64
|
+
- 旧报告里的“React 未支持”“URL 同步待实现”“Vite 8 生产挂起未解”属于旧版本记录。当前补修证据见 [完整验收报告 §14](完整Demo展示与全面复测-验收报告-20261002.md#14-共享协商收尾与证据订正571)。
|
package/examples/README.md
CHANGED
|
@@ -1,69 +1,5 @@
|
|
|
1
|
-
#
|
|
1
|
+
# 可复制模板
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
本 npm 包附带五个完整模板,见 [模板指南](templates/README.md)。复制整个模板目录,在模板根执行 pnpm install --frozen-lockfile,再执行 pnpm dev。
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
完整操作步骤见 **[vue/README.md](./vue/README.md)**。
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
cd examples/vue/remote && npm install && npm run dev # 终端 1:vue-remote,http://localhost:5213
|
|
11
|
-
cd examples/vue/host && npm install && npm run dev # 终端 2:vue-host,http://localhost:5214
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
## React(宿主 5204 / 远程 5203)
|
|
15
|
-
|
|
16
|
-
完整操作步骤见 **[react/README.md](./react/README.md)**。
|
|
17
|
-
|
|
18
|
-
```bash
|
|
19
|
-
cd examples/react/remote && npm install && npm run dev # 终端 1:react-remote,http://localhost:5203
|
|
20
|
-
cd examples/react/host && npm install && npm run dev # 终端 2:react-host,http://localhost:5204
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
## 跨框架桥接(Vue 宿主 5314 × React 远程 5303;React 宿主 5304 × Vue 远程 5313)
|
|
24
|
-
|
|
25
|
-
完整操作步骤见 **[bridge/README.md](./bridge/README.md)**。
|
|
26
|
-
|
|
27
|
-
```bash
|
|
28
|
-
# Vue 宿主 × React 子应用:终端 1 起子应用,终端 2 起宿主
|
|
29
|
-
cd examples/bridge/react-remote && npm install && npm run dev # 5303
|
|
30
|
-
cd examples/bridge/vue-host && npm install && npm run dev # 5314
|
|
31
|
-
|
|
32
|
-
# React 宿主 × Vue 子应用
|
|
33
|
-
cd examples/bridge/vue-remote && npm install && npm run dev # 5313
|
|
34
|
-
cd examples/bridge/react-host && npm install && npm run dev # 5304
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
## 每对示例演示什么
|
|
38
|
-
|
|
39
|
-
- 远程可点击计数组件(本地状态在远程组件内,宿主页面直接操作)
|
|
40
|
-
- 普通 TS 模块跨应用调用(宿主展示真实返回值)
|
|
41
|
-
- 远程首页 + 带真实路由参数的详情页(深链刷新可恢复)
|
|
42
|
-
- 宿主导航、路由级懒加载(首页不批量预取未访问的远程页面)
|
|
43
|
-
- 插件默认加载/错误占位与恢复操作(**重试加载** 同页恢复;**刷新页面重试** 整页恢复)
|
|
44
|
-
- 生产构建 + 最小 Nginx 部署(含 SPA fallback)
|
|
45
|
-
|
|
46
|
-
## 目录
|
|
47
|
-
|
|
48
|
-
```text
|
|
49
|
-
examples/
|
|
50
|
-
├── README.md / README.en.md # 本入口(中/英)
|
|
51
|
-
├── bridge/ # 跨框架桥接(子应用级挂载/卸载,§8.2)
|
|
52
|
-
│ ├── README.md # 双向组合说明
|
|
53
|
-
│ ├── vue-host/ # Vue 宿主 × React 子应用(5314)
|
|
54
|
-
│ ├── react-remote/ # React 子应用(5303)
|
|
55
|
-
│ ├── react-host/ # React 宿主 × Vue 子应用(5304)
|
|
56
|
-
│ └── vue-remote/ # Vue 子应用(5313)
|
|
57
|
-
├── vue/
|
|
58
|
-
│ ├── README.md # Vue 一对示例的组合说明
|
|
59
|
-
│ ├── host/ # Vue 宿主(vue-host,5214)
|
|
60
|
-
│ └── remote/ # Vue 远程(vue-remote,5213)
|
|
61
|
-
└── react/
|
|
62
|
-
├── README.md # React 一对示例的组合说明
|
|
63
|
-
├── host/ # React 宿主(react-host,5204)
|
|
64
|
-
└── remote/ # React 远程(react-remote,5203)
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
> `examples/` 面向使用者拷贝运行;仓库根的 `fixtures/` 是插件内部回归夹具(源码 link 到插件工作区),请勿当作使用模板。
|
|
68
|
-
|
|
69
|
-
> 提示:复制后可在项目根目录运行 `npx fulgurjs explain`(纯本地、无网络)核对联邦配置摘要。
|
|
5
|
+
功能演示、大型应用集成和展示门户见 [GitHub 统一示例入口](https://github.com/chenmingye/fulgurjs-federation/tree/master/examples)。
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# fulgurjs-federation 模板(examples/templates/)
|
|
2
|
+
|
|
3
|
+
五个可独立复制、`pnpm install` 后直接运行的联邦接入模板。全部使用 **npm registry 正式包** `@fulgurjs/federation@5.8.0`(精确版本 + pnpm 锁文件),不依赖本仓库源码、workspace 或父目录。
|
|
4
|
+
|
|
5
|
+
## 获取模板的两种方式
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# 方式一(推荐):CLI 创建——不需要 clone 本仓库
|
|
9
|
+
npx @fulgurjs/federation create vue-vue --dir my-federation
|
|
10
|
+
# 交互式:npx @fulgurjs/federation create
|
|
11
|
+
# 模板清单:npx @fulgurjs/federation create --list
|
|
12
|
+
|
|
13
|
+
# 方式二:从仓库复制(clone 或下载 ZIP 后)
|
|
14
|
+
cp -r examples/templates/vue-vue /wherever/you/want && cd /wherever/you/want/vue-vue
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
`create` 复制完整模板并默认执行 `pnpm install --frozen-lockfile`;目标目录非空默认拒绝(`--force` 只增量复制,不删除已有文件);安装失败非零退出并显示原因。它不做应用名称/端口改写——需要改端口时按下方清单手工同步。
|
|
18
|
+
|
|
19
|
+
## 选择模板
|
|
20
|
+
|
|
21
|
+
| 模板 | 组合 | 演示能力 | 复制范围 |
|
|
22
|
+
|---|---|---|---|
|
|
23
|
+
| [`vue-vue/`](vue-vue) | Vue 宿主 × Vue 远程 | 远程组件/TS 模块、路由懒加载、错误占位与重试、生产部署 | 整个 `vue-vue/` 目录 |
|
|
24
|
+
| [`react-react/`](react-react) | React 宿主 × React 远程 | 同上(React 版:remoteComponent / useLoadRemote / ErrorBoundary) | 整个 `react-react/` 目录 |
|
|
25
|
+
| [`vue-host-react-remote/`](vue-host-react-remote) | Vue 宿主 × React 子应用 | 跨框架完整子应用桥接(挂载/卸载/appProps 快照) | 整个 `vue-host-react-remote/` 目录 |
|
|
26
|
+
| [`react-host-vue-remote/`](react-host-vue-remote) | React 宿主 × Vue 子应用 | 同上(反方向) | 整个 `react-host-vue-remote/` 目录 |
|
|
27
|
+
| [`showcase/`](showcase) | Vue/React 双宿主 × Vue/React 双远程 | **完整演示**:双向跨框架桥接、URL 同步(深链刷新/前进后退)、多远程并存、同框架子应用对照 | 整个 `showcase/` 目录 |
|
|
28
|
+
|
|
29
|
+
每个模板目录是一个完整 pnpm workspace(根 `package.json` + `pnpm-workspace.yaml` + `pnpm-lock.yaml`)。**必须复制整个模板目录**,不能只复制其中的子应用。
|
|
30
|
+
|
|
31
|
+
## 最短运行路径
|
|
32
|
+
|
|
33
|
+
环境要求:Node ≥ 20(实测 24.x)、pnpm ≥ 9。**推荐 pnpm ≥ 12**(锁文件由 pnpm 12 生成;9/10/11 亦可安装)。平台口径:macOS 与 Linux(CI)实测;启动器含 Windows 兜底路径但**未经验证**。
|
|
34
|
+
|
|
35
|
+
> **pnpm 12 用户注意**:各模板 `pnpm-workspace.yaml` 已带 `allowBuilds: {esbuild: true, vue-demi: true}`(pnpm 12 的构建脚本批准形态;pnpm 9–11 忽略该键——esbuild ≥0.16 的二进制经 optionalDependencies 平台包分发,postinstall 仅做校验,不影响安装与运行)。若用 pnpm 10/11 且提示未批准构建脚本,可改回 `onlyBuiltDependencies: [esbuild, vue-demi]` 或按提示 `pnpm approve-builds`。**不要**让 pnpm 把 `allowBuilds: <pkg>: set this to true or false` 的占位提示留在 yaml 里——把值改成 `true` 即可通过(pnpm 12 会在遇到未决构建脚本时自动写入该提示行)。
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
# 以 vue-vue 为例;其余模板把目录名换掉即可
|
|
39
|
+
pnpm install # 安装(锁文件冻结:pnpm install --frozen-lockfile)
|
|
40
|
+
pnpm dev # 统一启动器:远程(5213) + 宿主(5214) 按顺序启动
|
|
41
|
+
# 打开 http://localhost:5214 —— 远程按钮、TS 模块调用、路由懒加载、错误恢复演示
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
各模板端口(远程先于宿主启动):
|
|
45
|
+
|
|
46
|
+
| 模板 | 远程 | 宿主 |
|
|
47
|
+
|---|---|---|
|
|
48
|
+
| vue-vue | 5213 | 5214 |
|
|
49
|
+
| react-react | 5203 | 5204 |
|
|
50
|
+
| vue-host-react-remote | react-remote 5303 | vue-host 5314 |
|
|
51
|
+
| react-host-vue-remote | vue-remote 5313 | react-host 5304 |
|
|
52
|
+
| showcase | vue-remote 5335 / react-remote 5333 | vue-host 5334 / react-host 5336 |
|
|
53
|
+
|
|
54
|
+
## 统一 dev 启动器(`pnpm dev`)的行为
|
|
55
|
+
|
|
56
|
+
五个模板共用同一份启动脚本(模板内 `scripts/dev.mjs`,规范源在仓库 `examples/scripts/dev-runner.mjs`,`npm run test:examples` 校验一致)。行为:
|
|
57
|
+
|
|
58
|
+
- **启动前端口预检**:任一端口被占用则拒绝启动(退出码 2),打印占用查看命令与处理方法;不会替你结束端口上的既有服务。
|
|
59
|
+
- **按序启动、逐个探活**:远程先启动,就绪后再启动宿主;日志带 `[应用名]` 前缀。
|
|
60
|
+
- **失败整组退出**:任一应用启动失败/超时/运行中退出,停止本次启动的全部进程(退出码 1)并打印该应用日志尾部;不留下半残组合。
|
|
61
|
+
- **Ctrl+C / SIGTERM 清理**:只清理本次启动的子进程(进程组级),不依赖 PID 文件,不按端口批量杀进程。
|
|
62
|
+
- 单独调试某个应用:`pnpm run dev:remote` / `pnpm run dev:host`(showcase 有四个 `dev:*` 入口),绕过启动器直接启动。
|
|
63
|
+
- 「dev server 已监听」表示端口就绪;页面可用以浏览器实际加载为准。
|
|
64
|
+
|
|
65
|
+
## 改端口的固定清单
|
|
66
|
+
|
|
67
|
+
模板不做端口/名称自动改写;需要改时同步以下三处(以 vue-vue 的远程 5213 为例):
|
|
68
|
+
|
|
69
|
+
1. `remote/package.json` 的 `dev` 与 `preview` 脚本里的 `--port 5213`;
|
|
70
|
+
2. `host/fulgurjs.config.ts` 中 `remotes['vue-remote'].dev` 的 `http://localhost:5213`;
|
|
71
|
+
3. (可选)根 `scripts/dev.config.json` 里该应用的 `port`,保持启动器/文档/场景表一致。
|
|
72
|
+
|
|
73
|
+
宿主自身端口在 `host/package.json` 的 dev/preview 脚本。跨应用容器名(如 `vue-remote`)改名时,还需同步宿主代码中的 spec 前缀(`vue-remote/...`)与页面表——不建议改名。
|
|
74
|
+
|
|
75
|
+
## 生产构建与部署
|
|
76
|
+
|
|
77
|
+
`pnpm build` 后产物为标准 Vite dist,远程会多生成 `fulgurjs-remoteEntry.js` 与 `fulgurjs-manifest.json`,用 no-cache 规则部署,SPA fallback 配置见 [Vue 模板部署说明](vue-vue/README.md#生产构建与最小-nginx-部署)。部署后可用 `npx fulgurjs doctor --base <站点> --apps <部署子目录>` 体检(`--apps` 是部署子目录,不是容器名)。
|
|
78
|
+
|
|
79
|
+
## 模板覆盖的能力 → 去哪看
|
|
80
|
+
|
|
81
|
+
- **组件/模块加载、错误占位、重试恢复**:Vue/Vue 与 React/React 模板首页即演示。
|
|
82
|
+
- **跨框架完整子应用挂载/卸载、appProps 快照、会话切换**:两个桥接模板。
|
|
83
|
+
- **URL 同步(子应用内部路由 ↔ 宿主地址、刷新直达、前进后退、多层嵌套)**:showcase,宿主页 URL 变化随子应用导航联动。
|
|
84
|
+
- **shared 共享协商、React 18/19 隔离、页面接入(createHostPages)、错误注入与恢复、Jeecg 三层嵌套**:不在模板内重复造码,直接用[统一示例入口](../README.md) 中的对应场景(`examples/demos/shared`、`examples/demos/react-versions`、`examples/demos/pages-cli`、`examples/demos/errors`、`examples/integrations/jeecg`),同样可独立下载运行(见 [功能演示说明](https://github.com/chenmingye/fulgurjs-federation/tree/master/examples/demos))。
|
|
85
|
+
|
|
86
|
+
## 与展示门户的关系
|
|
87
|
+
|
|
88
|
+
这五个模板也是门户的基础场景工程。门户通过 `examples/scenarios.json` 直接启动本目录里的宿主与远程,不维护另一份基础源码。功能演示在 [demos/](https://github.com/chenmingye/fulgurjs-federation/tree/master/examples/demos),大型集成在 [integrations/](https://github.com/chenmingye/fulgurjs-federation/tree/master/examples/integrations)。
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# react-host-vue-remote:完整子应用桥接模板
|
|
2
|
+
|
|
3
|
+
`react-host/` 是宿主,`vue-remote/` 是子应用。复制整个模板目录,在根目录运行:
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
pnpm install --frozen-lockfile
|
|
7
|
+
pnpm dev
|
|
8
|
+
# http://localhost:5304
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
宿主展示远程应用、上下文传递与会话切换;切换用户或登出会卸载旧代次。远程独立运行与被嵌入时使用不同路由接线。
|
|
12
|
+
|
|
13
|
+
- 单独启动:`pnpm dev:remote`、`pnpm dev:host`。
|
|
14
|
+
- 生产构建:`pnpm build`,按各子应用配置的 base 部署 dist;远程入口与宿主的 prod 地址必须一致。各子应用 README 提供配置与部署细节。
|
|
15
|
+
- 本模板展示挂载、卸载与会话,不开启宿主/子应用 URL 同步;需要深链、刷新和前进后退,使用 [showcase](../showcase/)。
|
|
16
|
+
- 无 JS 沙箱或自动 CSS 隔离,子应用全局样式和 body 副作用需要自行管理。
|
|
17
|
+
|
|
18
|
+
环境要求见[模板指南](../README.md)。所有依赖来自 registry,不需要本仓库源码或其他模板。
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "fulgurjs-template-react-host-vue-remote",
|
|
3
|
+
"private": true,
|
|
4
|
+
"version": "0.0.0",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"dev:remote": "pnpm --dir vue-remote dev",
|
|
7
|
+
"dev:host": "pnpm --dir react-host dev",
|
|
8
|
+
"dev": "node scripts/dev.mjs",
|
|
9
|
+
"build": "pnpm --dir vue-remote build && pnpm --dir react-host build"
|
|
10
|
+
}
|
|
11
|
+
}
|