@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,611 @@
1
+ /**
2
+ * bundler-plugin v0.1.0-beta.0
3
+ * (c) 2026 baicie
4
+ * Released under the MIT License.
5
+ **/
6
+ import path from "node:path";
7
+ import { analyzeComponents } from "@zeus-js/component-analyzer";
8
+ import fg from "fast-glob";
9
+ import picomatch from "picomatch";
10
+ import fs from "node:fs/promises";
11
+ import { transformAsync } from "@babel/core";
12
+ import zeusCompiler from "@zeus-js/compiler";
13
+ //#region packages/web-c/bundler-plugin/src/filter.ts
14
+ function cleanUrl(id) {
15
+ return id.replace(/[?#].*$/, "");
16
+ }
17
+ //#endregion
18
+ //#region packages/web-c/bundler-plugin/src/componentTransformFilter.ts
19
+ function normalizePath$1(value) {
20
+ return value.replace(/\\/g, "/");
21
+ }
22
+ function createComponentTransformFilter(options) {
23
+ const isIncluded = picomatch(options.include);
24
+ const isExcluded = picomatch(options.exclude);
25
+ return function shouldTransform(id) {
26
+ const clean = normalizePath$1(cleanUrl(id));
27
+ const relative = normalizePath$1(path.relative(options.root, clean));
28
+ if (relative.startsWith("..") || path.isAbsolute(relative)) return false;
29
+ if (isExcluded(relative)) return false;
30
+ return isIncluded(relative);
31
+ };
32
+ }
33
+ //#endregion
34
+ //#region packages/web-c/bundler-plugin/src/defaults.ts
35
+ const DEFAULT_COMPONENT_INCLUDE = ["src/**/*.{ts,tsx,js,jsx}", "components/**/*.{ts,tsx,js,jsx}"];
36
+ const DEFAULT_COMPONENT_EXCLUDE = [
37
+ "**/*.test.*",
38
+ "**/*.spec.*",
39
+ "**/__tests__/**",
40
+ "**/*.d.ts",
41
+ "src/shared/**",
42
+ "node_modules/**",
43
+ "dist/**"
44
+ ];
45
+ function resolveComponentInclude(include) {
46
+ return (include === null || include === void 0 ? void 0 : include.length) ? include : DEFAULT_COMPONENT_INCLUDE;
47
+ }
48
+ function resolveComponentExclude(exclude) {
49
+ return (exclude === null || exclude === void 0 ? void 0 : exclude.length) ? exclude : DEFAULT_COMPONENT_EXCLUDE;
50
+ }
51
+ //#endregion
52
+ //#region packages/web-c/bundler-plugin/src/diagnostics.ts
53
+ function formatDiagnostic(diagnostic) {
54
+ return `[zeus component-analyzer] ${diagnostic.file}: ${diagnostic.message}`;
55
+ }
56
+ function hasErrorDiagnostics(diagnostics) {
57
+ return diagnostics.some((item) => item.level === "error");
58
+ }
59
+ //#endregion
60
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/asyncToGenerator.js
61
+ function asyncGeneratorStep(n, t, e, r, o, a, c) {
62
+ try {
63
+ var i = n[a](c), u = i.value;
64
+ } catch (n) {
65
+ e(n);
66
+ return;
67
+ }
68
+ i.done ? t(u) : Promise.resolve(u).then(r, o);
69
+ }
70
+ function _asyncToGenerator(n) {
71
+ return function() {
72
+ var t = this, e = arguments;
73
+ return new Promise(function(r, o) {
74
+ var a = n.apply(t, e);
75
+ function _next(n) {
76
+ asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
77
+ }
78
+ function _throw(n) {
79
+ asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
80
+ }
81
+ _next(void 0);
82
+ });
83
+ };
84
+ }
85
+ //#endregion
86
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/typeof.js
87
+ function _typeof(o) {
88
+ "@babel/helpers - typeof";
89
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
90
+ return typeof o;
91
+ } : function(o) {
92
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
93
+ }, _typeof(o);
94
+ }
95
+ //#endregion
96
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPrimitive.js
97
+ function toPrimitive(t, r) {
98
+ if ("object" != _typeof(t) || !t) return t;
99
+ var e = t[Symbol.toPrimitive];
100
+ if (void 0 !== e) {
101
+ var i = e.call(t, r || "default");
102
+ if ("object" != _typeof(i)) return i;
103
+ throw new TypeError("@@toPrimitive must return a primitive value.");
104
+ }
105
+ return ("string" === r ? String : Number)(t);
106
+ }
107
+ //#endregion
108
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPropertyKey.js
109
+ function toPropertyKey(t) {
110
+ var i = toPrimitive(t, "string");
111
+ return "symbol" == _typeof(i) ? i : i + "";
112
+ }
113
+ //#endregion
114
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/defineProperty.js
115
+ function _defineProperty(e, r, t) {
116
+ return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
117
+ value: t,
118
+ enumerable: !0,
119
+ configurable: !0,
120
+ writable: !0
121
+ }) : e[r] = t, e;
122
+ }
123
+ //#endregion
124
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/objectSpread2.js
125
+ function ownKeys(e, r) {
126
+ var t = Object.keys(e);
127
+ if (Object.getOwnPropertySymbols) {
128
+ var o = Object.getOwnPropertySymbols(e);
129
+ r && (o = o.filter(function(r) {
130
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
131
+ })), t.push.apply(t, o);
132
+ }
133
+ return t;
134
+ }
135
+ function _objectSpread2(e) {
136
+ for (var r = 1; r < arguments.length; r++) {
137
+ var t = null != arguments[r] ? arguments[r] : {};
138
+ r % 2 ? ownKeys(Object(t), !0).forEach(function(r) {
139
+ _defineProperty(e, r, t[r]);
140
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r) {
141
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
142
+ });
143
+ }
144
+ return e;
145
+ }
146
+ //#endregion
147
+ //#region packages/web-c/bundler-plugin/src/dts.ts
148
+ function resolveDts(_x) {
149
+ return _resolveDts.apply(this, arguments);
150
+ }
151
+ function _resolveDts() {
152
+ _resolveDts = _asyncToGenerator(function* (options) {
153
+ var _options$mode;
154
+ const mode = (_options$mode = options.mode) !== null && _options$mode !== void 0 ? _options$mode : "auto";
155
+ if (mode === true) return {
156
+ enabled: true,
157
+ mode,
158
+ reason: ["explicit-enabled"]
159
+ };
160
+ if (mode === false) return {
161
+ enabled: false,
162
+ mode,
163
+ reason: ["explicit-disabled"]
164
+ };
165
+ const reason = [];
166
+ if (yield packageDeclaresTypes(options.root)) reason.push("package-types-field");
167
+ if (yield hasTypeScriptDependency(options.root)) reason.push("typescript-dependency");
168
+ if (yield fileExists(path.join(options.root, "tsconfig.json"))) reason.push("tsconfig");
169
+ if (yield hasTypeScriptSource({
170
+ root: options.root,
171
+ include: options.include,
172
+ exclude: options.exclude
173
+ })) reason.push("typescript-source");
174
+ return {
175
+ enabled: reason.length > 0,
176
+ mode,
177
+ reason
178
+ };
179
+ });
180
+ return _resolveDts.apply(this, arguments);
181
+ }
182
+ function hasTypeScriptDependency(_x2) {
183
+ return _hasTypeScriptDependency.apply(this, arguments);
184
+ }
185
+ function _hasTypeScriptDependency() {
186
+ _hasTypeScriptDependency = _asyncToGenerator(function* (root) {
187
+ const pkg = yield readPackageJson(root);
188
+ if (!pkg) return false;
189
+ const deps = _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({}, pkg.dependencies), pkg.devDependencies), pkg.peerDependencies), pkg.optionalDependencies);
190
+ return Boolean(deps.typescript);
191
+ });
192
+ return _hasTypeScriptDependency.apply(this, arguments);
193
+ }
194
+ function packageDeclaresTypes(_x3) {
195
+ return _packageDeclaresTypes.apply(this, arguments);
196
+ }
197
+ function _packageDeclaresTypes() {
198
+ _packageDeclaresTypes = _asyncToGenerator(function* (root) {
199
+ const pkg = yield readPackageJson(root);
200
+ if (!pkg) return false;
201
+ if (pkg.types || pkg.typings) return true;
202
+ return hasTypesInExports(pkg.exports);
203
+ });
204
+ return _packageDeclaresTypes.apply(this, arguments);
205
+ }
206
+ function hasTypesInExports(value) {
207
+ if (!value) return false;
208
+ if (typeof value !== "object") return false;
209
+ if ("types" in value) return true;
210
+ return Object.values(value).some(hasTypesInExports);
211
+ }
212
+ function hasTypeScriptSource(_x4) {
213
+ return _hasTypeScriptSource.apply(this, arguments);
214
+ }
215
+ function _hasTypeScriptSource() {
216
+ _hasTypeScriptSource = _asyncToGenerator(function* (options) {
217
+ return (yield fg(options.include, {
218
+ cwd: options.root,
219
+ onlyFiles: true,
220
+ absolute: false,
221
+ ignore: options.exclude
222
+ })).some((file) => file.endsWith(".ts") || file.endsWith(".tsx"));
223
+ });
224
+ return _hasTypeScriptSource.apply(this, arguments);
225
+ }
226
+ function readPackageJson(_x5) {
227
+ return _readPackageJson.apply(this, arguments);
228
+ }
229
+ function _readPackageJson() {
230
+ _readPackageJson = _asyncToGenerator(function* (root) {
231
+ try {
232
+ return JSON.parse(yield fs.readFile(path.join(root, "package.json"), "utf-8"));
233
+ } catch (_unused) {
234
+ return null;
235
+ }
236
+ });
237
+ return _readPackageJson.apply(this, arguments);
238
+ }
239
+ function fileExists(_x6) {
240
+ return _fileExists.apply(this, arguments);
241
+ }
242
+ function _fileExists() {
243
+ _fileExists = _asyncToGenerator(function* (file) {
244
+ try {
245
+ yield fs.access(file);
246
+ return true;
247
+ } catch (_unused2) {
248
+ return false;
249
+ }
250
+ });
251
+ return _fileExists.apply(this, arguments);
252
+ }
253
+ //#endregion
254
+ //#region packages/web-c/bundler-plugin/src/outputRegistry.ts
255
+ function createOutputRegistry() {
256
+ const map = /* @__PURE__ */ new Map();
257
+ return {
258
+ register(kind, options) {
259
+ map.set(kind, normalizeRegistration(kind, options));
260
+ },
261
+ has(kind) {
262
+ return map.has(kind);
263
+ },
264
+ get(kind) {
265
+ const current = map.get(kind);
266
+ if (!current) throw new Error(`[zeus] output kind "${kind}" is not registered.`);
267
+ return current;
268
+ },
269
+ getDir(kind) {
270
+ return this.get(kind).outDir;
271
+ },
272
+ getFileName(kind, tag) {
273
+ const current = this.get(kind);
274
+ if (current.fileName) return current.fileName(tag, kind);
275
+ return `${normalizeTagName(tag, current.stripPrefix)}.js`;
276
+ },
277
+ join(kind, fileName) {
278
+ return path.posix.join(this.getDir(kind), fileName);
279
+ }
280
+ };
281
+ }
282
+ function normalizeRegistration(kind, options) {
283
+ var _options$outDir, _options$stripPrefix;
284
+ return {
285
+ outDir: (_options$outDir = options.outDir) !== null && _options$outDir !== void 0 ? _options$outDir : defaultDir(kind),
286
+ stripPrefix: (_options$stripPrefix = options.stripPrefix) !== null && _options$stripPrefix !== void 0 ? _options$stripPrefix : false,
287
+ fileName: options.fileName
288
+ };
289
+ }
290
+ function defaultDir(kind) {
291
+ switch (kind) {
292
+ case "wc": return "wc";
293
+ case "react": return "react";
294
+ case "vue": return "vue";
295
+ case "icons-react": return "icons/react";
296
+ case "icons-vue": return "icons/vue";
297
+ case "icons-wc": return "icons/wc";
298
+ case "asset": return "";
299
+ }
300
+ }
301
+ function normalizeTagName(tag, stripPrefix) {
302
+ if (stripPrefix && tag.startsWith(stripPrefix)) return tag.slice(stripPrefix.length);
303
+ return tag;
304
+ }
305
+ //#endregion
306
+ //#region packages/web-c/bundler-plugin/src/transform.ts
307
+ function transformZeus(_x) {
308
+ return _transformZeus.apply(this, arguments);
309
+ }
310
+ function _transformZeus() {
311
+ _transformZeus = _asyncToGenerator(function* (options) {
312
+ var _compiler$moduleName;
313
+ const { id, code, compiler, sourcemap = true } = options;
314
+ const result = yield transformAsync(code, {
315
+ filename: id,
316
+ sourceMaps: sourcemap,
317
+ plugins: [[zeusCompiler, _objectSpread2({
318
+ moduleName: (_compiler$moduleName = compiler === null || compiler === void 0 ? void 0 : compiler.moduleName) !== null && _compiler$moduleName !== void 0 ? _compiler$moduleName : "@zeus-js/runtime-dom",
319
+ generate: "dom",
320
+ hydratable: false,
321
+ delegateEvents: true
322
+ }, compiler)]],
323
+ parserOpts: {
324
+ sourceType: "module",
325
+ plugins: ["typescript", "jsx"]
326
+ },
327
+ generatorOpts: {
328
+ retainLines: false,
329
+ compact: false,
330
+ jsescOption: { minimal: true }
331
+ }
332
+ });
333
+ if (!(result === null || result === void 0 ? void 0 : result.code)) return null;
334
+ return {
335
+ code: result.code,
336
+ map: result.map
337
+ };
338
+ });
339
+ return _transformZeus.apply(this, arguments);
340
+ }
341
+ //#endregion
342
+ //#region packages/web-c/bundler-plugin/src/virtual.ts
343
+ const RESOLVED_VIRTUAL_PREFIX = "\0";
344
+ var VirtualModuleRegistry = class {
345
+ constructor() {
346
+ this.modules = /* @__PURE__ */ new Map();
347
+ this.virtualDirs = /* @__PURE__ */ new Map();
348
+ this.virtualFileNames = /* @__PURE__ */ new Map();
349
+ this.idsByFileName = /* @__PURE__ */ new Map();
350
+ }
351
+ set(id, code, fileName) {
352
+ const normalized = normalizeVirtualId(id);
353
+ this.modules.set(normalized, code);
354
+ if (fileName) {
355
+ const dir = path.posix.dirname(fileName);
356
+ this.virtualDirs.set(normalized, dir);
357
+ const normalizedFileName = normalizePath(fileName);
358
+ this.virtualFileNames.set(normalized, normalizedFileName);
359
+ this.idsByFileName.set(normalizedFileName, normalized);
360
+ }
361
+ }
362
+ has(id) {
363
+ return this.modules.has(normalizeVirtualId(id));
364
+ }
365
+ get(id) {
366
+ return this.modules.get(normalizeVirtualId(id));
367
+ }
368
+ clear() {
369
+ this.modules.clear();
370
+ this.virtualDirs.clear();
371
+ this.virtualFileNames.clear();
372
+ this.idsByFileName.clear();
373
+ }
374
+ resolve(id, importer) {
375
+ const normalized = normalizeVirtualId(id);
376
+ if (this.modules.has(normalized)) return RESOLVED_VIRTUAL_PREFIX + normalized;
377
+ if (importer && (id.startsWith(".") || id.startsWith(".."))) {
378
+ const importerNormalized = normalizeVirtualId(importer);
379
+ const importerDir = this.virtualDirs.get(importerNormalized);
380
+ if (importerDir) {
381
+ const resolved = normalizePath(path.posix.join(importerDir, id));
382
+ const resolvedVirtualId = this.idsByFileName.get(resolved);
383
+ if (resolvedVirtualId) return RESOLVED_VIRTUAL_PREFIX + resolvedVirtualId;
384
+ const importingPrefix = this.getIdPrefix(importerNormalized);
385
+ if (importingPrefix !== null) {
386
+ const baseName = path.posix.basename(resolved, ".js");
387
+ for (const [key] of this.modules.entries()) if (key === importingPrefix + baseName) return RESOLVED_VIRTUAL_PREFIX + key;
388
+ for (const stripPrefix of [
389
+ "z-",
390
+ "wc-",
391
+ "wc/",
392
+ ""
393
+ ]) {
394
+ const candidate = stripPrefix ? importingPrefix + stripPrefix + baseName : importingPrefix + baseName;
395
+ if (this.modules.has(candidate)) return RESOLVED_VIRTUAL_PREFIX + candidate;
396
+ }
397
+ const fullName = baseName;
398
+ for (const [key] of this.modules.entries()) if (key.endsWith(":" + fullName)) return RESOLVED_VIRTUAL_PREFIX + key;
399
+ }
400
+ }
401
+ }
402
+ return null;
403
+ }
404
+ getIdPrefix(virtualId) {
405
+ const lastColon = virtualId.lastIndexOf(":");
406
+ if (lastColon <= 0) return null;
407
+ return virtualId.slice(0, lastColon + 1);
408
+ }
409
+ load(id) {
410
+ var _this$modules$get;
411
+ if (!id.startsWith(RESOLVED_VIRTUAL_PREFIX)) return null;
412
+ const normalized = id.slice(1);
413
+ return (_this$modules$get = this.modules.get(normalized)) !== null && _this$modules$get !== void 0 ? _this$modules$get : null;
414
+ }
415
+ };
416
+ function normalizeVirtualId(id) {
417
+ return id.startsWith("\0") ? id.slice(1) : id;
418
+ }
419
+ function normalizePath(value) {
420
+ return value.replace(/\\/g, "/").replace(/^\.\//, "");
421
+ }
422
+ //#endregion
423
+ //#region packages/web-c/bundler-plugin/src/rollup.ts
424
+ function createZeusPlugin(options = {}) {
425
+ let shouldTransform = (_id) => false;
426
+ const virtualModules = new VirtualModuleRegistry();
427
+ let ctx;
428
+ return {
429
+ name: "zeus-bundler-plugin",
430
+ buildStart() {
431
+ var _this = this;
432
+ return _asyncToGenerator(function* () {
433
+ var _options$components, _options$components2, _options$plugins;
434
+ virtualModules.clear();
435
+ const root = resolveRoot(options.root);
436
+ const include = resolveComponentInclude((_options$components = options.components) === null || _options$components === void 0 ? void 0 : _options$components.include);
437
+ const exclude = resolveComponentExclude((_options$components2 = options.components) === null || _options$components2 === void 0 ? void 0 : _options$components2.exclude);
438
+ shouldTransform = createComponentTransformFilter({
439
+ root,
440
+ include,
441
+ exclude
442
+ });
443
+ const dts = yield resolveDts({
444
+ root,
445
+ mode: options.dts,
446
+ include,
447
+ exclude
448
+ });
449
+ const manifestResult = yield createManifest(root, include, exclude);
450
+ for (const file of yield collectWatchFiles(root, include, exclude)) _this.addWatchFile(file);
451
+ const diagnostics = manifestResult.diagnostics;
452
+ for (const diagnostic of diagnostics) {
453
+ const message = formatDiagnostic(diagnostic);
454
+ if (diagnostic.level === "error") _this.error(message);
455
+ else if (options.diagnostics !== false) _this.warn(message);
456
+ }
457
+ if (hasErrorDiagnostics(diagnostics)) _this.error("[zeus] component analyzer failed.");
458
+ if (options.diagnostics === "verbose") _this.warn(`[zeus] dts ${dts.enabled ? "enabled" : "disabled"}: ${dts.reason.join(", ") || "no signal"}`);
459
+ const outputs = createOutputRegistry();
460
+ ctx = {
461
+ root,
462
+ manifest: manifestResult.manifest,
463
+ diagnostics,
464
+ dts,
465
+ outputs,
466
+ emitFile: _this.emitFile.bind(_this),
467
+ warn: _this.warn.bind(_this),
468
+ error: _this.error.bind(_this),
469
+ addWatchFile: _this.addWatchFile.bind(_this),
470
+ meta: { watchMode: _this.meta.watchMode }
471
+ };
472
+ const plugins = (_options$plugins = options.plugins) !== null && _options$plugins !== void 0 ? _options$plugins : [];
473
+ for (const plugin of plugins) {
474
+ var _plugin$setup;
475
+ yield (_plugin$setup = plugin.setup) === null || _plugin$setup === void 0 ? void 0 : _plugin$setup.call(plugin, ctx);
476
+ }
477
+ for (const plugin of plugins) {
478
+ var _plugin$buildStart;
479
+ yield (_plugin$buildStart = plugin.buildStart) === null || _plugin$buildStart === void 0 ? void 0 : _plugin$buildStart.call(plugin, ctx);
480
+ }
481
+ for (const plugin of plugins) {
482
+ var _plugin$virtualModule;
483
+ const modules = yield (_plugin$virtualModule = plugin.virtualModules) === null || _plugin$virtualModule === void 0 ? void 0 : _plugin$virtualModule.call(plugin, ctx);
484
+ if (!modules) continue;
485
+ for (const mod of modules) virtualModules.set(mod.id, mod.code, mod.fileName);
486
+ emitVirtualEntries(modules, _this);
487
+ }
488
+ })();
489
+ },
490
+ resolveId(id, importer) {
491
+ const resolved = virtualModules.resolve(id, importer);
492
+ if (resolved) return {
493
+ id: resolved,
494
+ moduleSideEffects: "no-treeshake"
495
+ };
496
+ return null;
497
+ },
498
+ load(id) {
499
+ return virtualModules.load(id);
500
+ },
501
+ transform(code, id) {
502
+ return _asyncToGenerator(function* () {
503
+ if (!shouldTransform(id)) return null;
504
+ const result = yield transformZeus({
505
+ id,
506
+ code,
507
+ compiler: options.compiler,
508
+ sourcemap: true
509
+ });
510
+ if (!result) return null;
511
+ return result;
512
+ })();
513
+ },
514
+ generateBundle(_, bundle) {
515
+ var _this2 = this;
516
+ return _asyncToGenerator(function* () {
517
+ var _options$plugins2;
518
+ if (!ctx) return;
519
+ const plugins = (_options$plugins2 = options.plugins) !== null && _options$plugins2 !== void 0 ? _options$plugins2 : [];
520
+ for (const plugin of plugins) {
521
+ var _plugin$generateBundl;
522
+ const files = yield (_plugin$generateBundl = plugin.generateBundle) === null || _plugin$generateBundl === void 0 ? void 0 : _plugin$generateBundl.call(plugin, ctx, bundle);
523
+ if (!files) continue;
524
+ for (const file of files) emitOutputFile(_this2, file);
525
+ }
526
+ })();
527
+ }
528
+ };
529
+ }
530
+ function createManifest(_x, _x2, _x3) {
531
+ return _createManifest.apply(this, arguments);
532
+ }
533
+ function _createManifest() {
534
+ _createManifest = _asyncToGenerator(function* (root, include, exclude) {
535
+ if (!include.length) return {
536
+ manifest: {
537
+ version: 1,
538
+ components: []
539
+ },
540
+ diagnostics: []
541
+ };
542
+ return yield analyzeComponents({
543
+ root,
544
+ include,
545
+ exclude
546
+ });
547
+ });
548
+ return _createManifest.apply(this, arguments);
549
+ }
550
+ function collectWatchFiles(_x4, _x5, _x6) {
551
+ return _collectWatchFiles.apply(this, arguments);
552
+ }
553
+ function _collectWatchFiles() {
554
+ _collectWatchFiles = _asyncToGenerator(function* (root, include, exclude) {
555
+ if (!include.length) return [];
556
+ return yield fg(include, {
557
+ cwd: root,
558
+ absolute: true,
559
+ ignore: exclude
560
+ });
561
+ });
562
+ return _collectWatchFiles.apply(this, arguments);
563
+ }
564
+ function resolveRoot(root) {
565
+ if (typeof root === "function") return path.resolve(root());
566
+ return path.resolve(root !== null && root !== void 0 ? root : process.cwd());
567
+ }
568
+ function emitOutputFile(pluginContext, file) {
569
+ if (file.type === "asset") {
570
+ pluginContext.emitFile({
571
+ type: "asset",
572
+ fileName: file.fileName,
573
+ source: file.source
574
+ });
575
+ return;
576
+ }
577
+ pluginContext.emitFile({
578
+ type: "chunk",
579
+ id: file.id,
580
+ fileName: file.fileName
581
+ });
582
+ }
583
+ function emitVirtualEntries(modules, pluginContext) {
584
+ for (const mod of modules) {
585
+ if (!mod.fileName) continue;
586
+ pluginContext.emitFile({
587
+ type: "chunk",
588
+ id: mod.id,
589
+ fileName: mod.fileName,
590
+ preserveSignature: "strict"
591
+ });
592
+ }
593
+ }
594
+ //#endregion
595
+ //#region packages/web-c/bundler-plugin/src/pluginOptions.ts
596
+ function resolvePluginDts(value, ctx) {
597
+ if (value === true) return true;
598
+ if (value === false) return false;
599
+ return ctx.dts.enabled;
600
+ }
601
+ //#endregion
602
+ //#region packages/web-c/bundler-plugin/src/vite.ts
603
+ function mergeExternal(userExternal, pluginExternal) {
604
+ if (!userExternal) return pluginExternal;
605
+ if (typeof userExternal === "function") return (source, importer, isResolved) => {
606
+ return pluginExternal.includes(source) || userExternal(source, importer, isResolved);
607
+ };
608
+ return [...Array.isArray(userExternal) ? userExternal : [userExternal], ...pluginExternal];
609
+ }
610
+ //#endregion
611
+ export { createOutputRegistry, createZeusPlugin, createZeusPlugin as default, createZeusPlugin as zeus, mergeExternal, resolveComponentExclude, resolveComponentInclude, resolvePluginDts };
@@ -0,0 +1,27 @@
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 packages/web-c/bundler-plugin/src/outputPlugins/manifest.ts
11
+ function manifestOutput(options = {}) {
12
+ var _options$fileName, _options$pretty;
13
+ const fileName = (_options$fileName = options.fileName) !== null && _options$fileName !== void 0 ? _options$fileName : "zeus.components.json";
14
+ const pretty = (_options$pretty = options.pretty) !== null && _options$pretty !== void 0 ? _options$pretty : true;
15
+ return {
16
+ name: "zeus-output-manifest",
17
+ generateBundle(ctx) {
18
+ return [{
19
+ type: "asset",
20
+ fileName,
21
+ source: JSON.stringify(ctx.manifest, null, pretty ? 2 : 0)
22
+ }];
23
+ }
24
+ };
25
+ }
26
+ //#endregion
27
+ exports.default = manifestOutput;
@@ -0,0 +1,27 @@
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 packages/web-c/bundler-plugin/src/outputPlugins/manifest.ts
11
+ function manifestOutput(options = {}) {
12
+ var _options$fileName, _options$pretty;
13
+ const fileName = (_options$fileName = options.fileName) !== null && _options$fileName !== void 0 ? _options$fileName : "zeus.components.json";
14
+ const pretty = (_options$pretty = options.pretty) !== null && _options$pretty !== void 0 ? _options$pretty : true;
15
+ return {
16
+ name: "zeus-output-manifest",
17
+ generateBundle(ctx) {
18
+ return [{
19
+ type: "asset",
20
+ fileName,
21
+ source: JSON.stringify(ctx.manifest, null, pretty ? 2 : 0)
22
+ }];
23
+ }
24
+ };
25
+ }
26
+ //#endregion
27
+ exports.default = manifestOutput;
@@ -0,0 +1,3 @@
1
+ import type { ZeusComponentPlugin } from '../types';
2
+
3
+ export default function manifestOutput(options?: ManifestOutputOptions): ZeusComponentPlugin;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * bundler-plugin v0.1.0-beta.0
3
+ * (c) 2026 baicie
4
+ * Released under the MIT License.
5
+ **/
6
+ //#region packages/web-c/bundler-plugin/src/outputPlugins/manifest.ts
7
+ function manifestOutput(options = {}) {
8
+ var _options$fileName, _options$pretty;
9
+ const fileName = (_options$fileName = options.fileName) !== null && _options$fileName !== void 0 ? _options$fileName : "zeus.components.json";
10
+ const pretty = (_options$pretty = options.pretty) !== null && _options$pretty !== void 0 ? _options$pretty : true;
11
+ return {
12
+ name: "zeus-output-manifest",
13
+ generateBundle(ctx) {
14
+ return [{
15
+ type: "asset",
16
+ fileName,
17
+ source: JSON.stringify(ctx.manifest, null, pretty ? 2 : 0)
18
+ }];
19
+ }
20
+ };
21
+ }
22
+ //#endregion
23
+ export { manifestOutput as default };