@zeus-js/bundler-plugin 0.1.0-beta.1 → 0.1.0-beta.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,156 @@
1
+ import { CompilerOptions } from '@zeus-js/compiler';
2
+ import { ComponentManifest, AnalyzerDiagnostic } from '@zeus-js/component-analyzer';
3
+ import { RolldownOptions, Plugin } from 'rolldown';
4
+
5
+ type MaybePromise<T> = T | Promise<T>;
6
+ type RootOption = string | (() => string);
7
+ type ZeusOutputKind = 'wc' | 'react' | 'vue' | 'icons-react' | 'icons-vue' | 'icons-wc' | 'asset';
8
+ type DtsMode = boolean | 'auto';
9
+ interface ResolvedDts {
10
+ enabled: boolean;
11
+ mode: DtsMode;
12
+ reason: DtsAutoReason[];
13
+ }
14
+ type DtsAutoReason = 'explicit-enabled' | 'explicit-disabled' | 'package-types-field' | 'typescript-dependency' | 'tsconfig' | 'typescript-source';
15
+ interface ZeusBuildContext {
16
+ root: string;
17
+ manifest: ComponentManifest;
18
+ diagnostics: AnalyzerDiagnostic[];
19
+ dts: ResolvedDts;
20
+ outputs: ZeusOutputRegistry;
21
+ emitFile: (file: unknown) => string | void;
22
+ warn: (message: string | Error) => void;
23
+ error: (message: string | Error) => never;
24
+ addWatchFile: (id: string) => void;
25
+ meta: {
26
+ watchMode: boolean;
27
+ };
28
+ }
29
+ type ZeusOutputBundle = Record<string, unknown>;
30
+ interface ZeusOutputRegistry {
31
+ register(kind: ZeusOutputKind, options: ZeusOutputRegistration): void;
32
+ has(kind: ZeusOutputKind): boolean;
33
+ get(kind: ZeusOutputKind): RequiredZeusOutputRegistration;
34
+ getDir(kind: ZeusOutputKind): string;
35
+ getFileName(kind: ZeusOutputKind, tag: string): string;
36
+ join(kind: ZeusOutputKind, fileName: string): string;
37
+ }
38
+ interface ZeusOutputRegistration {
39
+ outDir?: string;
40
+ stripPrefix?: string | false;
41
+ fileName?: (tag: string, kind: ZeusOutputKind) => string;
42
+ }
43
+ interface RequiredZeusOutputRegistration {
44
+ outDir: string;
45
+ stripPrefix: string | false;
46
+ fileName?: (tag: string, kind: ZeusOutputKind) => string;
47
+ }
48
+ interface ZeusVirtualModule {
49
+ id: string;
50
+ code: string;
51
+ fileName?: string;
52
+ }
53
+ interface ZeusOutputAsset {
54
+ type: 'asset';
55
+ fileName: string;
56
+ source: string | Uint8Array;
57
+ }
58
+ interface ZeusOutputChunk {
59
+ type: 'chunk';
60
+ id: string;
61
+ fileName?: string;
62
+ }
63
+ type ZeusOutputFile = ZeusOutputAsset | ZeusOutputChunk;
64
+ interface ZeusComponentPlugin {
65
+ name: string;
66
+ /**
67
+ * Register output dirs / externals / plugin metadata.
68
+ *
69
+ * This hook runs before virtualModules().
70
+ */
71
+ setup?(ctx: ZeusBuildContext): void | Promise<void>;
72
+ buildStart?(ctx: ZeusBuildContext): MaybePromise<void>;
73
+ virtualModules?(ctx: ZeusBuildContext): MaybePromise<ZeusVirtualModule[] | void>;
74
+ generateBundle?(ctx: ZeusBuildContext, bundle: ZeusOutputBundle): MaybePromise<ZeusOutputFile[] | void>;
75
+ /**
76
+ * Framework dependencies that bundler config helpers should externalize.
77
+ *
78
+ * Used by the Vite adapter, defineZeusRollupConfig(), and
79
+ * defineZeusRolldownConfig().
80
+ */
81
+ external?: string[];
82
+ }
83
+ interface ZeusBundlerPluginOptions {
84
+ /**
85
+ * Project root.
86
+ *
87
+ * @default
88
+ * - Vite: resolved config.root
89
+ * - Rollup/Rolldown: process.cwd()
90
+ */
91
+ root?: RootOption;
92
+ /**
93
+ * Component source scan options.
94
+ * See DEFAULT_COMPONENT_INCLUDE and DEFAULT_COMPONENT_EXCLUDE in defaults.ts.
95
+ */
96
+ components?: {
97
+ include?: string[];
98
+ exclude?: string[];
99
+ };
100
+ /**
101
+ * Zeus JSX compile transform filter.
102
+ *
103
+ * This is intentionally separate from `components`: files can be excluded
104
+ * from component analysis / manifest generation while still compiling JSX.
105
+ */
106
+ transform?: {
107
+ include?: string[];
108
+ exclude?: string[];
109
+ };
110
+ /**
111
+ * Declaration generation mode.
112
+ *
113
+ * @default 'auto'
114
+ */
115
+ dts?: DtsMode;
116
+ /**
117
+ * Compiler options.
118
+ */
119
+ compiler?: Partial<CompilerOptions>;
120
+ /**
121
+ * Print analyzer diagnostics.
122
+ *
123
+ * @default true
124
+ */
125
+ diagnostics?: boolean | 'verbose';
126
+ /**
127
+ * Component-host plugins.
128
+ */
129
+ plugins?: ZeusComponentPlugin[];
130
+ /**
131
+ * Enable TypeScript transpilation via Babel preset-typescript.
132
+ *
133
+ * @default
134
+ * - rollup: true
135
+ * - rolldown: false
136
+ * - vite: false
137
+ */
138
+ transpile?: boolean;
139
+ /**
140
+ * Rollup adapter only. Additional extensions to try when resolving imports.
141
+ * Set to `false` to disable extension resolution.
142
+ *
143
+ * @default ['.ts', '.tsx', '.mts', '.cts', '.js', '.jsx', '.mjs', '.cjs']
144
+ */
145
+ resolveExtensions?: string[] | false;
146
+ }
147
+
148
+ export declare function zeus(options?: ZeusBundlerPluginOptions): Plugin;
149
+
150
+ export interface ZeusRolldownConfigOptions extends Omit<RolldownOptions, 'plugins'> {
151
+ zeus?: ZeusBundlerPluginOptions;
152
+ plugins?: RolldownOptions['plugins'];
153
+ }
154
+ export declare function defineZeusRolldownConfig(config?: ZeusRolldownConfigOptions): RolldownOptions;
155
+
156
+ export { zeus as default, };