@fulgurjs/federation 5.8.0 → 5.9.1
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 +19 -4
- package/README.en.md +60 -24
- package/README.md +60 -24
- package/dist/cli.js +327 -29
- package/dist/index.cjs +2 -2
- package/dist/index.js +2 -2
- package/dist/runtime.js +1 -1
- package/docs/API.en.md +14 -3
- package/docs/API.md +7 -6
- package/docs/webpack-mf-/345/257/271/347/205/247/344/270/216/347/274/272/345/217/243.md +2 -2
- 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 +4 -4
- 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
|
@@ -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
|
+
}
|