@zeus-js/bundler-plugin 0.1.0-beta.2 → 0.1.0-beta.4
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 +223 -11
- package/dist/bundler-plugin.cjs.prod.js +223 -11
- package/dist/bundler-plugin.d.ts +32 -5
- package/dist/bundler-plugin.esm-bundler.js +250 -16
- package/dist/outputPlugins/manifest.cjs.js +1 -1
- package/dist/outputPlugins/manifest.cjs.prod.js +1 -1
- package/dist/outputPlugins/manifest.d.ts +1 -1
- package/dist/outputPlugins/manifest.js +1 -1
- package/dist/outputPlugins/manifest.prod.js +1 -1
- package/dist/rolldown.cjs.js +112 -20
- package/dist/rolldown.cjs.prod.js +112 -20
- package/dist/rolldown.d.ts +9 -1
- package/dist/rolldown.js +113 -29
- package/dist/rolldown.prod.js +113 -29
- package/dist/rollup.cjs.js +107 -19
- package/dist/rollup.cjs.prod.js +107 -19
- package/dist/rollup.d.ts +9 -1
- package/dist/rollup.js +109 -27
- package/dist/rollup.prod.js +109 -27
- package/dist/vite.cjs.js +105 -18
- package/dist/vite.cjs.prod.js +105 -18
- package/dist/vite.d.ts +9 -1
- package/dist/vite.js +105 -24
- package/dist/vite.prod.js +105 -24
- package/package.json +7 -7
package/dist/vite.cjs.prod.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* bundler-plugin v0.1.0-beta.
|
|
2
|
+
* bundler-plugin v0.1.0-beta.4
|
|
3
3
|
* (c) 2026 baicie
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
**/
|
|
@@ -189,6 +189,42 @@ async function fileExists(file) {
|
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
191
|
//#endregion
|
|
192
|
+
//#region packages/web-c/bundler-plugin/src/external.ts
|
|
193
|
+
const ZEUS_LIBRARY_EXTERNALS = [/^@zeus-js\//];
|
|
194
|
+
function collectPluginExternals(options, collectOptions = {}) {
|
|
195
|
+
var _options$plugins;
|
|
196
|
+
const entries = [];
|
|
197
|
+
if (collectOptions.includeZeusLibraryExternals) entries.push(...ZEUS_LIBRARY_EXTERNALS);
|
|
198
|
+
for (const plugin of (_options$plugins = options.plugins) !== null && _options$plugins !== void 0 ? _options$plugins : []) {
|
|
199
|
+
var _plugin$external;
|
|
200
|
+
for (const dep of (_plugin$external = plugin.external) !== null && _plugin$external !== void 0 ? _plugin$external : []) entries.push(dep);
|
|
201
|
+
}
|
|
202
|
+
return uniqueExternalEntries(entries);
|
|
203
|
+
}
|
|
204
|
+
function mergeExternal(userExternal, pluginExternal) {
|
|
205
|
+
if (!userExternal) return pluginExternal;
|
|
206
|
+
if (typeof userExternal === "function") return (source, importer, isResolved) => {
|
|
207
|
+
return matchesExternal(source, pluginExternal) || userExternal(source, importer, isResolved);
|
|
208
|
+
};
|
|
209
|
+
return uniqueExternalEntries([...Array.isArray(userExternal) ? userExternal : [userExternal], ...pluginExternal]);
|
|
210
|
+
}
|
|
211
|
+
function matchesExternal(source, entries) {
|
|
212
|
+
return entries.some((entry) => {
|
|
213
|
+
return typeof entry === "string" ? entry === source : entry.test(source);
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
function uniqueExternalEntries(entries) {
|
|
217
|
+
const seen = /* @__PURE__ */ new Set();
|
|
218
|
+
const result = [];
|
|
219
|
+
for (const entry of entries) {
|
|
220
|
+
const key = typeof entry === "string" ? `s:${entry}` : `r:${entry.source}/${entry.flags}`;
|
|
221
|
+
if (seen.has(key)) continue;
|
|
222
|
+
seen.add(key);
|
|
223
|
+
result.push(entry);
|
|
224
|
+
}
|
|
225
|
+
return result;
|
|
226
|
+
}
|
|
227
|
+
//#endregion
|
|
192
228
|
//#region packages/web-c/bundler-plugin/src/outputRegistry.ts
|
|
193
229
|
function createOutputRegistry() {
|
|
194
230
|
const map = /* @__PURE__ */ new Map();
|
|
@@ -370,9 +406,39 @@ function createZeusBundlerPlugin(options = {}, createOptions) {
|
|
|
370
406
|
let shouldCompileZeus = (_id) => false;
|
|
371
407
|
let ctx;
|
|
372
408
|
let root = process.cwd();
|
|
409
|
+
const cleanedOutputDirs = /* @__PURE__ */ new Set();
|
|
373
410
|
const virtualModules = new VirtualModuleRegistry();
|
|
374
411
|
return {
|
|
375
412
|
name: resolvePluginName(target),
|
|
413
|
+
options(inputOptions) {
|
|
414
|
+
if (target === "vite") return null;
|
|
415
|
+
const pluginExternals = collectPluginExternals(options, { includeZeusLibraryExternals: true });
|
|
416
|
+
const shouldSetRolldownTarget = target === "rolldown";
|
|
417
|
+
if (!pluginExternals.length && !shouldSetRolldownTarget) return null;
|
|
418
|
+
const nextOptions = { ...inputOptions };
|
|
419
|
+
if (pluginExternals.length) nextOptions.external = mergeExternal(inputOptions.external, pluginExternals);
|
|
420
|
+
if (shouldSetRolldownTarget) {
|
|
421
|
+
var _transform;
|
|
422
|
+
nextOptions.transform = {
|
|
423
|
+
target: "es2016",
|
|
424
|
+
...(_transform = inputOptions.transform) !== null && _transform !== void 0 ? _transform : {}
|
|
425
|
+
};
|
|
426
|
+
}
|
|
427
|
+
return nextOptions;
|
|
428
|
+
},
|
|
429
|
+
outputOptions(outputOptions) {
|
|
430
|
+
if (target === "vite") return null;
|
|
431
|
+
cleanOutputDir(outputOptions, {
|
|
432
|
+
root: resolveRoot(options.root),
|
|
433
|
+
enabled: options.clean !== false,
|
|
434
|
+
cleanedOutputDirs
|
|
435
|
+
});
|
|
436
|
+
if (outputOptions.chunkFileNames) return null;
|
|
437
|
+
return {
|
|
438
|
+
...outputOptions,
|
|
439
|
+
chunkFileNames: "chunks/[name]-[hash].js"
|
|
440
|
+
};
|
|
441
|
+
},
|
|
376
442
|
async buildStart() {
|
|
377
443
|
var _options$components, _options$components2, _options$transform, _options$transform2, _options$plugins;
|
|
378
444
|
virtualModules.clear();
|
|
@@ -437,6 +503,14 @@ function createZeusBundlerPlugin(options = {}, createOptions) {
|
|
|
437
503
|
id: resolvedVirtual,
|
|
438
504
|
moduleSideEffects: "no-treeshake"
|
|
439
505
|
};
|
|
506
|
+
const cleanImporter = importer === null || importer === void 0 ? void 0 : importer.replace(/^\x00/, "");
|
|
507
|
+
if ((cleanImporter === null || cleanImporter === void 0 ? void 0 : cleanImporter.startsWith("zeus:")) && (id.startsWith("./") || id.startsWith("../"))) {
|
|
508
|
+
const virtualEntryId = resolveVirtualEntryImport(id, cleanImporter);
|
|
509
|
+
if (virtualEntryId && virtualModules.has(virtualEntryId)) return {
|
|
510
|
+
id: "\0" + virtualEntryId,
|
|
511
|
+
moduleSideEffects: "no-treeshake"
|
|
512
|
+
};
|
|
513
|
+
}
|
|
440
514
|
if (target === "rollup") {
|
|
441
515
|
const resolvedTs = resolveTsLikeImport(id, importer, { extensions: options.resolveExtensions });
|
|
442
516
|
if (resolvedTs) return resolvedTs;
|
|
@@ -484,6 +558,31 @@ function resolveRoot(root) {
|
|
|
484
558
|
if (typeof root === "function") return node_path.default.resolve(root());
|
|
485
559
|
return node_path.default.resolve(root !== null && root !== void 0 ? root : process.cwd());
|
|
486
560
|
}
|
|
561
|
+
function cleanOutputDir(outputOptions, options) {
|
|
562
|
+
if (!options.enabled) return;
|
|
563
|
+
const outputDir = resolveOutputDir(outputOptions, options.root);
|
|
564
|
+
if (!outputDir || !isSafeCleanTarget(outputDir, options.root)) return;
|
|
565
|
+
if (options.cleanedOutputDirs.has(outputDir)) return;
|
|
566
|
+
options.cleanedOutputDirs.add(outputDir);
|
|
567
|
+
node_fs.default.rmSync(outputDir, {
|
|
568
|
+
recursive: true,
|
|
569
|
+
force: true
|
|
570
|
+
});
|
|
571
|
+
}
|
|
572
|
+
function resolveOutputDir(outputOptions, root) {
|
|
573
|
+
const dir = outputOptions.dir;
|
|
574
|
+
if (typeof dir === "string" && dir.length > 0) return node_path.default.resolve(root, dir);
|
|
575
|
+
const file = outputOptions.file;
|
|
576
|
+
if (typeof file === "string" && file.length > 0) return node_path.default.dirname(node_path.default.resolve(root, file));
|
|
577
|
+
return node_path.default.resolve(root, "dist");
|
|
578
|
+
}
|
|
579
|
+
function isSafeCleanTarget(outputDir, root) {
|
|
580
|
+
const resolvedRoot = node_path.default.resolve(root);
|
|
581
|
+
const resolvedOutputDir = node_path.default.resolve(outputDir);
|
|
582
|
+
if (resolvedOutputDir === resolvedRoot) return false;
|
|
583
|
+
const relative = node_path.default.relative(resolvedRoot, resolvedOutputDir);
|
|
584
|
+
return Boolean(relative) && !relative.startsWith("..") && !node_path.default.isAbsolute(relative);
|
|
585
|
+
}
|
|
487
586
|
async function createManifest(root, include, exclude) {
|
|
488
587
|
if (!include.length) return {
|
|
489
588
|
manifest: {
|
|
@@ -564,23 +663,11 @@ function emitVirtualEntries(modules, pluginContext) {
|
|
|
564
663
|
});
|
|
565
664
|
}
|
|
566
665
|
}
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
for (const plugin of (_options$plugins = options.plugins) !== null && _options$plugins !== void 0 ? _options$plugins : []) {
|
|
573
|
-
var _plugin$external;
|
|
574
|
-
for (const dep of (_plugin$external = plugin.external) !== null && _plugin$external !== void 0 ? _plugin$external : []) set.add(dep);
|
|
575
|
-
}
|
|
576
|
-
return Array.from(set);
|
|
577
|
-
}
|
|
578
|
-
function mergeExternal(userExternal, pluginExternal) {
|
|
579
|
-
if (!userExternal) return pluginExternal;
|
|
580
|
-
if (typeof userExternal === "function") return (source, importer, isResolved) => {
|
|
581
|
-
return pluginExternal.includes(source) || userExternal(source, importer, isResolved);
|
|
582
|
-
};
|
|
583
|
-
return [...Array.isArray(userExternal) ? userExternal : [userExternal], ...pluginExternal];
|
|
666
|
+
function resolveVirtualEntryImport(id, importer) {
|
|
667
|
+
const tagName = id.replace(/\.js$/, "").replace(/^\.\//, "").replace(/\.entry$/, "");
|
|
668
|
+
const lastColon = importer.lastIndexOf(":");
|
|
669
|
+
if (lastColon <= 0) return null;
|
|
670
|
+
return `${importer.slice(0, lastColon + 1)}entry:${tagName}`;
|
|
584
671
|
}
|
|
585
672
|
//#endregion
|
|
586
673
|
//#region packages/web-c/bundler-plugin/src/vite.ts
|
package/dist/vite.d.ts
CHANGED
|
@@ -78,7 +78,7 @@ interface ZeusComponentPlugin {
|
|
|
78
78
|
* Used by the Vite adapter, defineZeusRollupConfig(), and
|
|
79
79
|
* defineZeusRolldownConfig().
|
|
80
80
|
*/
|
|
81
|
-
external?: string
|
|
81
|
+
external?: Array<string | RegExp>;
|
|
82
82
|
}
|
|
83
83
|
interface ZeusBundlerPluginOptions {
|
|
84
84
|
/**
|
|
@@ -136,6 +136,14 @@ interface ZeusBundlerPluginOptions {
|
|
|
136
136
|
* - vite: false
|
|
137
137
|
*/
|
|
138
138
|
transpile?: boolean;
|
|
139
|
+
/**
|
|
140
|
+
* Clean the resolved Rollup/Rolldown output directory before writing.
|
|
141
|
+
*
|
|
142
|
+
* Vite keeps using its own emptyOutDir behavior.
|
|
143
|
+
*
|
|
144
|
+
* @default true
|
|
145
|
+
*/
|
|
146
|
+
clean?: boolean;
|
|
139
147
|
/**
|
|
140
148
|
* Rollup adapter only. Additional extensions to try when resolving imports.
|
|
141
149
|
* Set to `false` to disable extension resolution.
|
package/dist/vite.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* bundler-plugin v0.1.0-beta.
|
|
2
|
+
* bundler-plugin v0.1.0-beta.4
|
|
3
3
|
* (c) 2026 baicie
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
**/
|
|
@@ -80,7 +80,7 @@ function hasErrorDiagnostics(diagnostics) {
|
|
|
80
80
|
return diagnostics.some((item) => item.level === "error");
|
|
81
81
|
}
|
|
82
82
|
//#endregion
|
|
83
|
-
//#region \0@oxc-project+runtime@0.
|
|
83
|
+
//#region \0@oxc-project+runtime@0.134.0/helpers/esm/asyncToGenerator.js
|
|
84
84
|
function asyncGeneratorStep(n, t, e, r, o, a, c) {
|
|
85
85
|
try {
|
|
86
86
|
var i = n[a](c), u = i.value;
|
|
@@ -106,7 +106,7 @@ function _asyncToGenerator(n) {
|
|
|
106
106
|
};
|
|
107
107
|
}
|
|
108
108
|
//#endregion
|
|
109
|
-
//#region \0@oxc-project+runtime@0.
|
|
109
|
+
//#region \0@oxc-project+runtime@0.134.0/helpers/esm/typeof.js
|
|
110
110
|
function _typeof(o) {
|
|
111
111
|
"@babel/helpers - typeof";
|
|
112
112
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -116,7 +116,7 @@ function _typeof(o) {
|
|
|
116
116
|
}, _typeof(o);
|
|
117
117
|
}
|
|
118
118
|
//#endregion
|
|
119
|
-
//#region \0@oxc-project+runtime@0.
|
|
119
|
+
//#region \0@oxc-project+runtime@0.134.0/helpers/esm/toPrimitive.js
|
|
120
120
|
function toPrimitive(t, r) {
|
|
121
121
|
if ("object" != _typeof(t) || !t) return t;
|
|
122
122
|
var e = t[Symbol.toPrimitive];
|
|
@@ -128,13 +128,13 @@ function toPrimitive(t, r) {
|
|
|
128
128
|
return ("string" === r ? String : Number)(t);
|
|
129
129
|
}
|
|
130
130
|
//#endregion
|
|
131
|
-
//#region \0@oxc-project+runtime@0.
|
|
131
|
+
//#region \0@oxc-project+runtime@0.134.0/helpers/esm/toPropertyKey.js
|
|
132
132
|
function toPropertyKey(t) {
|
|
133
133
|
var i = toPrimitive(t, "string");
|
|
134
134
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
135
135
|
}
|
|
136
136
|
//#endregion
|
|
137
|
-
//#region \0@oxc-project+runtime@0.
|
|
137
|
+
//#region \0@oxc-project+runtime@0.134.0/helpers/esm/defineProperty.js
|
|
138
138
|
function _defineProperty(e, r, t) {
|
|
139
139
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
140
140
|
value: t,
|
|
@@ -144,7 +144,7 @@ function _defineProperty(e, r, t) {
|
|
|
144
144
|
}) : e[r] = t, e;
|
|
145
145
|
}
|
|
146
146
|
//#endregion
|
|
147
|
-
//#region \0@oxc-project+runtime@0.
|
|
147
|
+
//#region \0@oxc-project+runtime@0.134.0/helpers/esm/objectSpread2.js
|
|
148
148
|
function ownKeys(e, r) {
|
|
149
149
|
var t = Object.keys(e);
|
|
150
150
|
if (Object.getOwnPropertySymbols) {
|
|
@@ -274,6 +274,42 @@ function _fileExists() {
|
|
|
274
274
|
return _fileExists.apply(this, arguments);
|
|
275
275
|
}
|
|
276
276
|
//#endregion
|
|
277
|
+
//#region packages/web-c/bundler-plugin/src/external.ts
|
|
278
|
+
const ZEUS_LIBRARY_EXTERNALS = [/^@zeus-js\//];
|
|
279
|
+
function collectPluginExternals(options, collectOptions = {}) {
|
|
280
|
+
var _options$plugins;
|
|
281
|
+
const entries = [];
|
|
282
|
+
if (collectOptions.includeZeusLibraryExternals) entries.push(...ZEUS_LIBRARY_EXTERNALS);
|
|
283
|
+
for (const plugin of (_options$plugins = options.plugins) !== null && _options$plugins !== void 0 ? _options$plugins : []) {
|
|
284
|
+
var _plugin$external;
|
|
285
|
+
for (const dep of (_plugin$external = plugin.external) !== null && _plugin$external !== void 0 ? _plugin$external : []) entries.push(dep);
|
|
286
|
+
}
|
|
287
|
+
return uniqueExternalEntries(entries);
|
|
288
|
+
}
|
|
289
|
+
function mergeExternal(userExternal, pluginExternal) {
|
|
290
|
+
if (!userExternal) return pluginExternal;
|
|
291
|
+
if (typeof userExternal === "function") return (source, importer, isResolved) => {
|
|
292
|
+
return matchesExternal(source, pluginExternal) || userExternal(source, importer, isResolved);
|
|
293
|
+
};
|
|
294
|
+
return uniqueExternalEntries([...Array.isArray(userExternal) ? userExternal : [userExternal], ...pluginExternal]);
|
|
295
|
+
}
|
|
296
|
+
function matchesExternal(source, entries) {
|
|
297
|
+
return entries.some((entry) => {
|
|
298
|
+
return typeof entry === "string" ? entry === source : entry.test(source);
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
function uniqueExternalEntries(entries) {
|
|
302
|
+
const seen = /* @__PURE__ */ new Set();
|
|
303
|
+
const result = [];
|
|
304
|
+
for (const entry of entries) {
|
|
305
|
+
const key = typeof entry === "string" ? `s:${entry}` : `r:${entry.source}/${entry.flags}`;
|
|
306
|
+
if (seen.has(key)) continue;
|
|
307
|
+
seen.add(key);
|
|
308
|
+
result.push(entry);
|
|
309
|
+
}
|
|
310
|
+
return result;
|
|
311
|
+
}
|
|
312
|
+
//#endregion
|
|
277
313
|
//#region packages/web-c/bundler-plugin/src/outputRegistry.ts
|
|
278
314
|
function createOutputRegistry() {
|
|
279
315
|
const map = /* @__PURE__ */ new Map();
|
|
@@ -460,9 +496,33 @@ function createZeusBundlerPlugin(options = {}, createOptions) {
|
|
|
460
496
|
let shouldCompileZeus = (_id) => false;
|
|
461
497
|
let ctx;
|
|
462
498
|
let root = process.cwd();
|
|
499
|
+
const cleanedOutputDirs = /* @__PURE__ */ new Set();
|
|
463
500
|
const virtualModules = new VirtualModuleRegistry();
|
|
464
501
|
return {
|
|
465
502
|
name: resolvePluginName(target),
|
|
503
|
+
options(inputOptions) {
|
|
504
|
+
if (target === "vite") return null;
|
|
505
|
+
const pluginExternals = collectPluginExternals(options, { includeZeusLibraryExternals: true });
|
|
506
|
+
const shouldSetRolldownTarget = target === "rolldown";
|
|
507
|
+
if (!pluginExternals.length && !shouldSetRolldownTarget) return null;
|
|
508
|
+
const nextOptions = _objectSpread2({}, inputOptions);
|
|
509
|
+
if (pluginExternals.length) nextOptions.external = mergeExternal(inputOptions.external, pluginExternals);
|
|
510
|
+
if (shouldSetRolldownTarget) {
|
|
511
|
+
var _transform;
|
|
512
|
+
nextOptions.transform = _objectSpread2({ target: "es2016" }, (_transform = inputOptions.transform) !== null && _transform !== void 0 ? _transform : {});
|
|
513
|
+
}
|
|
514
|
+
return nextOptions;
|
|
515
|
+
},
|
|
516
|
+
outputOptions(outputOptions) {
|
|
517
|
+
if (target === "vite") return null;
|
|
518
|
+
cleanOutputDir(outputOptions, {
|
|
519
|
+
root: resolveRoot(options.root),
|
|
520
|
+
enabled: options.clean !== false,
|
|
521
|
+
cleanedOutputDirs
|
|
522
|
+
});
|
|
523
|
+
if (outputOptions.chunkFileNames) return null;
|
|
524
|
+
return _objectSpread2(_objectSpread2({}, outputOptions), {}, { chunkFileNames: "chunks/[name]-[hash].js" });
|
|
525
|
+
},
|
|
466
526
|
buildStart() {
|
|
467
527
|
var _this = this;
|
|
468
528
|
return _asyncToGenerator(function* () {
|
|
@@ -530,6 +590,14 @@ function createZeusBundlerPlugin(options = {}, createOptions) {
|
|
|
530
590
|
id: resolvedVirtual,
|
|
531
591
|
moduleSideEffects: "no-treeshake"
|
|
532
592
|
};
|
|
593
|
+
const cleanImporter = importer === null || importer === void 0 ? void 0 : importer.replace(/^\x00/, "");
|
|
594
|
+
if ((cleanImporter === null || cleanImporter === void 0 ? void 0 : cleanImporter.startsWith("zeus:")) && (id.startsWith("./") || id.startsWith("../"))) {
|
|
595
|
+
const virtualEntryId = resolveVirtualEntryImport(id, cleanImporter);
|
|
596
|
+
if (virtualEntryId && virtualModules.has(virtualEntryId)) return {
|
|
597
|
+
id: "\0" + virtualEntryId,
|
|
598
|
+
moduleSideEffects: "no-treeshake"
|
|
599
|
+
};
|
|
600
|
+
}
|
|
533
601
|
if (target === "rollup") {
|
|
534
602
|
const resolvedTs = resolveTsLikeImport(id, importer, { extensions: options.resolveExtensions });
|
|
535
603
|
if (resolvedTs) return resolvedTs;
|
|
@@ -582,6 +650,31 @@ function resolveRoot(root) {
|
|
|
582
650
|
if (typeof root === "function") return path.resolve(root());
|
|
583
651
|
return path.resolve(root !== null && root !== void 0 ? root : process.cwd());
|
|
584
652
|
}
|
|
653
|
+
function cleanOutputDir(outputOptions, options) {
|
|
654
|
+
if (!options.enabled) return;
|
|
655
|
+
const outputDir = resolveOutputDir(outputOptions, options.root);
|
|
656
|
+
if (!outputDir || !isSafeCleanTarget(outputDir, options.root)) return;
|
|
657
|
+
if (options.cleanedOutputDirs.has(outputDir)) return;
|
|
658
|
+
options.cleanedOutputDirs.add(outputDir);
|
|
659
|
+
fs.rmSync(outputDir, {
|
|
660
|
+
recursive: true,
|
|
661
|
+
force: true
|
|
662
|
+
});
|
|
663
|
+
}
|
|
664
|
+
function resolveOutputDir(outputOptions, root) {
|
|
665
|
+
const dir = outputOptions.dir;
|
|
666
|
+
if (typeof dir === "string" && dir.length > 0) return path.resolve(root, dir);
|
|
667
|
+
const file = outputOptions.file;
|
|
668
|
+
if (typeof file === "string" && file.length > 0) return path.dirname(path.resolve(root, file));
|
|
669
|
+
return path.resolve(root, "dist");
|
|
670
|
+
}
|
|
671
|
+
function isSafeCleanTarget(outputDir, root) {
|
|
672
|
+
const resolvedRoot = path.resolve(root);
|
|
673
|
+
const resolvedOutputDir = path.resolve(outputDir);
|
|
674
|
+
if (resolvedOutputDir === resolvedRoot) return false;
|
|
675
|
+
const relative = path.relative(resolvedRoot, resolvedOutputDir);
|
|
676
|
+
return Boolean(relative) && !relative.startsWith("..") && !path.isAbsolute(relative);
|
|
677
|
+
}
|
|
585
678
|
function createManifest(_x, _x2, _x3) {
|
|
586
679
|
return _createManifest.apply(this, arguments);
|
|
587
680
|
}
|
|
@@ -674,23 +767,11 @@ function emitVirtualEntries(modules, pluginContext) {
|
|
|
674
767
|
});
|
|
675
768
|
}
|
|
676
769
|
}
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
for (const plugin of (_options$plugins = options.plugins) !== null && _options$plugins !== void 0 ? _options$plugins : []) {
|
|
683
|
-
var _plugin$external;
|
|
684
|
-
for (const dep of (_plugin$external = plugin.external) !== null && _plugin$external !== void 0 ? _plugin$external : []) set.add(dep);
|
|
685
|
-
}
|
|
686
|
-
return Array.from(set);
|
|
687
|
-
}
|
|
688
|
-
function mergeExternal(userExternal, pluginExternal) {
|
|
689
|
-
if (!userExternal) return pluginExternal;
|
|
690
|
-
if (typeof userExternal === "function") return (source, importer, isResolved) => {
|
|
691
|
-
return pluginExternal.includes(source) || userExternal(source, importer, isResolved);
|
|
692
|
-
};
|
|
693
|
-
return [...Array.isArray(userExternal) ? userExternal : [userExternal], ...pluginExternal];
|
|
770
|
+
function resolveVirtualEntryImport(id, importer) {
|
|
771
|
+
const tagName = id.replace(/\.js$/, "").replace(/^\.\//, "").replace(/\.entry$/, "");
|
|
772
|
+
const lastColon = importer.lastIndexOf(":");
|
|
773
|
+
if (lastColon <= 0) return null;
|
|
774
|
+
return `${importer.slice(0, lastColon + 1)}entry:${tagName}`;
|
|
694
775
|
}
|
|
695
776
|
//#endregion
|
|
696
777
|
//#region packages/web-c/bundler-plugin/src/vite.ts
|
package/dist/vite.prod.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* bundler-plugin v0.1.0-beta.
|
|
2
|
+
* bundler-plugin v0.1.0-beta.4
|
|
3
3
|
* (c) 2026 baicie
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
**/
|
|
@@ -80,7 +80,7 @@ function hasErrorDiagnostics(diagnostics) {
|
|
|
80
80
|
return diagnostics.some((item) => item.level === "error");
|
|
81
81
|
}
|
|
82
82
|
//#endregion
|
|
83
|
-
//#region \0@oxc-project+runtime@0.
|
|
83
|
+
//#region \0@oxc-project+runtime@0.134.0/helpers/esm/asyncToGenerator.js
|
|
84
84
|
function asyncGeneratorStep(n, t, e, r, o, a, c) {
|
|
85
85
|
try {
|
|
86
86
|
var i = n[a](c), u = i.value;
|
|
@@ -106,7 +106,7 @@ function _asyncToGenerator(n) {
|
|
|
106
106
|
};
|
|
107
107
|
}
|
|
108
108
|
//#endregion
|
|
109
|
-
//#region \0@oxc-project+runtime@0.
|
|
109
|
+
//#region \0@oxc-project+runtime@0.134.0/helpers/esm/typeof.js
|
|
110
110
|
function _typeof(o) {
|
|
111
111
|
"@babel/helpers - typeof";
|
|
112
112
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -116,7 +116,7 @@ function _typeof(o) {
|
|
|
116
116
|
}, _typeof(o);
|
|
117
117
|
}
|
|
118
118
|
//#endregion
|
|
119
|
-
//#region \0@oxc-project+runtime@0.
|
|
119
|
+
//#region \0@oxc-project+runtime@0.134.0/helpers/esm/toPrimitive.js
|
|
120
120
|
function toPrimitive(t, r) {
|
|
121
121
|
if ("object" != _typeof(t) || !t) return t;
|
|
122
122
|
var e = t[Symbol.toPrimitive];
|
|
@@ -128,13 +128,13 @@ function toPrimitive(t, r) {
|
|
|
128
128
|
return ("string" === r ? String : Number)(t);
|
|
129
129
|
}
|
|
130
130
|
//#endregion
|
|
131
|
-
//#region \0@oxc-project+runtime@0.
|
|
131
|
+
//#region \0@oxc-project+runtime@0.134.0/helpers/esm/toPropertyKey.js
|
|
132
132
|
function toPropertyKey(t) {
|
|
133
133
|
var i = toPrimitive(t, "string");
|
|
134
134
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
135
135
|
}
|
|
136
136
|
//#endregion
|
|
137
|
-
//#region \0@oxc-project+runtime@0.
|
|
137
|
+
//#region \0@oxc-project+runtime@0.134.0/helpers/esm/defineProperty.js
|
|
138
138
|
function _defineProperty(e, r, t) {
|
|
139
139
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
140
140
|
value: t,
|
|
@@ -144,7 +144,7 @@ function _defineProperty(e, r, t) {
|
|
|
144
144
|
}) : e[r] = t, e;
|
|
145
145
|
}
|
|
146
146
|
//#endregion
|
|
147
|
-
//#region \0@oxc-project+runtime@0.
|
|
147
|
+
//#region \0@oxc-project+runtime@0.134.0/helpers/esm/objectSpread2.js
|
|
148
148
|
function ownKeys(e, r) {
|
|
149
149
|
var t = Object.keys(e);
|
|
150
150
|
if (Object.getOwnPropertySymbols) {
|
|
@@ -274,6 +274,42 @@ function _fileExists() {
|
|
|
274
274
|
return _fileExists.apply(this, arguments);
|
|
275
275
|
}
|
|
276
276
|
//#endregion
|
|
277
|
+
//#region packages/web-c/bundler-plugin/src/external.ts
|
|
278
|
+
const ZEUS_LIBRARY_EXTERNALS = [/^@zeus-js\//];
|
|
279
|
+
function collectPluginExternals(options, collectOptions = {}) {
|
|
280
|
+
var _options$plugins;
|
|
281
|
+
const entries = [];
|
|
282
|
+
if (collectOptions.includeZeusLibraryExternals) entries.push(...ZEUS_LIBRARY_EXTERNALS);
|
|
283
|
+
for (const plugin of (_options$plugins = options.plugins) !== null && _options$plugins !== void 0 ? _options$plugins : []) {
|
|
284
|
+
var _plugin$external;
|
|
285
|
+
for (const dep of (_plugin$external = plugin.external) !== null && _plugin$external !== void 0 ? _plugin$external : []) entries.push(dep);
|
|
286
|
+
}
|
|
287
|
+
return uniqueExternalEntries(entries);
|
|
288
|
+
}
|
|
289
|
+
function mergeExternal(userExternal, pluginExternal) {
|
|
290
|
+
if (!userExternal) return pluginExternal;
|
|
291
|
+
if (typeof userExternal === "function") return (source, importer, isResolved) => {
|
|
292
|
+
return matchesExternal(source, pluginExternal) || userExternal(source, importer, isResolved);
|
|
293
|
+
};
|
|
294
|
+
return uniqueExternalEntries([...Array.isArray(userExternal) ? userExternal : [userExternal], ...pluginExternal]);
|
|
295
|
+
}
|
|
296
|
+
function matchesExternal(source, entries) {
|
|
297
|
+
return entries.some((entry) => {
|
|
298
|
+
return typeof entry === "string" ? entry === source : entry.test(source);
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
function uniqueExternalEntries(entries) {
|
|
302
|
+
const seen = /* @__PURE__ */ new Set();
|
|
303
|
+
const result = [];
|
|
304
|
+
for (const entry of entries) {
|
|
305
|
+
const key = typeof entry === "string" ? `s:${entry}` : `r:${entry.source}/${entry.flags}`;
|
|
306
|
+
if (seen.has(key)) continue;
|
|
307
|
+
seen.add(key);
|
|
308
|
+
result.push(entry);
|
|
309
|
+
}
|
|
310
|
+
return result;
|
|
311
|
+
}
|
|
312
|
+
//#endregion
|
|
277
313
|
//#region packages/web-c/bundler-plugin/src/outputRegistry.ts
|
|
278
314
|
function createOutputRegistry() {
|
|
279
315
|
const map = /* @__PURE__ */ new Map();
|
|
@@ -460,9 +496,33 @@ function createZeusBundlerPlugin(options = {}, createOptions) {
|
|
|
460
496
|
let shouldCompileZeus = (_id) => false;
|
|
461
497
|
let ctx;
|
|
462
498
|
let root = process.cwd();
|
|
499
|
+
const cleanedOutputDirs = /* @__PURE__ */ new Set();
|
|
463
500
|
const virtualModules = new VirtualModuleRegistry();
|
|
464
501
|
return {
|
|
465
502
|
name: resolvePluginName(target),
|
|
503
|
+
options(inputOptions) {
|
|
504
|
+
if (target === "vite") return null;
|
|
505
|
+
const pluginExternals = collectPluginExternals(options, { includeZeusLibraryExternals: true });
|
|
506
|
+
const shouldSetRolldownTarget = target === "rolldown";
|
|
507
|
+
if (!pluginExternals.length && !shouldSetRolldownTarget) return null;
|
|
508
|
+
const nextOptions = _objectSpread2({}, inputOptions);
|
|
509
|
+
if (pluginExternals.length) nextOptions.external = mergeExternal(inputOptions.external, pluginExternals);
|
|
510
|
+
if (shouldSetRolldownTarget) {
|
|
511
|
+
var _transform;
|
|
512
|
+
nextOptions.transform = _objectSpread2({ target: "es2016" }, (_transform = inputOptions.transform) !== null && _transform !== void 0 ? _transform : {});
|
|
513
|
+
}
|
|
514
|
+
return nextOptions;
|
|
515
|
+
},
|
|
516
|
+
outputOptions(outputOptions) {
|
|
517
|
+
if (target === "vite") return null;
|
|
518
|
+
cleanOutputDir(outputOptions, {
|
|
519
|
+
root: resolveRoot(options.root),
|
|
520
|
+
enabled: options.clean !== false,
|
|
521
|
+
cleanedOutputDirs
|
|
522
|
+
});
|
|
523
|
+
if (outputOptions.chunkFileNames) return null;
|
|
524
|
+
return _objectSpread2(_objectSpread2({}, outputOptions), {}, { chunkFileNames: "chunks/[name]-[hash].js" });
|
|
525
|
+
},
|
|
466
526
|
buildStart() {
|
|
467
527
|
var _this = this;
|
|
468
528
|
return _asyncToGenerator(function* () {
|
|
@@ -530,6 +590,14 @@ function createZeusBundlerPlugin(options = {}, createOptions) {
|
|
|
530
590
|
id: resolvedVirtual,
|
|
531
591
|
moduleSideEffects: "no-treeshake"
|
|
532
592
|
};
|
|
593
|
+
const cleanImporter = importer === null || importer === void 0 ? void 0 : importer.replace(/^\x00/, "");
|
|
594
|
+
if ((cleanImporter === null || cleanImporter === void 0 ? void 0 : cleanImporter.startsWith("zeus:")) && (id.startsWith("./") || id.startsWith("../"))) {
|
|
595
|
+
const virtualEntryId = resolveVirtualEntryImport(id, cleanImporter);
|
|
596
|
+
if (virtualEntryId && virtualModules.has(virtualEntryId)) return {
|
|
597
|
+
id: "\0" + virtualEntryId,
|
|
598
|
+
moduleSideEffects: "no-treeshake"
|
|
599
|
+
};
|
|
600
|
+
}
|
|
533
601
|
if (target === "rollup") {
|
|
534
602
|
const resolvedTs = resolveTsLikeImport(id, importer, { extensions: options.resolveExtensions });
|
|
535
603
|
if (resolvedTs) return resolvedTs;
|
|
@@ -582,6 +650,31 @@ function resolveRoot(root) {
|
|
|
582
650
|
if (typeof root === "function") return path.resolve(root());
|
|
583
651
|
return path.resolve(root !== null && root !== void 0 ? root : process.cwd());
|
|
584
652
|
}
|
|
653
|
+
function cleanOutputDir(outputOptions, options) {
|
|
654
|
+
if (!options.enabled) return;
|
|
655
|
+
const outputDir = resolveOutputDir(outputOptions, options.root);
|
|
656
|
+
if (!outputDir || !isSafeCleanTarget(outputDir, options.root)) return;
|
|
657
|
+
if (options.cleanedOutputDirs.has(outputDir)) return;
|
|
658
|
+
options.cleanedOutputDirs.add(outputDir);
|
|
659
|
+
fs.rmSync(outputDir, {
|
|
660
|
+
recursive: true,
|
|
661
|
+
force: true
|
|
662
|
+
});
|
|
663
|
+
}
|
|
664
|
+
function resolveOutputDir(outputOptions, root) {
|
|
665
|
+
const dir = outputOptions.dir;
|
|
666
|
+
if (typeof dir === "string" && dir.length > 0) return path.resolve(root, dir);
|
|
667
|
+
const file = outputOptions.file;
|
|
668
|
+
if (typeof file === "string" && file.length > 0) return path.dirname(path.resolve(root, file));
|
|
669
|
+
return path.resolve(root, "dist");
|
|
670
|
+
}
|
|
671
|
+
function isSafeCleanTarget(outputDir, root) {
|
|
672
|
+
const resolvedRoot = path.resolve(root);
|
|
673
|
+
const resolvedOutputDir = path.resolve(outputDir);
|
|
674
|
+
if (resolvedOutputDir === resolvedRoot) return false;
|
|
675
|
+
const relative = path.relative(resolvedRoot, resolvedOutputDir);
|
|
676
|
+
return Boolean(relative) && !relative.startsWith("..") && !path.isAbsolute(relative);
|
|
677
|
+
}
|
|
585
678
|
function createManifest(_x, _x2, _x3) {
|
|
586
679
|
return _createManifest.apply(this, arguments);
|
|
587
680
|
}
|
|
@@ -674,23 +767,11 @@ function emitVirtualEntries(modules, pluginContext) {
|
|
|
674
767
|
});
|
|
675
768
|
}
|
|
676
769
|
}
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
for (const plugin of (_options$plugins = options.plugins) !== null && _options$plugins !== void 0 ? _options$plugins : []) {
|
|
683
|
-
var _plugin$external;
|
|
684
|
-
for (const dep of (_plugin$external = plugin.external) !== null && _plugin$external !== void 0 ? _plugin$external : []) set.add(dep);
|
|
685
|
-
}
|
|
686
|
-
return Array.from(set);
|
|
687
|
-
}
|
|
688
|
-
function mergeExternal(userExternal, pluginExternal) {
|
|
689
|
-
if (!userExternal) return pluginExternal;
|
|
690
|
-
if (typeof userExternal === "function") return (source, importer, isResolved) => {
|
|
691
|
-
return pluginExternal.includes(source) || userExternal(source, importer, isResolved);
|
|
692
|
-
};
|
|
693
|
-
return [...Array.isArray(userExternal) ? userExternal : [userExternal], ...pluginExternal];
|
|
770
|
+
function resolveVirtualEntryImport(id, importer) {
|
|
771
|
+
const tagName = id.replace(/\.js$/, "").replace(/^\.\//, "").replace(/\.entry$/, "");
|
|
772
|
+
const lastColon = importer.lastIndexOf(":");
|
|
773
|
+
if (lastColon <= 0) return null;
|
|
774
|
+
return `${importer.slice(0, lastColon + 1)}entry:${tagName}`;
|
|
694
775
|
}
|
|
695
776
|
//#endregion
|
|
696
777
|
//#region packages/web-c/bundler-plugin/src/vite.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeus-js/bundler-plugin",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.4",
|
|
4
4
|
"description": "Zeus bundler plugin host",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -13,14 +13,14 @@
|
|
|
13
13
|
"exports": {
|
|
14
14
|
".": {
|
|
15
15
|
"types": "./dist/bundler-plugin.d.ts",
|
|
16
|
+
"module": "./dist/bundler-plugin.esm-bundler.js",
|
|
17
|
+
"import": "./dist/bundler-plugin.esm-bundler.js",
|
|
18
|
+
"require": "./index.js",
|
|
16
19
|
"node": {
|
|
17
20
|
"production": "./dist/bundler-plugin.cjs.prod.js",
|
|
18
21
|
"development": "./dist/bundler-plugin.cjs.js",
|
|
19
22
|
"default": "./index.js"
|
|
20
|
-
}
|
|
21
|
-
"module": "./dist/bundler-plugin.esm-bundler.js",
|
|
22
|
-
"import": "./dist/bundler-plugin.esm-bundler.js",
|
|
23
|
-
"require": "./index.js"
|
|
23
|
+
}
|
|
24
24
|
},
|
|
25
25
|
"./vite": {
|
|
26
26
|
"types": "./dist/vite.d.ts",
|
|
@@ -74,8 +74,8 @@
|
|
|
74
74
|
"@babel/preset-typescript": "^7.29.7",
|
|
75
75
|
"fast-glob": "^3.3.3",
|
|
76
76
|
"picomatch": "^4.0.4",
|
|
77
|
-
"@zeus-js/compiler": "0.1.0-beta.
|
|
78
|
-
"@zeus-js/component-analyzer": "0.1.0-beta.
|
|
77
|
+
"@zeus-js/compiler": "0.1.0-beta.4",
|
|
78
|
+
"@zeus-js/component-analyzer": "0.1.0-beta.4"
|
|
79
79
|
},
|
|
80
80
|
"peerDependencies": {
|
|
81
81
|
"rollup": "^4.0.0",
|