@fulgurjs/federation 5.1.4 → 5.2.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.
Files changed (84) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.en.md +5 -5
  3. package/README.md +12 -12
  4. package/dist/index.cjs +91 -3
  5. package/dist/index.js +91 -3
  6. package/dist/react-adapter.cjs +32 -1
  7. package/dist/react-adapter.d.cts +1 -1
  8. package/dist/react-adapter.d.ts +1 -1
  9. package/dist/react-adapter.js +32 -1
  10. package/dist/react.d.ts +1 -1
  11. package/dist/runtime-entry.d.ts +1 -1
  12. package/dist/runtime.js +1 -1
  13. package/dist/vue-adapter.cjs +99 -15
  14. package/dist/vue-adapter.d.cts +1 -1
  15. package/dist/vue-adapter.d.ts +1 -1
  16. package/dist/vue-adapter.js +100 -16
  17. package/examples/README.en.md +47 -0
  18. package/examples/README.md +40 -18
  19. package/examples/react/README.md +83 -0
  20. package/examples/react/host/README.md +49 -0
  21. package/examples/react/host/fulgurjs.config.ts +31 -0
  22. package/examples/{react-remote → react/host}/index.html +2 -1
  23. package/examples/react/host/package-lock.json +2383 -0
  24. package/examples/{react-host → react/host}/package.json +9 -8
  25. package/examples/react/host/src/App.tsx +19 -0
  26. package/examples/react/host/src/main.tsx +33 -0
  27. package/examples/react/host/src/pages/UtilsDemo.tsx +32 -0
  28. package/examples/react/host/src/remotePages.tsx +16 -0
  29. package/examples/{react-remote → react/host}/tsconfig.json +2 -3
  30. package/examples/{react-remote → react/host}/vite.config.ts +2 -2
  31. package/examples/react/remote/README.md +47 -0
  32. package/examples/react/remote/fulgurjs.config.ts +20 -0
  33. package/examples/{react-host → react/remote}/index.html +2 -1
  34. package/examples/react/remote/package-lock.json +2325 -0
  35. package/examples/{react-remote → react/remote}/package.json +8 -7
  36. package/examples/react/remote/src/App.tsx +16 -0
  37. package/examples/react/remote/src/exposes/ClickButton.tsx +15 -0
  38. package/examples/react/remote/src/exposes/pages/DetailPage.tsx +10 -0
  39. package/examples/react/remote/src/exposes/pages/HomePage.tsx +12 -0
  40. package/examples/react/remote/src/exposes/utils.ts +10 -0
  41. package/examples/react/remote/src/main.tsx +11 -0
  42. package/examples/{react-host → react/remote}/tsconfig.json +3 -4
  43. package/examples/{react-host → react/remote}/vite.config.ts +2 -2
  44. package/examples/vue/README.md +85 -0
  45. package/examples/vue/host/README.md +50 -0
  46. package/examples/vue/host/fulgurjs.config.ts +30 -0
  47. package/examples/vue/host/index.html +12 -0
  48. package/examples/vue/host/package-lock.json +1857 -0
  49. package/examples/vue/host/package.json +21 -0
  50. package/examples/vue/host/src/App.vue +12 -0
  51. package/examples/vue/host/src/main.ts +44 -0
  52. package/examples/vue/host/src/pages/HomePage.vue +16 -0
  53. package/examples/vue/host/src/pages/UtilsDemo.vue +45 -0
  54. package/examples/vue/host/tsconfig.json +13 -0
  55. package/examples/vue/host/vite.config.ts +8 -0
  56. package/examples/vue/remote/README.md +47 -0
  57. package/examples/vue/remote/fulgurjs.config.ts +20 -0
  58. package/examples/vue/remote/index.html +12 -0
  59. package/examples/vue/remote/package-lock.json +1835 -0
  60. package/examples/vue/remote/package.json +20 -0
  61. package/examples/vue/remote/src/App.vue +16 -0
  62. package/examples/vue/remote/src/exposes/ClickButton.vue +16 -0
  63. package/examples/vue/remote/src/exposes/pages/DetailPage.vue +14 -0
  64. package/examples/vue/remote/src/exposes/pages/HomePage.vue +11 -0
  65. package/examples/vue/remote/src/exposes/utils.ts +10 -0
  66. package/examples/vue/remote/src/main.ts +6 -0
  67. package/examples/vue/remote/tsconfig.json +13 -0
  68. package/examples/vue/remote/vite.config.ts +8 -0
  69. package/package.json +2 -2
  70. package/examples/host/fulgurjs.config.ts +0 -26
  71. package/examples/react-host/README.md +0 -28
  72. package/examples/react-host/fulgurjs.config.ts +0 -19
  73. package/examples/react-host/src/App.tsx +0 -66
  74. package/examples/react-host/src/federation/pages.data.ts +0 -21
  75. package/examples/react-host/src/main.tsx +0 -8
  76. package/examples/react-remote/fulgurjs.config.ts +0 -17
  77. package/examples/react-remote/src/Button.tsx +0 -15
  78. package/examples/react-remote/src/main.tsx +0 -6
  79. package/examples/react-remote/src/pages/Detail.tsx +0 -10
  80. package/examples/react-remote/src/pages/Home.tsx +0 -14
  81. package/examples/react-remote/src/utils.ts +0 -3
  82. package/examples/remote-a/fulgurjs.config.ts +0 -24
  83. package/examples/remote-a/src/views/Detail.vue +0 -3
  84. package/examples/remote-a/src/views/Home.vue +0 -3
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "fulgurjs-demo-vue-remote",
3
+ "private": true,
4
+ "version": "0.0.0",
5
+ "type": "module",
6
+ "scripts": {
7
+ "dev": "vite --port 5213 --strictPort",
8
+ "build": "vite build",
9
+ "preview": "vite preview --port 5213 --strictPort"
10
+ },
11
+ "dependencies": {
12
+ "@fulgurjs/federation": "5.2.0",
13
+ "vue": "^3.5.13"
14
+ },
15
+ "devDependencies": {
16
+ "@vitejs/plugin-vue": "^5.2.1",
17
+ "typescript": "^5.8.0",
18
+ "vite": "^6.3.5"
19
+ }
20
+ }
@@ -0,0 +1,16 @@
1
+ <template>
2
+ <div style="font-family: sans-serif; padding: 16px">
3
+ <h1>vue-remote 独立运行</h1>
4
+ <p>这是远程应用自己的壳,用于单独开发。联邦消费方(examples/vue/host)按 exposes 加载以下模块:</p>
5
+ <ul>
6
+ <li>./ClickButton —— 可点击计数按钮组件</li>
7
+ <li>./utils —— 普通 TS 工具模块</li>
8
+ <li>./pages/HomePage / ./pages/DetailPage —— 联邦页面</li>
9
+ </ul>
10
+ <ClickButton />
11
+ </div>
12
+ </template>
13
+
14
+ <script setup lang="ts">
15
+ import ClickButton from './exposes/ClickButton.vue'
16
+ </script>
@@ -0,0 +1,16 @@
1
+ <template>
2
+ <button
3
+ data-testid="demo-remote-button"
4
+ style="padding: 8px 16px; border: none; border-radius: 6px; background: #1677ff; color: #fff; cursor: pointer"
5
+ @click="count++"
6
+ >
7
+ 远程按钮(点击了 {{ count }} 次)
8
+ </button>
9
+ </template>
10
+
11
+ <script setup lang="ts">
12
+ import { ref } from 'vue'
13
+
14
+ // 本地状态保存在远程组件内部;被宿主消费时运行在宿主页面的 Vue 实例上
15
+ const count = ref(0)
16
+ </script>
@@ -0,0 +1,14 @@
1
+ <template>
2
+ <div data-testid="demo-remote-detail">
3
+ <h3>vue-remote / 详情页</h3>
4
+ <p data-testid="demo-detail-id">路由参数 id:{{ id }}</p>
5
+ <p data-testid="demo-detail-tab">query 参数 tab:{{ tab }}</p>
6
+ </div>
7
+ </template>
8
+
9
+ <script setup lang="ts">
10
+ // 页面参数由宿主路由传入(宿主把 route.params + route.query 作为 props 透传)
11
+ const props = defineProps<{ id?: string; tab?: string }>()
12
+ const id = props.id ?? '(无)'
13
+ const tab = props.tab ?? '(无)'
14
+ </script>
@@ -0,0 +1,11 @@
1
+ <template>
2
+ <div data-testid="demo-remote-home">
3
+ <h3>vue-remote / 首页</h3>
4
+ <p>这是由 vue-remote 暴露的联邦页面,渲染在宿主的路由出口内。</p>
5
+ <ClickButton />
6
+ </div>
7
+ </template>
8
+
9
+ <script setup lang="ts">
10
+ import ClickButton from '../ClickButton.vue'
11
+ </script>
@@ -0,0 +1,10 @@
1
+ /** 普通 TS 工具模块:演示跨应用函数/常量消费(不含任何组件) */
2
+ export const DEMO_ANSWER = 42
3
+
4
+ export function sumNumbers(...numbers: number[]): number {
5
+ return numbers.reduce((acc, n) => acc + n, 0)
6
+ }
7
+
8
+ export function formatPrice(yuan: number): string {
9
+ return `¥${yuan.toFixed(2)}`
10
+ }
@@ -0,0 +1,6 @@
1
+ import { createApp } from 'vue'
2
+ import App from './App.vue'
3
+
4
+ // 独立运行入口:单独开发/调试远程自身时使用。
5
+ // 被宿主消费时走的是 fulgurjs-remoteEntry.js 容器入口,与本文件无关。
6
+ createApp(App).mount('#app')
@@ -0,0 +1,13 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "ESNext",
5
+ "moduleResolution": "bundler",
6
+ "strict": true,
7
+ "jsx": "preserve",
8
+ "skipLibCheck": true,
9
+ "noEmit": true,
10
+ "types": ["vite/client"]
11
+ },
12
+ "include": ["src", "fulgurjs.config.ts", "vite.config.ts"]
13
+ }
@@ -0,0 +1,8 @@
1
+ import { defineConfig } from 'vite'
2
+ import vue from '@vitejs/plugin-vue'
3
+ import { federation } from '@fulgurjs/federation'
4
+ import fulgurjsConfig from './fulgurjs.config.ts'
5
+
6
+ export default defineConfig({
7
+ plugins: [vue(), federation(fulgurjsConfig)],
8
+ })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fulgurjs/federation",
3
- "version": "5.1.4",
3
+ "version": "5.2.1",
4
4
  "type": "module",
5
5
  "description": "Vite Module Federation with full Webpack MF parity. Dev & production, no compromise.",
6
6
  "license": "MIT",
@@ -67,7 +67,7 @@
67
67
  "docs/P5-vite7-8兼容矩阵.md"
68
68
  ],
69
69
  "scripts": {
70
- "build": "cp ../../README.md README.md && cp ../../README.en.md README.en.md && mkdir -p docs && cp ../../docs/迁移指南.md ../../docs/webpack-mf-对照与缺口.md ../../docs/沙箱边界审计.md ../../docs/P5-vite7-8兼容矩阵.md docs/ && cp ../../CHANGELOG.md CHANGELOG.md && cp ../../DESIGN.md DESIGN.md && rm -rf examples && cp -r ../../examples examples && esbuild src/runtime/index.ts --bundle --format=esm --target=es2022 --minify --outfile=dist/runtime.js && node scripts/gen-runtime.mjs && tsup src/index.ts src/pages.ts src/vue-adapter.ts src/react-adapter.ts src/context.ts --format esm,cjs --dts --external vite --target node18 --clean && tsup src/runtime-entry.ts --format esm --dts --external vite,vue --target node18 && tsup src/react.ts --format esm --dts --external vite,react --target node18 && esbuild src/cli.ts --bundle --format=esm --target=node18 --platform=node --outfile=dist/cli.js && esbuild src/runtime/index.ts --bundle --format=esm --target=es2022 --minify --outfile=dist/runtime.js && node scripts/gen-runtime-entry.mjs && node scripts/check-gzip.mjs && node scripts/check-manual-codes.mjs",
70
+ "build": "cp ../../README.md README.md && cp ../../README.en.md README.en.md && mkdir -p docs && cp ../../docs/迁移指南.md ../../docs/webpack-mf-对照与缺口.md ../../docs/沙箱边界审计.md ../../docs/P5-vite7-8兼容矩阵.md docs/ && cp ../../CHANGELOG.md CHANGELOG.md && cp ../../DESIGN.md DESIGN.md && rm -rf examples && cp -R ../../examples examples && find examples \\( -name node_modules -o -name dist -o -path '*/src/fulgurjs/types' \\) -exec rm -rf {} + && esbuild src/runtime/index.ts --bundle --format=esm --target=es2022 --minify --outfile=dist/runtime.js && node scripts/gen-runtime.mjs && tsup src/index.ts src/pages.ts src/vue-adapter.ts src/react-adapter.ts src/context.ts --format esm,cjs --dts --external vite --target node18 --clean && tsup src/runtime-entry.ts --format esm --dts --external vite,vue --target node18 && tsup src/react.ts --format esm --dts --external vite,react --target node18 && esbuild src/cli.ts --bundle --format=esm --target=node18 --platform=node --outfile=dist/cli.js && esbuild src/runtime/index.ts --bundle --format=esm --target=es2022 --minify --outfile=dist/runtime.js && node scripts/gen-runtime-entry.mjs && node scripts/check-gzip.mjs && node scripts/check-manual-codes.mjs",
71
71
  "dev": "tsup --watch",
72
72
  "test": "vitest run",
73
73
  "typecheck": "tsc --noEmit",
@@ -1,26 +0,0 @@
1
- // host/fulgurjs.config.ts —— 宿主应用自己的配置(一项目一份;整文件可复制到你的宿主项目根目录)
2
- //
3
- // 宿主只写自己的 name / remotes / shared;页面核对数据以具名导出 hostPages 提供给 CLI。
4
- // Vite 接入(本项目 vite.config.ts 只需两行联邦相关代码):
5
- // import federation from '@fulgurjs/federation'
6
- // import fulgurjsConfig from './fulgurjs.config'
7
- // // plugins: [ ...原有插件, federation(fulgurjsConfig) ]
8
- import type { FederationOptions } from '@fulgurjs/federation'
9
-
10
- export default {
11
- name: 'host-app',
12
- // 消费的远程(键 = import 前缀;dev/prod 地址二段式,单地址字符串也行)
13
- remotes: {
14
- 'remote-a': { dev: 'http://localhost:5174/remote-a', prod: '/remote-a' },
15
- },
16
- shared: {
17
- vue: { singleton: true },
18
- },
19
- } satisfies FederationOptions
20
-
21
- // ── 以下仅供 CLI explain/check-pages 读取(不是 federation() 的参数)──
22
- // 页面数据与运行时 createHostPages 消费同一份纯数据模块(唯一手工维护位置)
23
- export const hostPages = {
24
- remotePrefixes: { '/remote-a/': 'remote-a' },
25
- pages: [{ route: '/remote-a/home', name: 'RemoteAHome', title: '首页' }],
26
- }
@@ -1,28 +0,0 @@
1
- # react-host / react-remote(React 宿主与远程示例)
2
-
3
- 独立可运行的 React 联邦工程:从 npm registry 安装正式版 `@fulgurjs/federation`(无 link:/workspace:/绝对路径依赖)。
4
-
5
- ## 运行
6
-
7
- ```bash
8
- # 终端 1:远程(5203)
9
- cd react-remote && npm install && npm run dev
10
-
11
- # 终端 2:宿主(5204)
12
- cd react-host && npm install && npm run dev
13
- # 打开 http://localhost:5204 —— 首页有远程按钮与 utils 模块,/remote-react/home 与 /remote-react/detail/42?tab=basic 是远程页面
14
- ```
15
-
16
- ## 配置形态(每个应用两份文件)
17
-
18
- - `fulgurjs.config.ts`:纯数据(FederationOptions)——`vite.config.ts` 调 `federation(fulgurjsConfig)`,`react()` 照常放 plugins。
19
- - React 应用统一从 `@fulgurjs/federation/react` 导入(`remoteComponent` / `useLoadRemote` / `RemoteErrorBoundary` / `createReactHostPages` 与通用运行时 API)。
20
-
21
- ## CLI
22
-
23
- ```bash
24
- npx fulgurjs explain # 解析联邦配置
25
- npx fulgurjs check-pages # 校验页面表与线上 manifest(远程 dev server 启动时)
26
- ```
27
-
28
- 与 `fixtures/`(仓库内 e2e 回归夹具,用 `link:` 依赖本地插件)的区别:examples 面向使用者复制,依赖来自 registry。
@@ -1,19 +0,0 @@
1
- import type { FederationOptions } from '@fulgurjs/federation'
2
- import { pages, remotePrefixes } from './src/federation/pages.data'
3
-
4
- export default {
5
- name: 'host-react',
6
- remotes: {
7
- 'remote-react': {
8
- dev: 'http://localhost:5203',
9
- prod: '/remote-react/',
10
- },
11
- },
12
- shared: {
13
- react: { singleton: true },
14
- 'react-dom': { singleton: true },
15
- },
16
- } satisfies FederationOptions
17
-
18
- /** 仅 CLI 读取(fulgurjs explain/check-pages);同一纯数据模块也供浏览器页面适配器使用 */
19
- export const hostPages = { pages, remotePrefixes }
@@ -1,66 +0,0 @@
1
- /**
2
- * react-host:一个文件看清 React 宿主的联邦用法。
3
- * ① 每个应用根目录一份 fulgurjs.config.ts(纯数据);vite.config.ts 调 federation(fulgurjsConfig)
4
- * ② React 应用统一从 '@fulgurjs/federation/react' 导入(通用运行时 + React 适配 API)
5
- * ③ remoteComponent 工厂放模块顶层(首次渲染才加载);页面用 createReactHostPages + component(spec)
6
- */
7
- import { Link, Route, Routes, useParams, useSearchParams } from 'react-router-dom'
8
- import {
9
- createReactHostPages,
10
- remoteComponent,
11
- remoteSchema,
12
- useLoadRemote,
13
- } from '@fulgurjs/federation/react'
14
- import { pages, remotePrefixes } from './federation/pages.data'
15
-
16
- // 页面表(纯数据 + dev schema;R1–R5 校验与 Vue 完全一致)
17
- const hp = createReactHostPages({ pages, remotePrefixes, schema: remoteSchema })
18
-
19
- // 普通远程组件:模块顶层创建,不能在 render 内重复调用工厂
20
- const RemoteButton = remoteComponent<{ label: string; onClick?: () => void }>('remote-react/Button', {
21
- fallback: <p>正在加载远程按钮…</p>,
22
- })
23
-
24
- // 页面组件:与 Vue 相同动词 component(spec);路由层用 element 渲染
25
- const RemoteHome = hp.component('remote-react/pages/home')
26
- const RemoteDetail = hp.component<{ id: string; tab?: string }>('remote-react/pages/detail')
27
-
28
- /** 普通远程模块:useLoadRemote(data/error/loading/reload;错误无默认占位,由宿主决定 UI) */
29
- function UtilsPanel() {
30
- type Utils = { formatMoney(v: number, currency?: string): string }
31
- const { data, error, loading, reload } = useLoadRemote<Utils>('remote-react/utils')
32
- if (loading) return <p>utils 加载中…</p>
33
- if (error) return <button onClick={() => void reload()}>utils 加载失败,重试</button>
34
- return (
35
- <p>
36
- 12.5 → {data?.formatMoney(12.5)}(<button onClick={() => void reload()}>reload</button>)
37
- </p>
38
- )
39
- }
40
-
41
- function DetailRoute() {
42
- const { id } = useParams()
43
- const [sp] = useSearchParams()
44
- return <RemoteDetail id={id ?? ''} tab={sp.get('tab') ?? undefined} />
45
- }
46
-
47
- export default function App() {
48
- return (
49
- <div style={{ fontFamily: 'sans-serif', padding: 16 }}>
50
- <h1>react-host(fulgurjs example)</h1>
51
- <nav>
52
- <Link to="/">首页</Link> · <Link to="/remote-react/home">远程首页</Link> ·{' '}
53
- <Link to="/remote-react/detail/42?tab=basic">远程参数页</Link>
54
- </nav>
55
- <Routes>
56
- <Route path="/" element={<main>
57
- <p>宿主首页(远程组件按需加载)</p>
58
- <RemoteButton label="远程按钮" onClick={() => console.log('clicked')} />
59
- <UtilsPanel />
60
- </main>} />
61
- <Route path="/remote-react/home" element={<RemoteHome />} />
62
- <Route path="/remote-react/detail/:id" element={<DetailRoute />} />
63
- </Routes>
64
- </div>
65
- )
66
- }
@@ -1,21 +0,0 @@
1
- /**
2
- * 页面表数据(纯数据:不 import React/路由库/浏览器对象——CLI 与浏览器适配器共用)。
3
- * spec 缺省推导 = 去首段(远程前缀)+ 剥 :参数 段;带参路由建议显式 spec。
4
- */
5
- export interface PageRecord {
6
- route: string
7
- spec?: string
8
- name?: string
9
- title?: string
10
- /** 宿主自由扩展位(keepAlive 等)——与插件 PageRouteLike 的 index signature 对齐 */
11
- [key: string]: unknown
12
- }
13
-
14
- export const pages: PageRecord[] = [
15
- { route: '/remote-react/home', spec: 'pages/home', name: 'RemoteHome' },
16
- { route: '/remote-react/detail/:id', spec: 'pages/detail', name: 'RemoteDetail' },
17
- ]
18
-
19
- export const remotePrefixes: Record<string, string> = {
20
- '/remote-react': 'remote-react',
21
- }
@@ -1,8 +0,0 @@
1
- import { createElement, StrictMode } from 'react'
2
- import { createRoot } from 'react-dom/client'
3
- import { BrowserRouter } from 'react-router-dom'
4
- import App from './App'
5
-
6
- createRoot(document.getElementById('root')!).render(
7
- createElement(StrictMode, null, createElement(BrowserRouter, null, createElement(App))),
8
- )
@@ -1,17 +0,0 @@
1
- import type { FederationOptions } from '@fulgurjs/federation'
2
-
3
- export default {
4
- name: 'remote-react',
5
- exposes: {
6
- './Button': './src/Button.tsx',
7
- './utils': './src/utils.ts',
8
- './pages/home': './src/pages/Home.tsx',
9
- './pages/detail': './src/pages/Detail.tsx',
10
- },
11
- // 有初始化需求才添加(应用级 setup 一次 + 会话级 onSession 按宿主 sessionKey 去重):
12
- // setup: './src/fulgurjs/setup.ts',
13
- shared: {
14
- react: { singleton: true },
15
- 'react-dom': { singleton: true },
16
- },
17
- } satisfies FederationOptions
@@ -1,15 +0,0 @@
1
- import { useState } from 'react'
2
-
3
- export interface ButtonProps {
4
- label: string
5
- onClick?: () => void
6
- }
7
-
8
- export default function Button({ label, onClick }: ButtonProps) {
9
- const [count, setCount] = useState(0)
10
- return (
11
- <button type="button" onClick={() => { setCount((c) => c + 1); onClick?.() }}>
12
- {label}:已点击 {count} 次
13
- </button>
14
- )
15
- }
@@ -1,6 +0,0 @@
1
- import { createElement } from 'react'
2
- import { createRoot } from 'react-dom/client'
3
-
4
- createRoot(document.getElementById('root')!).render(
5
- createElement('p', null, 'react-remote 独立运行(联邦消费请从 react-host 访问)'),
6
- )
@@ -1,10 +0,0 @@
1
- /** 参数页:宿主路由的 params/query 以 props 传入(id 必填) */
2
- export default function Detail({ id, tab }: { id: string; tab?: string }) {
3
- return (
4
- <section>
5
- <h2>remote-react / Detail</h2>
6
- <p>id: {id}</p>
7
- <p>tab: {tab ?? '(none)'}</p>
8
- </section>
9
- )
10
- }
@@ -1,14 +0,0 @@
1
- import { useEffect, useState } from 'react'
2
-
3
- export default function Home() {
4
- const [now, setNow] = useState('')
5
- useEffect(() => {
6
- setNow(new Date().toISOString().slice(0, 19))
7
- }, [])
8
- return (
9
- <section>
10
- <h2>remote-react / Home</h2>
11
- <p>mounted at {now}</p>
12
- </section>
13
- )
14
- }
@@ -1,3 +0,0 @@
1
- export function formatMoney(value: number, currency = '¥'): string {
2
- return `${currency}${value.toFixed(2)}`
3
- }
@@ -1,24 +0,0 @@
1
- // remote-a/fulgurjs.config.ts —— 远程应用自己的配置(一项目一份;整文件可复制到你的远程项目根目录)
2
- //
3
- // Vite 接入(本项目 vite.config.ts 只需两行联邦相关代码):
4
- // import federation from '@fulgurjs/federation'
5
- // import fulgurjsConfig from './fulgurjs.config'
6
- // // plugins: [ ...原有插件, federation(fulgurjsConfig) ]
7
- //
8
- // CLI(纯本地,无网络):npx fulgurjs explain
9
- import type { FederationOptions } from '@fulgurjs/federation'
10
-
11
- export default {
12
- // 联邦容器名(宿主引用它时用这个名;同一页面内唯一)
13
- name: 'remote-a',
14
- // 对外暴露的模块:'./键' → 相对本项目根的源文件路径
15
- exposes: {
16
- './pages/remote-a/home': './src/views/Home.vue',
17
- './pages/remote-a/detail': './src/views/Detail.vue',
18
- },
19
- // 可选:远程需要启动期初始化(全局样式/组件/locale)时声明入口文件
20
- // setup: './src/fulgurjs/setup.ts',
21
- shared: {
22
- vue: { singleton: true },
23
- },
24
- } satisfies FederationOptions
@@ -1,3 +0,0 @@
1
- <template>
2
- <div>remote-a detail</div>
3
- </template>
@@ -1,3 +0,0 @@
1
- <template>
2
- <div>remote-a home</div>
3
- </template>