@zeus-js/bundler-plugin 0.1.0-beta.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.
@@ -0,0 +1,506 @@
1
+ /**
2
+ * bundler-plugin v0.1.0-beta.0
3
+ * (c) 2026 baicie
4
+ * Released under the MIT License.
5
+ **/
6
+ Object.defineProperties(exports, {
7
+ __esModule: { value: true },
8
+ [Symbol.toStringTag]: { value: "Module" }
9
+ });
10
+ //#region \0rolldown/runtime.js
11
+ var __create = Object.create;
12
+ var __defProp = Object.defineProperty;
13
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
14
+ var __getOwnPropNames = Object.getOwnPropertyNames;
15
+ var __getProtoOf = Object.getPrototypeOf;
16
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
17
+ var __copyProps = (to, from, except, desc) => {
18
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
19
+ key = keys[i];
20
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
21
+ get: ((k) => from[k]).bind(null, key),
22
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
23
+ });
24
+ }
25
+ return to;
26
+ };
27
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
28
+ value: mod,
29
+ enumerable: true
30
+ }) : target, mod));
31
+ //#endregion
32
+ let node_path = require("node:path");
33
+ node_path = __toESM(node_path, 1);
34
+ let _zeus_js_component_analyzer = require("@zeus-js/component-analyzer");
35
+ let fast_glob = require("fast-glob");
36
+ fast_glob = __toESM(fast_glob, 1);
37
+ let picomatch = require("picomatch");
38
+ picomatch = __toESM(picomatch, 1);
39
+ let node_fs_promises = require("node:fs/promises");
40
+ node_fs_promises = __toESM(node_fs_promises, 1);
41
+ let _babel_core = require("@babel/core");
42
+ let _zeus_js_compiler = require("@zeus-js/compiler");
43
+ _zeus_js_compiler = __toESM(_zeus_js_compiler, 1);
44
+ //#region packages/web-c/bundler-plugin/src/filter.ts
45
+ function cleanUrl(id) {
46
+ return id.replace(/[?#].*$/, "");
47
+ }
48
+ //#endregion
49
+ //#region packages/web-c/bundler-plugin/src/componentTransformFilter.ts
50
+ function normalizePath$1(value) {
51
+ return value.replace(/\\/g, "/");
52
+ }
53
+ function createComponentTransformFilter(options) {
54
+ const isIncluded = (0, picomatch.default)(options.include);
55
+ const isExcluded = (0, picomatch.default)(options.exclude);
56
+ return function shouldTransform(id) {
57
+ const clean = normalizePath$1(cleanUrl(id));
58
+ const relative = normalizePath$1(node_path.default.relative(options.root, clean));
59
+ if (relative.startsWith("..") || node_path.default.isAbsolute(relative)) return false;
60
+ if (isExcluded(relative)) return false;
61
+ return isIncluded(relative);
62
+ };
63
+ }
64
+ //#endregion
65
+ //#region packages/web-c/bundler-plugin/src/defaults.ts
66
+ const DEFAULT_COMPONENT_INCLUDE = ["src/**/*.{ts,tsx,js,jsx}", "components/**/*.{ts,tsx,js,jsx}"];
67
+ const DEFAULT_COMPONENT_EXCLUDE = [
68
+ "**/*.test.*",
69
+ "**/*.spec.*",
70
+ "**/__tests__/**",
71
+ "**/*.d.ts",
72
+ "src/shared/**",
73
+ "node_modules/**",
74
+ "dist/**"
75
+ ];
76
+ function resolveComponentInclude(include) {
77
+ return (include === null || include === void 0 ? void 0 : include.length) ? include : DEFAULT_COMPONENT_INCLUDE;
78
+ }
79
+ function resolveComponentExclude(exclude) {
80
+ return (exclude === null || exclude === void 0 ? void 0 : exclude.length) ? exclude : DEFAULT_COMPONENT_EXCLUDE;
81
+ }
82
+ //#endregion
83
+ //#region packages/web-c/bundler-plugin/src/diagnostics.ts
84
+ function formatDiagnostic(diagnostic) {
85
+ return `[zeus component-analyzer] ${diagnostic.file}: ${diagnostic.message}`;
86
+ }
87
+ function hasErrorDiagnostics(diagnostics) {
88
+ return diagnostics.some((item) => item.level === "error");
89
+ }
90
+ //#endregion
91
+ //#region packages/web-c/bundler-plugin/src/dts.ts
92
+ async function resolveDts(options) {
93
+ var _options$mode;
94
+ const mode = (_options$mode = options.mode) !== null && _options$mode !== void 0 ? _options$mode : "auto";
95
+ if (mode === true) return {
96
+ enabled: true,
97
+ mode,
98
+ reason: ["explicit-enabled"]
99
+ };
100
+ if (mode === false) return {
101
+ enabled: false,
102
+ mode,
103
+ reason: ["explicit-disabled"]
104
+ };
105
+ const reason = [];
106
+ if (await packageDeclaresTypes(options.root)) reason.push("package-types-field");
107
+ if (await hasTypeScriptDependency(options.root)) reason.push("typescript-dependency");
108
+ if (await fileExists(node_path.default.join(options.root, "tsconfig.json"))) reason.push("tsconfig");
109
+ if (await hasTypeScriptSource({
110
+ root: options.root,
111
+ include: options.include,
112
+ exclude: options.exclude
113
+ })) reason.push("typescript-source");
114
+ return {
115
+ enabled: reason.length > 0,
116
+ mode,
117
+ reason
118
+ };
119
+ }
120
+ async function hasTypeScriptDependency(root) {
121
+ const pkg = await readPackageJson(root);
122
+ if (!pkg) return false;
123
+ const deps = {
124
+ ...pkg.dependencies,
125
+ ...pkg.devDependencies,
126
+ ...pkg.peerDependencies,
127
+ ...pkg.optionalDependencies
128
+ };
129
+ return Boolean(deps.typescript);
130
+ }
131
+ async function packageDeclaresTypes(root) {
132
+ const pkg = await readPackageJson(root);
133
+ if (!pkg) return false;
134
+ if (pkg.types || pkg.typings) return true;
135
+ return hasTypesInExports(pkg.exports);
136
+ }
137
+ function hasTypesInExports(value) {
138
+ if (!value) return false;
139
+ if (typeof value !== "object") return false;
140
+ if ("types" in value) return true;
141
+ return Object.values(value).some(hasTypesInExports);
142
+ }
143
+ async function hasTypeScriptSource(options) {
144
+ return (await (0, fast_glob.default)(options.include, {
145
+ cwd: options.root,
146
+ onlyFiles: true,
147
+ absolute: false,
148
+ ignore: options.exclude
149
+ })).some((file) => file.endsWith(".ts") || file.endsWith(".tsx"));
150
+ }
151
+ async function readPackageJson(root) {
152
+ try {
153
+ return JSON.parse(await node_fs_promises.default.readFile(node_path.default.join(root, "package.json"), "utf-8"));
154
+ } catch {
155
+ return null;
156
+ }
157
+ }
158
+ async function fileExists(file) {
159
+ try {
160
+ await node_fs_promises.default.access(file);
161
+ return true;
162
+ } catch {
163
+ return false;
164
+ }
165
+ }
166
+ //#endregion
167
+ //#region packages/web-c/bundler-plugin/src/outputRegistry.ts
168
+ function createOutputRegistry() {
169
+ const map = /* @__PURE__ */ new Map();
170
+ return {
171
+ register(kind, options) {
172
+ map.set(kind, normalizeRegistration(kind, options));
173
+ },
174
+ has(kind) {
175
+ return map.has(kind);
176
+ },
177
+ get(kind) {
178
+ const current = map.get(kind);
179
+ if (!current) throw new Error(`[zeus] output kind "${kind}" is not registered.`);
180
+ return current;
181
+ },
182
+ getDir(kind) {
183
+ return this.get(kind).outDir;
184
+ },
185
+ getFileName(kind, tag) {
186
+ const current = this.get(kind);
187
+ if (current.fileName) return current.fileName(tag, kind);
188
+ return `${normalizeTagName(tag, current.stripPrefix)}.js`;
189
+ },
190
+ join(kind, fileName) {
191
+ return node_path.default.posix.join(this.getDir(kind), fileName);
192
+ }
193
+ };
194
+ }
195
+ function normalizeRegistration(kind, options) {
196
+ var _options$outDir, _options$stripPrefix;
197
+ return {
198
+ outDir: (_options$outDir = options.outDir) !== null && _options$outDir !== void 0 ? _options$outDir : defaultDir(kind),
199
+ stripPrefix: (_options$stripPrefix = options.stripPrefix) !== null && _options$stripPrefix !== void 0 ? _options$stripPrefix : false,
200
+ fileName: options.fileName
201
+ };
202
+ }
203
+ function defaultDir(kind) {
204
+ switch (kind) {
205
+ case "wc": return "wc";
206
+ case "react": return "react";
207
+ case "vue": return "vue";
208
+ case "icons-react": return "icons/react";
209
+ case "icons-vue": return "icons/vue";
210
+ case "icons-wc": return "icons/wc";
211
+ case "asset": return "";
212
+ }
213
+ }
214
+ function normalizeTagName(tag, stripPrefix) {
215
+ if (stripPrefix && tag.startsWith(stripPrefix)) return tag.slice(stripPrefix.length);
216
+ return tag;
217
+ }
218
+ //#endregion
219
+ //#region packages/web-c/bundler-plugin/src/transform.ts
220
+ async function transformZeus(options) {
221
+ var _compiler$moduleName;
222
+ const { id, code, compiler, sourcemap = true } = options;
223
+ const result = await (0, _babel_core.transformAsync)(code, {
224
+ filename: id,
225
+ sourceMaps: sourcemap,
226
+ plugins: [[_zeus_js_compiler.default, {
227
+ moduleName: (_compiler$moduleName = compiler === null || compiler === void 0 ? void 0 : compiler.moduleName) !== null && _compiler$moduleName !== void 0 ? _compiler$moduleName : "@zeus-js/runtime-dom",
228
+ generate: "dom",
229
+ hydratable: false,
230
+ delegateEvents: true,
231
+ ...compiler
232
+ }]],
233
+ parserOpts: {
234
+ sourceType: "module",
235
+ plugins: ["typescript", "jsx"]
236
+ },
237
+ generatorOpts: {
238
+ retainLines: false,
239
+ compact: false,
240
+ jsescOption: { minimal: true }
241
+ }
242
+ });
243
+ if (!(result === null || result === void 0 ? void 0 : result.code)) return null;
244
+ return {
245
+ code: result.code,
246
+ map: result.map
247
+ };
248
+ }
249
+ //#endregion
250
+ //#region packages/web-c/bundler-plugin/src/virtual.ts
251
+ const RESOLVED_VIRTUAL_PREFIX = "\0";
252
+ var VirtualModuleRegistry = class {
253
+ constructor() {
254
+ this.modules = /* @__PURE__ */ new Map();
255
+ this.virtualDirs = /* @__PURE__ */ new Map();
256
+ this.virtualFileNames = /* @__PURE__ */ new Map();
257
+ this.idsByFileName = /* @__PURE__ */ new Map();
258
+ }
259
+ set(id, code, fileName) {
260
+ const normalized = normalizeVirtualId(id);
261
+ this.modules.set(normalized, code);
262
+ if (fileName) {
263
+ const dir = node_path.default.posix.dirname(fileName);
264
+ this.virtualDirs.set(normalized, dir);
265
+ const normalizedFileName = normalizePath(fileName);
266
+ this.virtualFileNames.set(normalized, normalizedFileName);
267
+ this.idsByFileName.set(normalizedFileName, normalized);
268
+ }
269
+ }
270
+ has(id) {
271
+ return this.modules.has(normalizeVirtualId(id));
272
+ }
273
+ get(id) {
274
+ return this.modules.get(normalizeVirtualId(id));
275
+ }
276
+ clear() {
277
+ this.modules.clear();
278
+ this.virtualDirs.clear();
279
+ this.virtualFileNames.clear();
280
+ this.idsByFileName.clear();
281
+ }
282
+ resolve(id, importer) {
283
+ const normalized = normalizeVirtualId(id);
284
+ if (this.modules.has(normalized)) return RESOLVED_VIRTUAL_PREFIX + normalized;
285
+ if (importer && (id.startsWith(".") || id.startsWith(".."))) {
286
+ const importerNormalized = normalizeVirtualId(importer);
287
+ const importerDir = this.virtualDirs.get(importerNormalized);
288
+ if (importerDir) {
289
+ const resolved = normalizePath(node_path.default.posix.join(importerDir, id));
290
+ const resolvedVirtualId = this.idsByFileName.get(resolved);
291
+ if (resolvedVirtualId) return RESOLVED_VIRTUAL_PREFIX + resolvedVirtualId;
292
+ const importingPrefix = this.getIdPrefix(importerNormalized);
293
+ if (importingPrefix !== null) {
294
+ const baseName = node_path.default.posix.basename(resolved, ".js");
295
+ for (const [key] of this.modules.entries()) if (key === importingPrefix + baseName) return RESOLVED_VIRTUAL_PREFIX + key;
296
+ for (const stripPrefix of [
297
+ "z-",
298
+ "wc-",
299
+ "wc/",
300
+ ""
301
+ ]) {
302
+ const candidate = stripPrefix ? importingPrefix + stripPrefix + baseName : importingPrefix + baseName;
303
+ if (this.modules.has(candidate)) return RESOLVED_VIRTUAL_PREFIX + candidate;
304
+ }
305
+ const fullName = baseName;
306
+ for (const [key] of this.modules.entries()) if (key.endsWith(":" + fullName)) return RESOLVED_VIRTUAL_PREFIX + key;
307
+ }
308
+ }
309
+ }
310
+ return null;
311
+ }
312
+ getIdPrefix(virtualId) {
313
+ const lastColon = virtualId.lastIndexOf(":");
314
+ if (lastColon <= 0) return null;
315
+ return virtualId.slice(0, lastColon + 1);
316
+ }
317
+ load(id) {
318
+ var _this$modules$get;
319
+ if (!id.startsWith(RESOLVED_VIRTUAL_PREFIX)) return null;
320
+ const normalized = id.slice(1);
321
+ return (_this$modules$get = this.modules.get(normalized)) !== null && _this$modules$get !== void 0 ? _this$modules$get : null;
322
+ }
323
+ };
324
+ function normalizeVirtualId(id) {
325
+ return id.startsWith("\0") ? id.slice(1) : id;
326
+ }
327
+ function normalizePath(value) {
328
+ return value.replace(/\\/g, "/").replace(/^\.\//, "");
329
+ }
330
+ //#endregion
331
+ //#region packages/web-c/bundler-plugin/src/rollup.ts
332
+ function createZeusPlugin(options = {}) {
333
+ let shouldTransform = (_id) => false;
334
+ const virtualModules = new VirtualModuleRegistry();
335
+ let ctx;
336
+ return {
337
+ name: "zeus-bundler-plugin",
338
+ async buildStart() {
339
+ var _options$components, _options$components2, _options$plugins;
340
+ virtualModules.clear();
341
+ const root = resolveRoot(options.root);
342
+ const include = resolveComponentInclude((_options$components = options.components) === null || _options$components === void 0 ? void 0 : _options$components.include);
343
+ const exclude = resolveComponentExclude((_options$components2 = options.components) === null || _options$components2 === void 0 ? void 0 : _options$components2.exclude);
344
+ shouldTransform = createComponentTransformFilter({
345
+ root,
346
+ include,
347
+ exclude
348
+ });
349
+ const dts = await resolveDts({
350
+ root,
351
+ mode: options.dts,
352
+ include,
353
+ exclude
354
+ });
355
+ const manifestResult = await createManifest(root, include, exclude);
356
+ for (const file of await collectWatchFiles(root, include, exclude)) this.addWatchFile(file);
357
+ const diagnostics = manifestResult.diagnostics;
358
+ for (const diagnostic of diagnostics) {
359
+ const message = formatDiagnostic(diagnostic);
360
+ if (diagnostic.level === "error") this.error(message);
361
+ else if (options.diagnostics !== false) this.warn(message);
362
+ }
363
+ if (hasErrorDiagnostics(diagnostics)) this.error("[zeus] component analyzer failed.");
364
+ if (options.diagnostics === "verbose") this.warn(`[zeus] dts ${dts.enabled ? "enabled" : "disabled"}: ${dts.reason.join(", ") || "no signal"}`);
365
+ const outputs = createOutputRegistry();
366
+ ctx = {
367
+ root,
368
+ manifest: manifestResult.manifest,
369
+ diagnostics,
370
+ dts,
371
+ outputs,
372
+ emitFile: this.emitFile.bind(this),
373
+ warn: this.warn.bind(this),
374
+ error: this.error.bind(this),
375
+ addWatchFile: this.addWatchFile.bind(this),
376
+ meta: { watchMode: this.meta.watchMode }
377
+ };
378
+ const plugins = (_options$plugins = options.plugins) !== null && _options$plugins !== void 0 ? _options$plugins : [];
379
+ for (const plugin of plugins) {
380
+ var _plugin$setup;
381
+ await ((_plugin$setup = plugin.setup) === null || _plugin$setup === void 0 ? void 0 : _plugin$setup.call(plugin, ctx));
382
+ }
383
+ for (const plugin of plugins) {
384
+ var _plugin$buildStart;
385
+ await ((_plugin$buildStart = plugin.buildStart) === null || _plugin$buildStart === void 0 ? void 0 : _plugin$buildStart.call(plugin, ctx));
386
+ }
387
+ for (const plugin of plugins) {
388
+ var _plugin$virtualModule;
389
+ const modules = await ((_plugin$virtualModule = plugin.virtualModules) === null || _plugin$virtualModule === void 0 ? void 0 : _plugin$virtualModule.call(plugin, ctx));
390
+ if (!modules) continue;
391
+ for (const mod of modules) virtualModules.set(mod.id, mod.code, mod.fileName);
392
+ emitVirtualEntries(modules, this);
393
+ }
394
+ },
395
+ resolveId(id, importer) {
396
+ const resolved = virtualModules.resolve(id, importer);
397
+ if (resolved) return {
398
+ id: resolved,
399
+ moduleSideEffects: "no-treeshake"
400
+ };
401
+ return null;
402
+ },
403
+ load(id) {
404
+ return virtualModules.load(id);
405
+ },
406
+ async transform(code, id) {
407
+ if (!shouldTransform(id)) return null;
408
+ const result = await transformZeus({
409
+ id,
410
+ code,
411
+ compiler: options.compiler,
412
+ sourcemap: true
413
+ });
414
+ if (!result) return null;
415
+ return result;
416
+ },
417
+ async generateBundle(_, bundle) {
418
+ var _options$plugins2;
419
+ if (!ctx) return;
420
+ const plugins = (_options$plugins2 = options.plugins) !== null && _options$plugins2 !== void 0 ? _options$plugins2 : [];
421
+ for (const plugin of plugins) {
422
+ var _plugin$generateBundl;
423
+ const files = await ((_plugin$generateBundl = plugin.generateBundle) === null || _plugin$generateBundl === void 0 ? void 0 : _plugin$generateBundl.call(plugin, ctx, bundle));
424
+ if (!files) continue;
425
+ for (const file of files) emitOutputFile(this, file);
426
+ }
427
+ }
428
+ };
429
+ }
430
+ async function createManifest(root, include, exclude) {
431
+ if (!include.length) return {
432
+ manifest: {
433
+ version: 1,
434
+ components: []
435
+ },
436
+ diagnostics: []
437
+ };
438
+ return await (0, _zeus_js_component_analyzer.analyzeComponents)({
439
+ root,
440
+ include,
441
+ exclude
442
+ });
443
+ }
444
+ async function collectWatchFiles(root, include, exclude) {
445
+ if (!include.length) return [];
446
+ return await (0, fast_glob.default)(include, {
447
+ cwd: root,
448
+ absolute: true,
449
+ ignore: exclude
450
+ });
451
+ }
452
+ function resolveRoot(root) {
453
+ if (typeof root === "function") return node_path.default.resolve(root());
454
+ return node_path.default.resolve(root !== null && root !== void 0 ? root : process.cwd());
455
+ }
456
+ function emitOutputFile(pluginContext, file) {
457
+ if (file.type === "asset") {
458
+ pluginContext.emitFile({
459
+ type: "asset",
460
+ fileName: file.fileName,
461
+ source: file.source
462
+ });
463
+ return;
464
+ }
465
+ pluginContext.emitFile({
466
+ type: "chunk",
467
+ id: file.id,
468
+ fileName: file.fileName
469
+ });
470
+ }
471
+ function emitVirtualEntries(modules, pluginContext) {
472
+ for (const mod of modules) {
473
+ if (!mod.fileName) continue;
474
+ pluginContext.emitFile({
475
+ type: "chunk",
476
+ id: mod.id,
477
+ fileName: mod.fileName,
478
+ preserveSignature: "strict"
479
+ });
480
+ }
481
+ }
482
+ //#endregion
483
+ //#region packages/web-c/bundler-plugin/src/pluginOptions.ts
484
+ function resolvePluginDts(value, ctx) {
485
+ if (value === true) return true;
486
+ if (value === false) return false;
487
+ return ctx.dts.enabled;
488
+ }
489
+ //#endregion
490
+ //#region packages/web-c/bundler-plugin/src/vite.ts
491
+ function mergeExternal(userExternal, pluginExternal) {
492
+ if (!userExternal) return pluginExternal;
493
+ if (typeof userExternal === "function") return (source, importer, isResolved) => {
494
+ return pluginExternal.includes(source) || userExternal(source, importer, isResolved);
495
+ };
496
+ return [...Array.isArray(userExternal) ? userExternal : [userExternal], ...pluginExternal];
497
+ }
498
+ //#endregion
499
+ exports.createOutputRegistry = createOutputRegistry;
500
+ exports.createZeusPlugin = createZeusPlugin;
501
+ exports.default = createZeusPlugin;
502
+ exports.mergeExternal = mergeExternal;
503
+ exports.resolveComponentExclude = resolveComponentExclude;
504
+ exports.resolveComponentInclude = resolveComponentInclude;
505
+ exports.resolvePluginDts = resolvePluginDts;
506
+ exports.zeus = createZeusPlugin;
@@ -0,0 +1,130 @@
1
+ import { CompilerOptions } from '@zeus-js/compiler';
2
+ import { ComponentManifest, AnalyzerDiagnostic } from '@zeus-js/component-analyzer';
3
+ import { ExternalOption, PluginContext, OutputBundle, Plugin } from 'rollup';
4
+
5
+ type MaybePromise<T> = T | Promise<T>;
6
+ export type RollupExternalOption = ExternalOption;
7
+ type RootOption = string | (() => string);
8
+ export type ZeusOutputKind = 'wc' | 'react' | 'vue' | 'icons-react' | 'icons-vue' | 'icons-wc' | 'asset';
9
+ export type DtsMode = boolean | 'auto';
10
+ export interface ResolvedDts {
11
+ enabled: boolean;
12
+ mode: DtsMode;
13
+ reason: DtsAutoReason[];
14
+ }
15
+ export type DtsAutoReason = 'explicit-enabled' | 'explicit-disabled' | 'package-types-field' | 'typescript-dependency' | 'tsconfig' | 'typescript-source';
16
+ export interface ZeusBuildContext {
17
+ root: string;
18
+ manifest: ComponentManifest;
19
+ diagnostics: AnalyzerDiagnostic[];
20
+ dts: ResolvedDts;
21
+ outputs: ZeusOutputRegistry;
22
+ emitFile: PluginContext['emitFile'];
23
+ warn: PluginContext['warn'];
24
+ error: PluginContext['error'];
25
+ addWatchFile: PluginContext['addWatchFile'];
26
+ meta: {
27
+ watchMode: boolean;
28
+ };
29
+ }
30
+ export 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
+ export interface ZeusOutputRegistration {
39
+ outDir?: string;
40
+ stripPrefix?: string | false;
41
+ fileName?: (tag: string, kind: ZeusOutputKind) => string;
42
+ }
43
+ export interface RequiredZeusOutputRegistration {
44
+ outDir: string;
45
+ stripPrefix: string | false;
46
+ fileName?: (tag: string, kind: ZeusOutputKind) => string;
47
+ }
48
+ export interface ZeusVirtualModule {
49
+ id: string;
50
+ code: string;
51
+ fileName?: string;
52
+ }
53
+ export interface ZeusOutputAsset {
54
+ type: 'asset';
55
+ fileName: string;
56
+ source: string | Uint8Array;
57
+ }
58
+ export interface ZeusOutputChunk {
59
+ type: 'chunk';
60
+ id: string;
61
+ fileName?: string;
62
+ }
63
+ export type ZeusOutputFile = ZeusOutputAsset | ZeusOutputChunk;
64
+ export 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: OutputBundle): MaybePromise<ZeusOutputFile[] | void>;
75
+ /**
76
+ * Vite adapter can use this to auto externalize framework deps.
77
+ */
78
+ external?: string[];
79
+ }
80
+ export interface ZeusBundlerPluginOptions {
81
+ /**
82
+ * Project root.
83
+ *
84
+ * @default
85
+ * - Vite: resolved config.root
86
+ * - Rollup/Rolldown: process.cwd()
87
+ */
88
+ root?: RootOption;
89
+ /**
90
+ * Component source scan options.
91
+ * See DEFAULT_COMPONENT_INCLUDE and DEFAULT_COMPONENT_EXCLUDE in defaults.ts.
92
+ */
93
+ components?: {
94
+ include?: string[];
95
+ exclude?: string[];
96
+ };
97
+ /**
98
+ * Declaration generation mode.
99
+ *
100
+ * @default 'auto'
101
+ */
102
+ dts?: DtsMode;
103
+ /**
104
+ * Compiler options.
105
+ */
106
+ compiler?: Partial<CompilerOptions>;
107
+ /**
108
+ * Print analyzer diagnostics.
109
+ *
110
+ * @default true
111
+ */
112
+ diagnostics?: boolean | 'verbose';
113
+ /**
114
+ * Component-host plugins.
115
+ */
116
+ plugins?: ZeusComponentPlugin[];
117
+ }
118
+
119
+ export declare function createZeusPlugin(options?: ZeusBundlerPluginOptions): Plugin;
120
+
121
+ export declare function createOutputRegistry(): ZeusOutputRegistry;
122
+
123
+ export declare function resolveComponentInclude(include?: string[]): string[];
124
+ export declare function resolveComponentExclude(exclude?: string[]): string[];
125
+
126
+ export declare function resolvePluginDts(value: DtsMode | undefined, ctx: ZeusBuildContext): boolean;
127
+
128
+ export declare function mergeExternal(userExternal: RollupExternalOption | undefined, pluginExternal: string[]): RollupExternalOption;
129
+
130
+ export { createZeusPlugin as default, createZeusPlugin as zeus };