@fulgurjs/federation 0.4.2

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.
@@ -0,0 +1,82 @@
1
+ import { Plugin } from 'vite';
2
+
3
+ interface SharedHint {
4
+ /** 放入共享作用域的本地模块;false 表示不提供本地副本 */
5
+ import?: string | false;
6
+ /** 用于从 package.json 推断 requiredVersion 的包名 */
7
+ packageName?: string;
8
+ /** 期望版本(完整 semver 语法 / false 接受任意) */
9
+ requiredVersion?: string | false;
10
+ /** 只允许单实例 */
11
+ singleton?: boolean;
12
+ /** 版本无效时抛运行时错误(默认:有本地副本且非 singleton 时为 true,对齐 webpack) */
13
+ strictVersion?: boolean;
14
+ /** 在共享作用域中的键(导入名与共享名不同时使用) */
15
+ shareKey?: string;
16
+ /** 共享作用域命名空间 */
17
+ shareScope?: string;
18
+ /** 同步提供(打进初始 chunk,总是被下载) */
19
+ eager?: boolean;
20
+ /** 提供版本显式指定 */
21
+ version?: string;
22
+ }
23
+ type SharedConfig = string[] | Record<string, string | SharedHint>;
24
+ interface ExposeHint {
25
+ import: string;
26
+ /** 稳定 chunk 文件名(不写则内部 id,随构建变化) */
27
+ name?: string;
28
+ }
29
+ interface RemoteEntryConfig {
30
+ external?: string;
31
+ shareScope?: string;
32
+ /** dev 专用地址(缺省回落 external) */
33
+ dev?: string;
34
+ /** prod 专用地址(缺省回落 external) */
35
+ prod?: string;
36
+ timeout?: number;
37
+ retries?: number;
38
+ /** 备用 remoteEntry 地址 */
39
+ fallback?: string[];
40
+ breaker?: {
41
+ threshold?: number;
42
+ resetMs?: number;
43
+ };
44
+ }
45
+ interface FulgurOptions {
46
+ name: string;
47
+ filename?: string;
48
+ exposes?: Record<string, string | ExposeHint>;
49
+ remotes?: Record<string, string | RemoteEntryConfig | (() => Promise<any>)>;
50
+ shared?: SharedConfig;
51
+ shareScope?: string;
52
+ remoteType?: string;
53
+ library?: {
54
+ type?: string;
55
+ name?: string;
56
+ };
57
+ runtime?: string | false;
58
+ runtimeChunk?: boolean | 'single';
59
+ manifest?: boolean | Record<string, unknown>;
60
+ runtimePlugins?: string[];
61
+ dts?: boolean | {
62
+ dir?: string;
63
+ };
64
+ /** 接受并恒为 true:TLA 天然异步边界,无需手工 bootstrap(比 webpack 更进一步) */
65
+ automaticAsyncBoundary?: boolean;
66
+ /** 接受并恒为 true:preloadRemote 能力始终可用 */
67
+ dataPrefetch?: boolean;
68
+ /** 接受 no-op:Rollup/Rolldown 原生 tree-shaking 已覆盖 */
69
+ usedExports?: boolean;
70
+ ignoreUnusedSharedExports?: boolean;
71
+ /**
72
+ * dev 下自身源码(含依赖,需配合 optimizeDeps.exclude)是否参与 shared 协商改写。
73
+ * 默认:纯 remote(无 remotes)为 true——被宿主消费的组件需协商到宿主实例;
74
+ * 有 remotes 的宿主为 false——自身 import 即自身 provide,避免巨型工程 TLA/循环依赖风险。
75
+ * 双向联邦(宿主同时 expose 组件给更高层消费)显式设 true。
76
+ */
77
+ devSharedSelf?: boolean;
78
+ }
79
+
80
+ declare function federation(options: FulgurOptions): Plugin[];
81
+
82
+ export { type FulgurOptions, federation as default, federation };
@@ -0,0 +1,82 @@
1
+ import { Plugin } from 'vite';
2
+
3
+ interface SharedHint {
4
+ /** 放入共享作用域的本地模块;false 表示不提供本地副本 */
5
+ import?: string | false;
6
+ /** 用于从 package.json 推断 requiredVersion 的包名 */
7
+ packageName?: string;
8
+ /** 期望版本(完整 semver 语法 / false 接受任意) */
9
+ requiredVersion?: string | false;
10
+ /** 只允许单实例 */
11
+ singleton?: boolean;
12
+ /** 版本无效时抛运行时错误(默认:有本地副本且非 singleton 时为 true,对齐 webpack) */
13
+ strictVersion?: boolean;
14
+ /** 在共享作用域中的键(导入名与共享名不同时使用) */
15
+ shareKey?: string;
16
+ /** 共享作用域命名空间 */
17
+ shareScope?: string;
18
+ /** 同步提供(打进初始 chunk,总是被下载) */
19
+ eager?: boolean;
20
+ /** 提供版本显式指定 */
21
+ version?: string;
22
+ }
23
+ type SharedConfig = string[] | Record<string, string | SharedHint>;
24
+ interface ExposeHint {
25
+ import: string;
26
+ /** 稳定 chunk 文件名(不写则内部 id,随构建变化) */
27
+ name?: string;
28
+ }
29
+ interface RemoteEntryConfig {
30
+ external?: string;
31
+ shareScope?: string;
32
+ /** dev 专用地址(缺省回落 external) */
33
+ dev?: string;
34
+ /** prod 专用地址(缺省回落 external) */
35
+ prod?: string;
36
+ timeout?: number;
37
+ retries?: number;
38
+ /** 备用 remoteEntry 地址 */
39
+ fallback?: string[];
40
+ breaker?: {
41
+ threshold?: number;
42
+ resetMs?: number;
43
+ };
44
+ }
45
+ interface FulgurOptions {
46
+ name: string;
47
+ filename?: string;
48
+ exposes?: Record<string, string | ExposeHint>;
49
+ remotes?: Record<string, string | RemoteEntryConfig | (() => Promise<any>)>;
50
+ shared?: SharedConfig;
51
+ shareScope?: string;
52
+ remoteType?: string;
53
+ library?: {
54
+ type?: string;
55
+ name?: string;
56
+ };
57
+ runtime?: string | false;
58
+ runtimeChunk?: boolean | 'single';
59
+ manifest?: boolean | Record<string, unknown>;
60
+ runtimePlugins?: string[];
61
+ dts?: boolean | {
62
+ dir?: string;
63
+ };
64
+ /** 接受并恒为 true:TLA 天然异步边界,无需手工 bootstrap(比 webpack 更进一步) */
65
+ automaticAsyncBoundary?: boolean;
66
+ /** 接受并恒为 true:preloadRemote 能力始终可用 */
67
+ dataPrefetch?: boolean;
68
+ /** 接受 no-op:Rollup/Rolldown 原生 tree-shaking 已覆盖 */
69
+ usedExports?: boolean;
70
+ ignoreUnusedSharedExports?: boolean;
71
+ /**
72
+ * dev 下自身源码(含依赖,需配合 optimizeDeps.exclude)是否参与 shared 协商改写。
73
+ * 默认:纯 remote(无 remotes)为 true——被宿主消费的组件需协商到宿主实例;
74
+ * 有 remotes 的宿主为 false——自身 import 即自身 provide,避免巨型工程 TLA/循环依赖风险。
75
+ * 双向联邦(宿主同时 expose 组件给更高层消费)显式设 true。
76
+ */
77
+ devSharedSelf?: boolean;
78
+ }
79
+
80
+ declare function federation(options: FulgurOptions): Plugin[];
81
+
82
+ export { type FulgurOptions, federation as default, federation };