@zeus-js/bundler-plugin 0.1.0-beta.0 → 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.
- package/dist/bundler-plugin.cjs.js +135 -48
- package/dist/bundler-plugin.cjs.prod.js +135 -48
- package/dist/bundler-plugin.d.ts +40 -10
- package/dist/bundler-plugin.esm-bundler.js +134 -48
- package/dist/outputPlugins/manifest.cjs.js +1 -1
- package/dist/outputPlugins/manifest.cjs.prod.js +1 -1
- package/dist/outputPlugins/manifest.d.ts +86 -2
- package/dist/outputPlugins/manifest.js +1 -1
- package/dist/outputPlugins/manifest.prod.js +1 -1
- package/dist/rolldown.cjs.js +610 -0
- package/dist/rolldown.cjs.prod.js +610 -0
- package/dist/rolldown.d.ts +156 -0
- package/dist/rolldown.js +745 -0
- package/dist/rolldown.prod.js +745 -0
- package/dist/rollup.cjs.js +610 -0
- package/dist/rollup.cjs.prod.js +610 -0
- package/dist/rollup.d.ts +156 -0
- package/dist/rollup.js +745 -0
- package/dist/rollup.prod.js +745 -0
- package/dist/vite.cjs.js +146 -63
- package/dist/vite.cjs.prod.js +146 -63
- package/dist/vite.d.ts +148 -4
- package/dist/vite.js +150 -66
- package/dist/vite.prod.js +150 -66
- package/package.json +25 -5
package/dist/bundler-plugin.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { CompilerOptions } from '@zeus-js/compiler';
|
|
2
2
|
import { ComponentManifest, AnalyzerDiagnostic } from '@zeus-js/component-analyzer';
|
|
3
|
-
import {
|
|
3
|
+
import { Plugin } from 'rollup';
|
|
4
4
|
|
|
5
5
|
type MaybePromise<T> = T | Promise<T>;
|
|
6
|
-
export type RollupExternalOption =
|
|
6
|
+
export type RollupExternalOption = string | RegExp | Array<string | RegExp> | ((source: string, importer: string | undefined, isResolved: boolean) => boolean);
|
|
7
7
|
type RootOption = string | (() => string);
|
|
8
8
|
export type ZeusOutputKind = 'wc' | 'react' | 'vue' | 'icons-react' | 'icons-vue' | 'icons-wc' | 'asset';
|
|
9
9
|
export type DtsMode = boolean | 'auto';
|
|
@@ -19,14 +19,15 @@ export interface ZeusBuildContext {
|
|
|
19
19
|
diagnostics: AnalyzerDiagnostic[];
|
|
20
20
|
dts: ResolvedDts;
|
|
21
21
|
outputs: ZeusOutputRegistry;
|
|
22
|
-
emitFile:
|
|
23
|
-
warn:
|
|
24
|
-
error:
|
|
25
|
-
addWatchFile:
|
|
22
|
+
emitFile: (file: unknown) => string | void;
|
|
23
|
+
warn: (message: string | Error) => void;
|
|
24
|
+
error: (message: string | Error) => never;
|
|
25
|
+
addWatchFile: (id: string) => void;
|
|
26
26
|
meta: {
|
|
27
27
|
watchMode: boolean;
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
|
+
type ZeusOutputBundle = Record<string, unknown>;
|
|
30
31
|
export interface ZeusOutputRegistry {
|
|
31
32
|
register(kind: ZeusOutputKind, options: ZeusOutputRegistration): void;
|
|
32
33
|
has(kind: ZeusOutputKind): boolean;
|
|
@@ -71,9 +72,12 @@ export interface ZeusComponentPlugin {
|
|
|
71
72
|
setup?(ctx: ZeusBuildContext): void | Promise<void>;
|
|
72
73
|
buildStart?(ctx: ZeusBuildContext): MaybePromise<void>;
|
|
73
74
|
virtualModules?(ctx: ZeusBuildContext): MaybePromise<ZeusVirtualModule[] | void>;
|
|
74
|
-
generateBundle?(ctx: ZeusBuildContext, bundle:
|
|
75
|
+
generateBundle?(ctx: ZeusBuildContext, bundle: ZeusOutputBundle): MaybePromise<ZeusOutputFile[] | void>;
|
|
75
76
|
/**
|
|
76
|
-
*
|
|
77
|
+
* Framework dependencies that bundler config helpers should externalize.
|
|
78
|
+
*
|
|
79
|
+
* Used by the Vite adapter, defineZeusRollupConfig(), and
|
|
80
|
+
* defineZeusRolldownConfig().
|
|
77
81
|
*/
|
|
78
82
|
external?: string[];
|
|
79
83
|
}
|
|
@@ -94,6 +98,16 @@ export interface ZeusBundlerPluginOptions {
|
|
|
94
98
|
include?: string[];
|
|
95
99
|
exclude?: string[];
|
|
96
100
|
};
|
|
101
|
+
/**
|
|
102
|
+
* Zeus JSX compile transform filter.
|
|
103
|
+
*
|
|
104
|
+
* This is intentionally separate from `components`: files can be excluded
|
|
105
|
+
* from component analysis / manifest generation while still compiling JSX.
|
|
106
|
+
*/
|
|
107
|
+
transform?: {
|
|
108
|
+
include?: string[];
|
|
109
|
+
exclude?: string[];
|
|
110
|
+
};
|
|
97
111
|
/**
|
|
98
112
|
* Declaration generation mode.
|
|
99
113
|
*
|
|
@@ -114,9 +128,25 @@ export interface ZeusBundlerPluginOptions {
|
|
|
114
128
|
* Component-host plugins.
|
|
115
129
|
*/
|
|
116
130
|
plugins?: ZeusComponentPlugin[];
|
|
131
|
+
/**
|
|
132
|
+
* Enable TypeScript transpilation via Babel preset-typescript.
|
|
133
|
+
*
|
|
134
|
+
* @default
|
|
135
|
+
* - rollup: true
|
|
136
|
+
* - rolldown: false
|
|
137
|
+
* - vite: false
|
|
138
|
+
*/
|
|
139
|
+
transpile?: boolean;
|
|
140
|
+
/**
|
|
141
|
+
* Rollup adapter only. Additional extensions to try when resolving imports.
|
|
142
|
+
* Set to `false` to disable extension resolution.
|
|
143
|
+
*
|
|
144
|
+
* @default ['.ts', '.tsx', '.mts', '.cts', '.js', '.jsx', '.mjs', '.cjs']
|
|
145
|
+
*/
|
|
146
|
+
resolveExtensions?: string[] | false;
|
|
117
147
|
}
|
|
118
148
|
|
|
119
|
-
export declare function
|
|
149
|
+
export declare function zeus(options?: ZeusBundlerPluginOptions): Plugin;
|
|
120
150
|
|
|
121
151
|
export declare function createOutputRegistry(): ZeusOutputRegistry;
|
|
122
152
|
|
|
@@ -127,4 +157,4 @@ export declare function resolvePluginDts(value: DtsMode | undefined, ctx: ZeusBu
|
|
|
127
157
|
|
|
128
158
|
export declare function mergeExternal(userExternal: RollupExternalOption | undefined, pluginExternal: string[]): RollupExternalOption;
|
|
129
159
|
|
|
130
|
-
export {
|
|
160
|
+
export { zeus as default, };
|
|
@@ -1,19 +1,24 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* bundler-plugin v0.1.0-beta.
|
|
2
|
+
* bundler-plugin v0.1.0-beta.2
|
|
3
3
|
* (c) 2026 baicie
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
**/
|
|
6
|
+
import fs from "node:fs";
|
|
6
7
|
import path from "node:path";
|
|
7
8
|
import { analyzeComponents } from "@zeus-js/component-analyzer";
|
|
8
9
|
import fg from "fast-glob";
|
|
9
10
|
import picomatch from "picomatch";
|
|
10
|
-
import fs from "node:fs/promises";
|
|
11
|
+
import fs$1 from "node:fs/promises";
|
|
11
12
|
import { transformAsync } from "@babel/core";
|
|
13
|
+
import presetTypeScript from "@babel/preset-typescript";
|
|
12
14
|
import zeusCompiler from "@zeus-js/compiler";
|
|
13
15
|
//#region packages/web-c/bundler-plugin/src/filter.ts
|
|
14
16
|
function cleanUrl(id) {
|
|
15
17
|
return id.replace(/[?#].*$/, "");
|
|
16
18
|
}
|
|
19
|
+
function isTypeScriptLike(id) {
|
|
20
|
+
return /\.[cm]?tsx?$/.test(cleanUrl(id));
|
|
21
|
+
}
|
|
17
22
|
//#endregion
|
|
18
23
|
//#region packages/web-c/bundler-plugin/src/componentTransformFilter.ts
|
|
19
24
|
function normalizePath$1(value) {
|
|
@@ -42,12 +47,28 @@ const DEFAULT_COMPONENT_EXCLUDE = [
|
|
|
42
47
|
"node_modules/**",
|
|
43
48
|
"dist/**"
|
|
44
49
|
];
|
|
50
|
+
const DEFAULT_TRANSFORM_INCLUDE = DEFAULT_COMPONENT_INCLUDE;
|
|
51
|
+
const DEFAULT_TRANSFORM_EXCLUDE = [
|
|
52
|
+
"**/*.test.*",
|
|
53
|
+
"**/*.spec.*",
|
|
54
|
+
"**/__tests__/**",
|
|
55
|
+
"**/*.d.ts",
|
|
56
|
+
"node_modules/**",
|
|
57
|
+
"dist/**"
|
|
58
|
+
];
|
|
45
59
|
function resolveComponentInclude(include) {
|
|
46
60
|
return (include === null || include === void 0 ? void 0 : include.length) ? include : DEFAULT_COMPONENT_INCLUDE;
|
|
47
61
|
}
|
|
48
62
|
function resolveComponentExclude(exclude) {
|
|
49
63
|
return (exclude === null || exclude === void 0 ? void 0 : exclude.length) ? exclude : DEFAULT_COMPONENT_EXCLUDE;
|
|
50
64
|
}
|
|
65
|
+
function resolveTransformInclude(include, componentInclude) {
|
|
66
|
+
if (include === null || include === void 0 ? void 0 : include.length) return include;
|
|
67
|
+
return Array.from(new Set([...DEFAULT_TRANSFORM_INCLUDE, ...componentInclude]));
|
|
68
|
+
}
|
|
69
|
+
function resolveTransformExclude(exclude) {
|
|
70
|
+
return (exclude === null || exclude === void 0 ? void 0 : exclude.length) ? exclude : DEFAULT_TRANSFORM_EXCLUDE;
|
|
71
|
+
}
|
|
51
72
|
//#endregion
|
|
52
73
|
//#region packages/web-c/bundler-plugin/src/diagnostics.ts
|
|
53
74
|
function formatDiagnostic(diagnostic) {
|
|
@@ -229,7 +250,7 @@ function readPackageJson(_x5) {
|
|
|
229
250
|
function _readPackageJson() {
|
|
230
251
|
_readPackageJson = _asyncToGenerator(function* (root) {
|
|
231
252
|
try {
|
|
232
|
-
return JSON.parse(yield fs.readFile(path.join(root, "package.json"), "utf-8"));
|
|
253
|
+
return JSON.parse(yield fs$1.readFile(path.join(root, "package.json"), "utf-8"));
|
|
233
254
|
} catch (_unused) {
|
|
234
255
|
return null;
|
|
235
256
|
}
|
|
@@ -242,7 +263,7 @@ function fileExists(_x6) {
|
|
|
242
263
|
function _fileExists() {
|
|
243
264
|
_fileExists = _asyncToGenerator(function* (file) {
|
|
244
265
|
try {
|
|
245
|
-
yield fs.access(file);
|
|
266
|
+
yield fs$1.access(file);
|
|
246
267
|
return true;
|
|
247
268
|
} catch (_unused2) {
|
|
248
269
|
return false;
|
|
@@ -309,17 +330,28 @@ function transformZeus(_x) {
|
|
|
309
330
|
}
|
|
310
331
|
function _transformZeus() {
|
|
311
332
|
_transformZeus = _asyncToGenerator(function* (options) {
|
|
312
|
-
var
|
|
313
|
-
const { id, code, compiler, sourcemap = true } = options;
|
|
333
|
+
var _compilerOptions$modu;
|
|
334
|
+
const { id, code, compiler, sourcemap = true, transpile = false } = options;
|
|
335
|
+
const isTs = isTypeScriptLike(id);
|
|
336
|
+
const isTsx = /\.[cm]?tsx$/.test(id.replace(/[?#].*$/, ""));
|
|
337
|
+
const shouldRunCompiler = compiler !== false;
|
|
338
|
+
const shouldStripTs = transpile && isTs;
|
|
339
|
+
if (!shouldRunCompiler && !shouldStripTs) return null;
|
|
340
|
+
const compilerOptions = compiler === false ? {} : compiler === void 0 ? {} : compiler;
|
|
314
341
|
const result = yield transformAsync(code, {
|
|
315
342
|
filename: id,
|
|
316
343
|
sourceMaps: sourcemap,
|
|
317
|
-
plugins: [[zeusCompiler, _objectSpread2({
|
|
318
|
-
moduleName: (
|
|
344
|
+
plugins: shouldRunCompiler ? [[zeusCompiler, _objectSpread2({
|
|
345
|
+
moduleName: (_compilerOptions$modu = compilerOptions.moduleName) !== null && _compilerOptions$modu !== void 0 ? _compilerOptions$modu : "@zeus-js/runtime-dom",
|
|
319
346
|
generate: "dom",
|
|
320
347
|
hydratable: false,
|
|
321
348
|
delegateEvents: true
|
|
322
|
-
},
|
|
349
|
+
}, compilerOptions)]] : [],
|
|
350
|
+
presets: shouldStripTs ? [[presetTypeScript, {
|
|
351
|
+
allExtensions: true,
|
|
352
|
+
isTSX: isTsx,
|
|
353
|
+
allowDeclareFields: true
|
|
354
|
+
}]] : [],
|
|
323
355
|
parserOpts: {
|
|
324
356
|
sourceType: "module",
|
|
325
357
|
plugins: ["typescript", "jsx"]
|
|
@@ -420,34 +452,38 @@ function normalizePath(value) {
|
|
|
420
452
|
return value.replace(/\\/g, "/").replace(/^\.\//, "");
|
|
421
453
|
}
|
|
422
454
|
//#endregion
|
|
423
|
-
//#region packages/web-c/bundler-plugin/src/
|
|
424
|
-
function
|
|
425
|
-
|
|
426
|
-
|
|
455
|
+
//#region packages/web-c/bundler-plugin/src/core.ts
|
|
456
|
+
function createZeusBundlerPlugin(options = {}, createOptions) {
|
|
457
|
+
const target = createOptions.target;
|
|
458
|
+
let shouldCompileZeus = (_id) => false;
|
|
427
459
|
let ctx;
|
|
460
|
+
let root = process.cwd();
|
|
461
|
+
const virtualModules = new VirtualModuleRegistry();
|
|
428
462
|
return {
|
|
429
|
-
name:
|
|
463
|
+
name: resolvePluginName(target),
|
|
430
464
|
buildStart() {
|
|
431
465
|
var _this = this;
|
|
432
466
|
return _asyncToGenerator(function* () {
|
|
433
|
-
var _options$components, _options$components2, _options$plugins;
|
|
467
|
+
var _options$components, _options$components2, _options$transform, _options$transform2, _options$plugins;
|
|
434
468
|
virtualModules.clear();
|
|
435
|
-
|
|
436
|
-
const
|
|
437
|
-
const
|
|
438
|
-
|
|
469
|
+
root = resolveRoot(options.root);
|
|
470
|
+
const componentInclude = resolveComponentInclude((_options$components = options.components) === null || _options$components === void 0 ? void 0 : _options$components.include);
|
|
471
|
+
const componentExclude = resolveComponentExclude((_options$components2 = options.components) === null || _options$components2 === void 0 ? void 0 : _options$components2.exclude);
|
|
472
|
+
const transformInclude = resolveTransformInclude((_options$transform = options.transform) === null || _options$transform === void 0 ? void 0 : _options$transform.include, componentInclude);
|
|
473
|
+
const transformExclude = resolveTransformExclude((_options$transform2 = options.transform) === null || _options$transform2 === void 0 ? void 0 : _options$transform2.exclude);
|
|
474
|
+
shouldCompileZeus = createComponentTransformFilter({
|
|
439
475
|
root,
|
|
440
|
-
include,
|
|
441
|
-
exclude
|
|
476
|
+
include: transformInclude,
|
|
477
|
+
exclude: transformExclude
|
|
442
478
|
});
|
|
443
479
|
const dts = yield resolveDts({
|
|
444
480
|
root,
|
|
445
481
|
mode: options.dts,
|
|
446
|
-
include,
|
|
447
|
-
exclude
|
|
482
|
+
include: componentInclude,
|
|
483
|
+
exclude: componentExclude
|
|
448
484
|
});
|
|
449
|
-
const manifestResult = yield createManifest(root,
|
|
450
|
-
for (const file of yield collectWatchFiles(root,
|
|
485
|
+
const manifestResult = yield createManifest(root, componentInclude, componentExclude);
|
|
486
|
+
for (const file of yield collectWatchFiles(root, componentInclude, componentExclude)) _this.addWatchFile(file);
|
|
451
487
|
const diagnostics = manifestResult.diagnostics;
|
|
452
488
|
for (const diagnostic of diagnostics) {
|
|
453
489
|
const message = formatDiagnostic(diagnostic);
|
|
@@ -456,13 +492,12 @@ function createZeusPlugin(options = {}) {
|
|
|
456
492
|
}
|
|
457
493
|
if (hasErrorDiagnostics(diagnostics)) _this.error("[zeus] component analyzer failed.");
|
|
458
494
|
if (options.diagnostics === "verbose") _this.warn(`[zeus] dts ${dts.enabled ? "enabled" : "disabled"}: ${dts.reason.join(", ") || "no signal"}`);
|
|
459
|
-
const outputs = createOutputRegistry();
|
|
460
495
|
ctx = {
|
|
461
496
|
root,
|
|
462
497
|
manifest: manifestResult.manifest,
|
|
463
498
|
diagnostics,
|
|
464
499
|
dts,
|
|
465
|
-
outputs,
|
|
500
|
+
outputs: createOutputRegistry(),
|
|
466
501
|
emitFile: _this.emitFile.bind(_this),
|
|
467
502
|
warn: _this.warn.bind(_this),
|
|
468
503
|
error: _this.error.bind(_this),
|
|
@@ -488,11 +523,15 @@ function createZeusPlugin(options = {}) {
|
|
|
488
523
|
})();
|
|
489
524
|
},
|
|
490
525
|
resolveId(id, importer) {
|
|
491
|
-
const
|
|
492
|
-
if (
|
|
493
|
-
id:
|
|
526
|
+
const resolvedVirtual = virtualModules.resolve(id, importer);
|
|
527
|
+
if (resolvedVirtual) return {
|
|
528
|
+
id: resolvedVirtual,
|
|
494
529
|
moduleSideEffects: "no-treeshake"
|
|
495
530
|
};
|
|
531
|
+
if (target === "rollup") {
|
|
532
|
+
const resolvedTs = resolveTsLikeImport(id, importer, { extensions: options.resolveExtensions });
|
|
533
|
+
if (resolvedTs) return resolvedTs;
|
|
534
|
+
}
|
|
496
535
|
return null;
|
|
497
536
|
},
|
|
498
537
|
load(id) {
|
|
@@ -500,15 +539,16 @@ function createZeusPlugin(options = {}) {
|
|
|
500
539
|
},
|
|
501
540
|
transform(code, id) {
|
|
502
541
|
return _asyncToGenerator(function* () {
|
|
503
|
-
|
|
504
|
-
const
|
|
542
|
+
const shouldRunZeus = shouldCompileZeus(id);
|
|
543
|
+
const shouldStripTs = resolveTranspile(options.transpile, target) && isTypeScriptLike(id);
|
|
544
|
+
if (!shouldRunZeus && !shouldStripTs) return null;
|
|
545
|
+
return yield transformZeus({
|
|
505
546
|
id,
|
|
506
547
|
code,
|
|
507
|
-
compiler: options.compiler,
|
|
508
|
-
sourcemap: true
|
|
548
|
+
compiler: shouldRunZeus ? options.compiler : false,
|
|
549
|
+
sourcemap: true,
|
|
550
|
+
transpile: shouldStripTs
|
|
509
551
|
});
|
|
510
|
-
if (!result) return null;
|
|
511
|
-
return result;
|
|
512
552
|
})();
|
|
513
553
|
},
|
|
514
554
|
generateBundle(_, bundle) {
|
|
@@ -527,6 +567,19 @@ function createZeusPlugin(options = {}) {
|
|
|
527
567
|
}
|
|
528
568
|
};
|
|
529
569
|
}
|
|
570
|
+
function resolvePluginName(target) {
|
|
571
|
+
if (target === "vite") return "vite-plugin-zeus";
|
|
572
|
+
if (target === "rolldown") return "rolldown-plugin-zeus";
|
|
573
|
+
return "rollup-plugin-zeus";
|
|
574
|
+
}
|
|
575
|
+
function resolveTranspile(value, target) {
|
|
576
|
+
if (typeof value === "boolean") return value;
|
|
577
|
+
return target === "rollup";
|
|
578
|
+
}
|
|
579
|
+
function resolveRoot(root) {
|
|
580
|
+
if (typeof root === "function") return path.resolve(root());
|
|
581
|
+
return path.resolve(root !== null && root !== void 0 ? root : process.cwd());
|
|
582
|
+
}
|
|
530
583
|
function createManifest(_x, _x2, _x3) {
|
|
531
584
|
return _createManifest.apply(this, arguments);
|
|
532
585
|
}
|
|
@@ -561,9 +614,37 @@ function _collectWatchFiles() {
|
|
|
561
614
|
});
|
|
562
615
|
return _collectWatchFiles.apply(this, arguments);
|
|
563
616
|
}
|
|
564
|
-
function
|
|
565
|
-
|
|
566
|
-
|
|
617
|
+
function resolveTsLikeImport(id, importer, options) {
|
|
618
|
+
var _options$extensions;
|
|
619
|
+
if (!importer) return null;
|
|
620
|
+
if (cleanUrl(id) !== id) return null;
|
|
621
|
+
const source = cleanUrl(id);
|
|
622
|
+
const from = cleanUrl(importer);
|
|
623
|
+
if (source.startsWith("\0") || from.startsWith("\0")) return null;
|
|
624
|
+
if (!source.startsWith(".") && !isAbsoluteImportPath(source)) return null;
|
|
625
|
+
if (path.extname(source)) return null;
|
|
626
|
+
if (options.extensions === false) return null;
|
|
627
|
+
const extensions = (_options$extensions = options.extensions) !== null && _options$extensions !== void 0 ? _options$extensions : [
|
|
628
|
+
".ts",
|
|
629
|
+
".tsx",
|
|
630
|
+
".mts",
|
|
631
|
+
".cts",
|
|
632
|
+
".js",
|
|
633
|
+
".jsx",
|
|
634
|
+
".mjs",
|
|
635
|
+
".cjs"
|
|
636
|
+
];
|
|
637
|
+
const base = isAbsoluteImportPath(source) ? source : path.resolve(path.dirname(from), source);
|
|
638
|
+
const candidates = [
|
|
639
|
+
base,
|
|
640
|
+
...extensions.map((ext) => `${base}${ext}`),
|
|
641
|
+
...extensions.map((ext) => path.join(base, `index${ext}`))
|
|
642
|
+
];
|
|
643
|
+
for (const file of candidates) if (fs.existsSync(file) && fs.statSync(file).isFile()) return file;
|
|
644
|
+
return null;
|
|
645
|
+
}
|
|
646
|
+
function isAbsoluteImportPath(id) {
|
|
647
|
+
return path.isAbsolute(id) || /^[a-zA-Z]:[\\/]/.test(id);
|
|
567
648
|
}
|
|
568
649
|
function emitOutputFile(pluginContext, file) {
|
|
569
650
|
if (file.type === "asset") {
|
|
@@ -592,14 +673,7 @@ function emitVirtualEntries(modules, pluginContext) {
|
|
|
592
673
|
}
|
|
593
674
|
}
|
|
594
675
|
//#endregion
|
|
595
|
-
//#region packages/web-c/bundler-plugin/src/
|
|
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
|
|
676
|
+
//#region packages/web-c/bundler-plugin/src/external.ts
|
|
603
677
|
function mergeExternal(userExternal, pluginExternal) {
|
|
604
678
|
if (!userExternal) return pluginExternal;
|
|
605
679
|
if (typeof userExternal === "function") return (source, importer, isResolved) => {
|
|
@@ -608,4 +682,16 @@ function mergeExternal(userExternal, pluginExternal) {
|
|
|
608
682
|
return [...Array.isArray(userExternal) ? userExternal : [userExternal], ...pluginExternal];
|
|
609
683
|
}
|
|
610
684
|
//#endregion
|
|
611
|
-
|
|
685
|
+
//#region packages/web-c/bundler-plugin/src/rollup.ts
|
|
686
|
+
function zeus(options = {}) {
|
|
687
|
+
return createZeusBundlerPlugin(options, { target: "rollup" });
|
|
688
|
+
}
|
|
689
|
+
//#endregion
|
|
690
|
+
//#region packages/web-c/bundler-plugin/src/pluginOptions.ts
|
|
691
|
+
function resolvePluginDts(value, ctx) {
|
|
692
|
+
if (value === true) return true;
|
|
693
|
+
if (value === false) return false;
|
|
694
|
+
return ctx.dts.enabled;
|
|
695
|
+
}
|
|
696
|
+
//#endregion
|
|
697
|
+
export { createOutputRegistry, zeus as default, zeus, mergeExternal, resolveComponentExclude, resolveComponentInclude, resolvePluginDts };
|
|
@@ -1,3 +1,87 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ComponentManifest, AnalyzerDiagnostic } from '@zeus-js/component-analyzer';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
4
|
+
type ZeusOutputKind = 'wc' | 'react' | 'vue' | 'icons-react' | 'icons-vue' | 'icons-wc' | 'asset';
|
|
5
|
+
type DtsMode = boolean | 'auto';
|
|
6
|
+
interface ResolvedDts {
|
|
7
|
+
enabled: boolean;
|
|
8
|
+
mode: DtsMode;
|
|
9
|
+
reason: DtsAutoReason[];
|
|
10
|
+
}
|
|
11
|
+
type DtsAutoReason = 'explicit-enabled' | 'explicit-disabled' | 'package-types-field' | 'typescript-dependency' | 'tsconfig' | 'typescript-source';
|
|
12
|
+
interface ZeusBuildContext {
|
|
13
|
+
root: string;
|
|
14
|
+
manifest: ComponentManifest;
|
|
15
|
+
diagnostics: AnalyzerDiagnostic[];
|
|
16
|
+
dts: ResolvedDts;
|
|
17
|
+
outputs: ZeusOutputRegistry;
|
|
18
|
+
emitFile: (file: unknown) => string | void;
|
|
19
|
+
warn: (message: string | Error) => void;
|
|
20
|
+
error: (message: string | Error) => never;
|
|
21
|
+
addWatchFile: (id: string) => void;
|
|
22
|
+
meta: {
|
|
23
|
+
watchMode: boolean;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
type ZeusOutputBundle = Record<string, unknown>;
|
|
27
|
+
interface ZeusOutputRegistry {
|
|
28
|
+
register(kind: ZeusOutputKind, options: ZeusOutputRegistration): void;
|
|
29
|
+
has(kind: ZeusOutputKind): boolean;
|
|
30
|
+
get(kind: ZeusOutputKind): RequiredZeusOutputRegistration;
|
|
31
|
+
getDir(kind: ZeusOutputKind): string;
|
|
32
|
+
getFileName(kind: ZeusOutputKind, tag: string): string;
|
|
33
|
+
join(kind: ZeusOutputKind, fileName: string): string;
|
|
34
|
+
}
|
|
35
|
+
interface ZeusOutputRegistration {
|
|
36
|
+
outDir?: string;
|
|
37
|
+
stripPrefix?: string | false;
|
|
38
|
+
fileName?: (tag: string, kind: ZeusOutputKind) => string;
|
|
39
|
+
}
|
|
40
|
+
interface RequiredZeusOutputRegistration {
|
|
41
|
+
outDir: string;
|
|
42
|
+
stripPrefix: string | false;
|
|
43
|
+
fileName?: (tag: string, kind: ZeusOutputKind) => string;
|
|
44
|
+
}
|
|
45
|
+
interface ZeusVirtualModule {
|
|
46
|
+
id: string;
|
|
47
|
+
code: string;
|
|
48
|
+
fileName?: string;
|
|
49
|
+
}
|
|
50
|
+
interface ZeusOutputAsset {
|
|
51
|
+
type: 'asset';
|
|
52
|
+
fileName: string;
|
|
53
|
+
source: string | Uint8Array;
|
|
54
|
+
}
|
|
55
|
+
interface ZeusOutputChunk {
|
|
56
|
+
type: 'chunk';
|
|
57
|
+
id: string;
|
|
58
|
+
fileName?: string;
|
|
59
|
+
}
|
|
60
|
+
type ZeusOutputFile = ZeusOutputAsset | ZeusOutputChunk;
|
|
61
|
+
interface ZeusComponentPlugin {
|
|
62
|
+
name: string;
|
|
63
|
+
/**
|
|
64
|
+
* Register output dirs / externals / plugin metadata.
|
|
65
|
+
*
|
|
66
|
+
* This hook runs before virtualModules().
|
|
67
|
+
*/
|
|
68
|
+
setup?(ctx: ZeusBuildContext): void | Promise<void>;
|
|
69
|
+
buildStart?(ctx: ZeusBuildContext): MaybePromise<void>;
|
|
70
|
+
virtualModules?(ctx: ZeusBuildContext): MaybePromise<ZeusVirtualModule[] | void>;
|
|
71
|
+
generateBundle?(ctx: ZeusBuildContext, bundle: ZeusOutputBundle): MaybePromise<ZeusOutputFile[] | void>;
|
|
72
|
+
/**
|
|
73
|
+
* Framework dependencies that bundler config helpers should externalize.
|
|
74
|
+
*
|
|
75
|
+
* Used by the Vite adapter, defineZeusRollupConfig(), and
|
|
76
|
+
* defineZeusRolldownConfig().
|
|
77
|
+
*/
|
|
78
|
+
external?: string[];
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface ManifestOutputOptions {
|
|
82
|
+
fileName?: string;
|
|
83
|
+
pretty?: boolean;
|
|
84
|
+
}
|
|
85
|
+
export declare function manifestOutput(options?: ManifestOutputOptions): ZeusComponentPlugin;
|
|
86
|
+
|
|
87
|
+
export { manifestOutput as default };
|