@zeus-js/bundler-plugin 0.1.0-beta.2 → 0.1.0-beta.3
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 +98 -9
- package/dist/bundler-plugin.cjs.prod.js +98 -9
- package/dist/bundler-plugin.d.ts +11 -2
- package/dist/bundler-plugin.esm-bundler.js +98 -15
- 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 +100 -19
- package/dist/rolldown.cjs.prod.js +100 -19
- package/dist/rolldown.d.ts +9 -1
- package/dist/rolldown.js +102 -27
- package/dist/rolldown.prod.js +102 -27
- package/dist/rollup.cjs.js +100 -19
- package/dist/rollup.cjs.prod.js +100 -19
- package/dist/rollup.d.ts +9 -1
- package/dist/rollup.js +102 -27
- package/dist/rollup.prod.js +102 -27
- package/dist/vite.cjs.js +98 -18
- package/dist/vite.cjs.prod.js +98 -18
- package/dist/vite.d.ts +9 -1
- package/dist/vite.js +98 -24
- package/dist/vite.prod.js +98 -24
- package/package.json +7 -7
package/dist/rollup.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* bundler-plugin v0.1.0-beta.
|
|
2
|
+
* bundler-plugin v0.1.0-beta.3
|
|
3
3
|
* (c) 2026 baicie
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
**/
|
|
@@ -78,7 +78,7 @@ function hasErrorDiagnostics(diagnostics) {
|
|
|
78
78
|
return diagnostics.some((item) => item.level === "error");
|
|
79
79
|
}
|
|
80
80
|
//#endregion
|
|
81
|
-
//#region \0@oxc-project+runtime@0.
|
|
81
|
+
//#region \0@oxc-project+runtime@0.134.0/helpers/esm/asyncToGenerator.js
|
|
82
82
|
function asyncGeneratorStep(n, t, e, r, o, a, c) {
|
|
83
83
|
try {
|
|
84
84
|
var i = n[a](c), u = i.value;
|
|
@@ -104,7 +104,7 @@ function _asyncToGenerator(n) {
|
|
|
104
104
|
};
|
|
105
105
|
}
|
|
106
106
|
//#endregion
|
|
107
|
-
//#region \0@oxc-project+runtime@0.
|
|
107
|
+
//#region \0@oxc-project+runtime@0.134.0/helpers/esm/typeof.js
|
|
108
108
|
function _typeof(o) {
|
|
109
109
|
"@babel/helpers - typeof";
|
|
110
110
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -114,7 +114,7 @@ function _typeof(o) {
|
|
|
114
114
|
}, _typeof(o);
|
|
115
115
|
}
|
|
116
116
|
//#endregion
|
|
117
|
-
//#region \0@oxc-project+runtime@0.
|
|
117
|
+
//#region \0@oxc-project+runtime@0.134.0/helpers/esm/toPrimitive.js
|
|
118
118
|
function toPrimitive(t, r) {
|
|
119
119
|
if ("object" != _typeof(t) || !t) return t;
|
|
120
120
|
var e = t[Symbol.toPrimitive];
|
|
@@ -126,13 +126,13 @@ function toPrimitive(t, r) {
|
|
|
126
126
|
return ("string" === r ? String : Number)(t);
|
|
127
127
|
}
|
|
128
128
|
//#endregion
|
|
129
|
-
//#region \0@oxc-project+runtime@0.
|
|
129
|
+
//#region \0@oxc-project+runtime@0.134.0/helpers/esm/toPropertyKey.js
|
|
130
130
|
function toPropertyKey(t) {
|
|
131
131
|
var i = toPrimitive(t, "string");
|
|
132
132
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
133
133
|
}
|
|
134
134
|
//#endregion
|
|
135
|
-
//#region \0@oxc-project+runtime@0.
|
|
135
|
+
//#region \0@oxc-project+runtime@0.134.0/helpers/esm/defineProperty.js
|
|
136
136
|
function _defineProperty(e, r, t) {
|
|
137
137
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
138
138
|
value: t,
|
|
@@ -142,7 +142,7 @@ function _defineProperty(e, r, t) {
|
|
|
142
142
|
}) : e[r] = t, e;
|
|
143
143
|
}
|
|
144
144
|
//#endregion
|
|
145
|
-
//#region \0@oxc-project+runtime@0.
|
|
145
|
+
//#region \0@oxc-project+runtime@0.134.0/helpers/esm/objectSpread2.js
|
|
146
146
|
function ownKeys(e, r) {
|
|
147
147
|
var t = Object.keys(e);
|
|
148
148
|
if (Object.getOwnPropertySymbols) {
|
|
@@ -272,6 +272,42 @@ function _fileExists() {
|
|
|
272
272
|
return _fileExists.apply(this, arguments);
|
|
273
273
|
}
|
|
274
274
|
//#endregion
|
|
275
|
+
//#region packages/web-c/bundler-plugin/src/external.ts
|
|
276
|
+
const ZEUS_LIBRARY_EXTERNALS = [/^@zeus-js\//];
|
|
277
|
+
function collectPluginExternals(options, collectOptions = {}) {
|
|
278
|
+
var _options$plugins;
|
|
279
|
+
const entries = [];
|
|
280
|
+
if (collectOptions.includeZeusLibraryExternals) entries.push(...ZEUS_LIBRARY_EXTERNALS);
|
|
281
|
+
for (const plugin of (_options$plugins = options.plugins) !== null && _options$plugins !== void 0 ? _options$plugins : []) {
|
|
282
|
+
var _plugin$external;
|
|
283
|
+
for (const dep of (_plugin$external = plugin.external) !== null && _plugin$external !== void 0 ? _plugin$external : []) entries.push(dep);
|
|
284
|
+
}
|
|
285
|
+
return uniqueExternalEntries(entries);
|
|
286
|
+
}
|
|
287
|
+
function mergeExternal(userExternal, pluginExternal) {
|
|
288
|
+
if (!userExternal) return pluginExternal;
|
|
289
|
+
if (typeof userExternal === "function") return (source, importer, isResolved) => {
|
|
290
|
+
return matchesExternal(source, pluginExternal) || userExternal(source, importer, isResolved);
|
|
291
|
+
};
|
|
292
|
+
return uniqueExternalEntries([...Array.isArray(userExternal) ? userExternal : [userExternal], ...pluginExternal]);
|
|
293
|
+
}
|
|
294
|
+
function matchesExternal(source, entries) {
|
|
295
|
+
return entries.some((entry) => {
|
|
296
|
+
return typeof entry === "string" ? entry === source : entry.test(source);
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
function uniqueExternalEntries(entries) {
|
|
300
|
+
const seen = /* @__PURE__ */ new Set();
|
|
301
|
+
const result = [];
|
|
302
|
+
for (const entry of entries) {
|
|
303
|
+
const key = typeof entry === "string" ? `s:${entry}` : `r:${entry.source}/${entry.flags}`;
|
|
304
|
+
if (seen.has(key)) continue;
|
|
305
|
+
seen.add(key);
|
|
306
|
+
result.push(entry);
|
|
307
|
+
}
|
|
308
|
+
return result;
|
|
309
|
+
}
|
|
310
|
+
//#endregion
|
|
275
311
|
//#region packages/web-c/bundler-plugin/src/outputRegistry.ts
|
|
276
312
|
function createOutputRegistry() {
|
|
277
313
|
const map = /* @__PURE__ */ new Map();
|
|
@@ -458,9 +494,26 @@ function createZeusBundlerPlugin(options = {}, createOptions) {
|
|
|
458
494
|
let shouldCompileZeus = (_id) => false;
|
|
459
495
|
let ctx;
|
|
460
496
|
let root = process.cwd();
|
|
497
|
+
const cleanedOutputDirs = /* @__PURE__ */ new Set();
|
|
461
498
|
const virtualModules = new VirtualModuleRegistry();
|
|
462
499
|
return {
|
|
463
500
|
name: resolvePluginName(target),
|
|
501
|
+
options(inputOptions) {
|
|
502
|
+
if (target === "vite") return null;
|
|
503
|
+
const pluginExternals = collectPluginExternals(options, { includeZeusLibraryExternals: true });
|
|
504
|
+
if (!pluginExternals.length) return null;
|
|
505
|
+
return _objectSpread2(_objectSpread2({}, inputOptions), {}, { external: mergeExternal(inputOptions.external, pluginExternals) });
|
|
506
|
+
},
|
|
507
|
+
outputOptions(outputOptions) {
|
|
508
|
+
if (target === "vite") return null;
|
|
509
|
+
cleanOutputDir(outputOptions, {
|
|
510
|
+
root: resolveRoot(options.root),
|
|
511
|
+
enabled: options.clean !== false,
|
|
512
|
+
cleanedOutputDirs
|
|
513
|
+
});
|
|
514
|
+
if (outputOptions.chunkFileNames) return null;
|
|
515
|
+
return _objectSpread2(_objectSpread2({}, outputOptions), {}, { chunkFileNames: "chunks/[name]-[hash].js" });
|
|
516
|
+
},
|
|
464
517
|
buildStart() {
|
|
465
518
|
var _this = this;
|
|
466
519
|
return _asyncToGenerator(function* () {
|
|
@@ -528,6 +581,14 @@ function createZeusBundlerPlugin(options = {}, createOptions) {
|
|
|
528
581
|
id: resolvedVirtual,
|
|
529
582
|
moduleSideEffects: "no-treeshake"
|
|
530
583
|
};
|
|
584
|
+
const cleanImporter = importer === null || importer === void 0 ? void 0 : importer.replace(/^\x00/, "");
|
|
585
|
+
if ((cleanImporter === null || cleanImporter === void 0 ? void 0 : cleanImporter.startsWith("zeus:")) && (id.startsWith("./") || id.startsWith("../"))) {
|
|
586
|
+
const virtualEntryId = resolveVirtualEntryImport(id, cleanImporter);
|
|
587
|
+
if (virtualEntryId && virtualModules.has(virtualEntryId)) return {
|
|
588
|
+
id: "\0" + virtualEntryId,
|
|
589
|
+
moduleSideEffects: "no-treeshake"
|
|
590
|
+
};
|
|
591
|
+
}
|
|
531
592
|
if (target === "rollup") {
|
|
532
593
|
const resolvedTs = resolveTsLikeImport(id, importer, { extensions: options.resolveExtensions });
|
|
533
594
|
if (resolvedTs) return resolvedTs;
|
|
@@ -580,6 +641,31 @@ function resolveRoot(root) {
|
|
|
580
641
|
if (typeof root === "function") return path.resolve(root());
|
|
581
642
|
return path.resolve(root !== null && root !== void 0 ? root : process.cwd());
|
|
582
643
|
}
|
|
644
|
+
function cleanOutputDir(outputOptions, options) {
|
|
645
|
+
if (!options.enabled) return;
|
|
646
|
+
const outputDir = resolveOutputDir(outputOptions, options.root);
|
|
647
|
+
if (!outputDir || !isSafeCleanTarget(outputDir, options.root)) return;
|
|
648
|
+
if (options.cleanedOutputDirs.has(outputDir)) return;
|
|
649
|
+
options.cleanedOutputDirs.add(outputDir);
|
|
650
|
+
fs.rmSync(outputDir, {
|
|
651
|
+
recursive: true,
|
|
652
|
+
force: true
|
|
653
|
+
});
|
|
654
|
+
}
|
|
655
|
+
function resolveOutputDir(outputOptions, root) {
|
|
656
|
+
const dir = outputOptions.dir;
|
|
657
|
+
if (typeof dir === "string" && dir.length > 0) return path.resolve(root, dir);
|
|
658
|
+
const file = outputOptions.file;
|
|
659
|
+
if (typeof file === "string" && file.length > 0) return path.dirname(path.resolve(root, file));
|
|
660
|
+
return path.resolve(root, "dist");
|
|
661
|
+
}
|
|
662
|
+
function isSafeCleanTarget(outputDir, root) {
|
|
663
|
+
const resolvedRoot = path.resolve(root);
|
|
664
|
+
const resolvedOutputDir = path.resolve(outputDir);
|
|
665
|
+
if (resolvedOutputDir === resolvedRoot) return false;
|
|
666
|
+
const relative = path.relative(resolvedRoot, resolvedOutputDir);
|
|
667
|
+
return Boolean(relative) && !relative.startsWith("..") && !path.isAbsolute(relative);
|
|
668
|
+
}
|
|
583
669
|
function createManifest(_x, _x2, _x3) {
|
|
584
670
|
return _createManifest.apply(this, arguments);
|
|
585
671
|
}
|
|
@@ -672,26 +758,14 @@ function emitVirtualEntries(modules, pluginContext) {
|
|
|
672
758
|
});
|
|
673
759
|
}
|
|
674
760
|
}
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
for (const plugin of (_options$plugins = options.plugins) !== null && _options$plugins !== void 0 ? _options$plugins : []) {
|
|
681
|
-
var _plugin$external;
|
|
682
|
-
for (const dep of (_plugin$external = plugin.external) !== null && _plugin$external !== void 0 ? _plugin$external : []) set.add(dep);
|
|
683
|
-
}
|
|
684
|
-
return Array.from(set);
|
|
685
|
-
}
|
|
686
|
-
function mergeExternal(userExternal, pluginExternal) {
|
|
687
|
-
if (!userExternal) return pluginExternal;
|
|
688
|
-
if (typeof userExternal === "function") return (source, importer, isResolved) => {
|
|
689
|
-
return pluginExternal.includes(source) || userExternal(source, importer, isResolved);
|
|
690
|
-
};
|
|
691
|
-
return [...Array.isArray(userExternal) ? userExternal : [userExternal], ...pluginExternal];
|
|
761
|
+
function resolveVirtualEntryImport(id, importer) {
|
|
762
|
+
const tagName = id.replace(/\.js$/, "").replace(/^\.\//, "").replace(/\.entry$/, "");
|
|
763
|
+
const lastColon = importer.lastIndexOf(":");
|
|
764
|
+
if (lastColon <= 0) return null;
|
|
765
|
+
return `${importer.slice(0, lastColon + 1)}entry:${tagName}`;
|
|
692
766
|
}
|
|
693
767
|
//#endregion
|
|
694
|
-
//#region \0@oxc-project+runtime@0.
|
|
768
|
+
//#region \0@oxc-project+runtime@0.134.0/helpers/esm/objectWithoutPropertiesLoose.js
|
|
695
769
|
function _objectWithoutPropertiesLoose(r, e) {
|
|
696
770
|
if (null == r) return {};
|
|
697
771
|
var t = {};
|
|
@@ -702,7 +776,7 @@ function _objectWithoutPropertiesLoose(r, e) {
|
|
|
702
776
|
return t;
|
|
703
777
|
}
|
|
704
778
|
//#endregion
|
|
705
|
-
//#region \0@oxc-project+runtime@0.
|
|
779
|
+
//#region \0@oxc-project+runtime@0.134.0/helpers/esm/objectWithoutProperties.js
|
|
706
780
|
function _objectWithoutProperties(e, t) {
|
|
707
781
|
if (null == e) return {};
|
|
708
782
|
var o, r, i = _objectWithoutPropertiesLoose(e, t);
|
|
@@ -726,13 +800,14 @@ function zeus(options = {}) {
|
|
|
726
800
|
}
|
|
727
801
|
function defineZeusRollupConfig(config = {}) {
|
|
728
802
|
const { zeus: zeusOptions = {}, plugins, input, output, external } = config, rest = _objectWithoutProperties(config, _excluded);
|
|
729
|
-
const pluginExternals = collectPluginExternals(zeusOptions);
|
|
803
|
+
const pluginExternals = collectPluginExternals(zeusOptions, { includeZeusLibraryExternals: true });
|
|
730
804
|
return _objectSpread2(_objectSpread2({ input: input !== null && input !== void 0 ? input : "src/index.ts" }, rest), {}, {
|
|
731
805
|
external: pluginExternals.length ? mergeExternal(external, pluginExternals) : external,
|
|
732
806
|
plugins: [zeus(zeusOptions), ...normalizePlugins(plugins)],
|
|
733
807
|
output: output !== null && output !== void 0 ? output : {
|
|
734
808
|
dir: "dist",
|
|
735
809
|
format: "es",
|
|
810
|
+
chunkFileNames: "chunks/[name]-[hash].js",
|
|
736
811
|
sourcemap: true
|
|
737
812
|
}
|
|
738
813
|
});
|
package/dist/rollup.prod.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* bundler-plugin v0.1.0-beta.
|
|
2
|
+
* bundler-plugin v0.1.0-beta.3
|
|
3
3
|
* (c) 2026 baicie
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
**/
|
|
@@ -78,7 +78,7 @@ function hasErrorDiagnostics(diagnostics) {
|
|
|
78
78
|
return diagnostics.some((item) => item.level === "error");
|
|
79
79
|
}
|
|
80
80
|
//#endregion
|
|
81
|
-
//#region \0@oxc-project+runtime@0.
|
|
81
|
+
//#region \0@oxc-project+runtime@0.134.0/helpers/esm/asyncToGenerator.js
|
|
82
82
|
function asyncGeneratorStep(n, t, e, r, o, a, c) {
|
|
83
83
|
try {
|
|
84
84
|
var i = n[a](c), u = i.value;
|
|
@@ -104,7 +104,7 @@ function _asyncToGenerator(n) {
|
|
|
104
104
|
};
|
|
105
105
|
}
|
|
106
106
|
//#endregion
|
|
107
|
-
//#region \0@oxc-project+runtime@0.
|
|
107
|
+
//#region \0@oxc-project+runtime@0.134.0/helpers/esm/typeof.js
|
|
108
108
|
function _typeof(o) {
|
|
109
109
|
"@babel/helpers - typeof";
|
|
110
110
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -114,7 +114,7 @@ function _typeof(o) {
|
|
|
114
114
|
}, _typeof(o);
|
|
115
115
|
}
|
|
116
116
|
//#endregion
|
|
117
|
-
//#region \0@oxc-project+runtime@0.
|
|
117
|
+
//#region \0@oxc-project+runtime@0.134.0/helpers/esm/toPrimitive.js
|
|
118
118
|
function toPrimitive(t, r) {
|
|
119
119
|
if ("object" != _typeof(t) || !t) return t;
|
|
120
120
|
var e = t[Symbol.toPrimitive];
|
|
@@ -126,13 +126,13 @@ function toPrimitive(t, r) {
|
|
|
126
126
|
return ("string" === r ? String : Number)(t);
|
|
127
127
|
}
|
|
128
128
|
//#endregion
|
|
129
|
-
//#region \0@oxc-project+runtime@0.
|
|
129
|
+
//#region \0@oxc-project+runtime@0.134.0/helpers/esm/toPropertyKey.js
|
|
130
130
|
function toPropertyKey(t) {
|
|
131
131
|
var i = toPrimitive(t, "string");
|
|
132
132
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
133
133
|
}
|
|
134
134
|
//#endregion
|
|
135
|
-
//#region \0@oxc-project+runtime@0.
|
|
135
|
+
//#region \0@oxc-project+runtime@0.134.0/helpers/esm/defineProperty.js
|
|
136
136
|
function _defineProperty(e, r, t) {
|
|
137
137
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
138
138
|
value: t,
|
|
@@ -142,7 +142,7 @@ function _defineProperty(e, r, t) {
|
|
|
142
142
|
}) : e[r] = t, e;
|
|
143
143
|
}
|
|
144
144
|
//#endregion
|
|
145
|
-
//#region \0@oxc-project+runtime@0.
|
|
145
|
+
//#region \0@oxc-project+runtime@0.134.0/helpers/esm/objectSpread2.js
|
|
146
146
|
function ownKeys(e, r) {
|
|
147
147
|
var t = Object.keys(e);
|
|
148
148
|
if (Object.getOwnPropertySymbols) {
|
|
@@ -272,6 +272,42 @@ function _fileExists() {
|
|
|
272
272
|
return _fileExists.apply(this, arguments);
|
|
273
273
|
}
|
|
274
274
|
//#endregion
|
|
275
|
+
//#region packages/web-c/bundler-plugin/src/external.ts
|
|
276
|
+
const ZEUS_LIBRARY_EXTERNALS = [/^@zeus-js\//];
|
|
277
|
+
function collectPluginExternals(options, collectOptions = {}) {
|
|
278
|
+
var _options$plugins;
|
|
279
|
+
const entries = [];
|
|
280
|
+
if (collectOptions.includeZeusLibraryExternals) entries.push(...ZEUS_LIBRARY_EXTERNALS);
|
|
281
|
+
for (const plugin of (_options$plugins = options.plugins) !== null && _options$plugins !== void 0 ? _options$plugins : []) {
|
|
282
|
+
var _plugin$external;
|
|
283
|
+
for (const dep of (_plugin$external = plugin.external) !== null && _plugin$external !== void 0 ? _plugin$external : []) entries.push(dep);
|
|
284
|
+
}
|
|
285
|
+
return uniqueExternalEntries(entries);
|
|
286
|
+
}
|
|
287
|
+
function mergeExternal(userExternal, pluginExternal) {
|
|
288
|
+
if (!userExternal) return pluginExternal;
|
|
289
|
+
if (typeof userExternal === "function") return (source, importer, isResolved) => {
|
|
290
|
+
return matchesExternal(source, pluginExternal) || userExternal(source, importer, isResolved);
|
|
291
|
+
};
|
|
292
|
+
return uniqueExternalEntries([...Array.isArray(userExternal) ? userExternal : [userExternal], ...pluginExternal]);
|
|
293
|
+
}
|
|
294
|
+
function matchesExternal(source, entries) {
|
|
295
|
+
return entries.some((entry) => {
|
|
296
|
+
return typeof entry === "string" ? entry === source : entry.test(source);
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
function uniqueExternalEntries(entries) {
|
|
300
|
+
const seen = /* @__PURE__ */ new Set();
|
|
301
|
+
const result = [];
|
|
302
|
+
for (const entry of entries) {
|
|
303
|
+
const key = typeof entry === "string" ? `s:${entry}` : `r:${entry.source}/${entry.flags}`;
|
|
304
|
+
if (seen.has(key)) continue;
|
|
305
|
+
seen.add(key);
|
|
306
|
+
result.push(entry);
|
|
307
|
+
}
|
|
308
|
+
return result;
|
|
309
|
+
}
|
|
310
|
+
//#endregion
|
|
275
311
|
//#region packages/web-c/bundler-plugin/src/outputRegistry.ts
|
|
276
312
|
function createOutputRegistry() {
|
|
277
313
|
const map = /* @__PURE__ */ new Map();
|
|
@@ -458,9 +494,26 @@ function createZeusBundlerPlugin(options = {}, createOptions) {
|
|
|
458
494
|
let shouldCompileZeus = (_id) => false;
|
|
459
495
|
let ctx;
|
|
460
496
|
let root = process.cwd();
|
|
497
|
+
const cleanedOutputDirs = /* @__PURE__ */ new Set();
|
|
461
498
|
const virtualModules = new VirtualModuleRegistry();
|
|
462
499
|
return {
|
|
463
500
|
name: resolvePluginName(target),
|
|
501
|
+
options(inputOptions) {
|
|
502
|
+
if (target === "vite") return null;
|
|
503
|
+
const pluginExternals = collectPluginExternals(options, { includeZeusLibraryExternals: true });
|
|
504
|
+
if (!pluginExternals.length) return null;
|
|
505
|
+
return _objectSpread2(_objectSpread2({}, inputOptions), {}, { external: mergeExternal(inputOptions.external, pluginExternals) });
|
|
506
|
+
},
|
|
507
|
+
outputOptions(outputOptions) {
|
|
508
|
+
if (target === "vite") return null;
|
|
509
|
+
cleanOutputDir(outputOptions, {
|
|
510
|
+
root: resolveRoot(options.root),
|
|
511
|
+
enabled: options.clean !== false,
|
|
512
|
+
cleanedOutputDirs
|
|
513
|
+
});
|
|
514
|
+
if (outputOptions.chunkFileNames) return null;
|
|
515
|
+
return _objectSpread2(_objectSpread2({}, outputOptions), {}, { chunkFileNames: "chunks/[name]-[hash].js" });
|
|
516
|
+
},
|
|
464
517
|
buildStart() {
|
|
465
518
|
var _this = this;
|
|
466
519
|
return _asyncToGenerator(function* () {
|
|
@@ -528,6 +581,14 @@ function createZeusBundlerPlugin(options = {}, createOptions) {
|
|
|
528
581
|
id: resolvedVirtual,
|
|
529
582
|
moduleSideEffects: "no-treeshake"
|
|
530
583
|
};
|
|
584
|
+
const cleanImporter = importer === null || importer === void 0 ? void 0 : importer.replace(/^\x00/, "");
|
|
585
|
+
if ((cleanImporter === null || cleanImporter === void 0 ? void 0 : cleanImporter.startsWith("zeus:")) && (id.startsWith("./") || id.startsWith("../"))) {
|
|
586
|
+
const virtualEntryId = resolveVirtualEntryImport(id, cleanImporter);
|
|
587
|
+
if (virtualEntryId && virtualModules.has(virtualEntryId)) return {
|
|
588
|
+
id: "\0" + virtualEntryId,
|
|
589
|
+
moduleSideEffects: "no-treeshake"
|
|
590
|
+
};
|
|
591
|
+
}
|
|
531
592
|
if (target === "rollup") {
|
|
532
593
|
const resolvedTs = resolveTsLikeImport(id, importer, { extensions: options.resolveExtensions });
|
|
533
594
|
if (resolvedTs) return resolvedTs;
|
|
@@ -580,6 +641,31 @@ function resolveRoot(root) {
|
|
|
580
641
|
if (typeof root === "function") return path.resolve(root());
|
|
581
642
|
return path.resolve(root !== null && root !== void 0 ? root : process.cwd());
|
|
582
643
|
}
|
|
644
|
+
function cleanOutputDir(outputOptions, options) {
|
|
645
|
+
if (!options.enabled) return;
|
|
646
|
+
const outputDir = resolveOutputDir(outputOptions, options.root);
|
|
647
|
+
if (!outputDir || !isSafeCleanTarget(outputDir, options.root)) return;
|
|
648
|
+
if (options.cleanedOutputDirs.has(outputDir)) return;
|
|
649
|
+
options.cleanedOutputDirs.add(outputDir);
|
|
650
|
+
fs.rmSync(outputDir, {
|
|
651
|
+
recursive: true,
|
|
652
|
+
force: true
|
|
653
|
+
});
|
|
654
|
+
}
|
|
655
|
+
function resolveOutputDir(outputOptions, root) {
|
|
656
|
+
const dir = outputOptions.dir;
|
|
657
|
+
if (typeof dir === "string" && dir.length > 0) return path.resolve(root, dir);
|
|
658
|
+
const file = outputOptions.file;
|
|
659
|
+
if (typeof file === "string" && file.length > 0) return path.dirname(path.resolve(root, file));
|
|
660
|
+
return path.resolve(root, "dist");
|
|
661
|
+
}
|
|
662
|
+
function isSafeCleanTarget(outputDir, root) {
|
|
663
|
+
const resolvedRoot = path.resolve(root);
|
|
664
|
+
const resolvedOutputDir = path.resolve(outputDir);
|
|
665
|
+
if (resolvedOutputDir === resolvedRoot) return false;
|
|
666
|
+
const relative = path.relative(resolvedRoot, resolvedOutputDir);
|
|
667
|
+
return Boolean(relative) && !relative.startsWith("..") && !path.isAbsolute(relative);
|
|
668
|
+
}
|
|
583
669
|
function createManifest(_x, _x2, _x3) {
|
|
584
670
|
return _createManifest.apply(this, arguments);
|
|
585
671
|
}
|
|
@@ -672,26 +758,14 @@ function emitVirtualEntries(modules, pluginContext) {
|
|
|
672
758
|
});
|
|
673
759
|
}
|
|
674
760
|
}
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
for (const plugin of (_options$plugins = options.plugins) !== null && _options$plugins !== void 0 ? _options$plugins : []) {
|
|
681
|
-
var _plugin$external;
|
|
682
|
-
for (const dep of (_plugin$external = plugin.external) !== null && _plugin$external !== void 0 ? _plugin$external : []) set.add(dep);
|
|
683
|
-
}
|
|
684
|
-
return Array.from(set);
|
|
685
|
-
}
|
|
686
|
-
function mergeExternal(userExternal, pluginExternal) {
|
|
687
|
-
if (!userExternal) return pluginExternal;
|
|
688
|
-
if (typeof userExternal === "function") return (source, importer, isResolved) => {
|
|
689
|
-
return pluginExternal.includes(source) || userExternal(source, importer, isResolved);
|
|
690
|
-
};
|
|
691
|
-
return [...Array.isArray(userExternal) ? userExternal : [userExternal], ...pluginExternal];
|
|
761
|
+
function resolveVirtualEntryImport(id, importer) {
|
|
762
|
+
const tagName = id.replace(/\.js$/, "").replace(/^\.\//, "").replace(/\.entry$/, "");
|
|
763
|
+
const lastColon = importer.lastIndexOf(":");
|
|
764
|
+
if (lastColon <= 0) return null;
|
|
765
|
+
return `${importer.slice(0, lastColon + 1)}entry:${tagName}`;
|
|
692
766
|
}
|
|
693
767
|
//#endregion
|
|
694
|
-
//#region \0@oxc-project+runtime@0.
|
|
768
|
+
//#region \0@oxc-project+runtime@0.134.0/helpers/esm/objectWithoutPropertiesLoose.js
|
|
695
769
|
function _objectWithoutPropertiesLoose(r, e) {
|
|
696
770
|
if (null == r) return {};
|
|
697
771
|
var t = {};
|
|
@@ -702,7 +776,7 @@ function _objectWithoutPropertiesLoose(r, e) {
|
|
|
702
776
|
return t;
|
|
703
777
|
}
|
|
704
778
|
//#endregion
|
|
705
|
-
//#region \0@oxc-project+runtime@0.
|
|
779
|
+
//#region \0@oxc-project+runtime@0.134.0/helpers/esm/objectWithoutProperties.js
|
|
706
780
|
function _objectWithoutProperties(e, t) {
|
|
707
781
|
if (null == e) return {};
|
|
708
782
|
var o, r, i = _objectWithoutPropertiesLoose(e, t);
|
|
@@ -726,13 +800,14 @@ function zeus(options = {}) {
|
|
|
726
800
|
}
|
|
727
801
|
function defineZeusRollupConfig(config = {}) {
|
|
728
802
|
const { zeus: zeusOptions = {}, plugins, input, output, external } = config, rest = _objectWithoutProperties(config, _excluded);
|
|
729
|
-
const pluginExternals = collectPluginExternals(zeusOptions);
|
|
803
|
+
const pluginExternals = collectPluginExternals(zeusOptions, { includeZeusLibraryExternals: true });
|
|
730
804
|
return _objectSpread2(_objectSpread2({ input: input !== null && input !== void 0 ? input : "src/index.ts" }, rest), {}, {
|
|
731
805
|
external: pluginExternals.length ? mergeExternal(external, pluginExternals) : external,
|
|
732
806
|
plugins: [zeus(zeusOptions), ...normalizePlugins(plugins)],
|
|
733
807
|
output: output !== null && output !== void 0 ? output : {
|
|
734
808
|
dir: "dist",
|
|
735
809
|
format: "es",
|
|
810
|
+
chunkFileNames: "chunks/[name]-[hash].js",
|
|
736
811
|
sourcemap: true
|
|
737
812
|
}
|
|
738
813
|
});
|
package/dist/vite.cjs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* bundler-plugin v0.1.0-beta.
|
|
2
|
+
* bundler-plugin v0.1.0-beta.3
|
|
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,32 @@ 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
|
+
if (!pluginExternals.length) return null;
|
|
417
|
+
return {
|
|
418
|
+
...inputOptions,
|
|
419
|
+
external: mergeExternal(inputOptions.external, pluginExternals)
|
|
420
|
+
};
|
|
421
|
+
},
|
|
422
|
+
outputOptions(outputOptions) {
|
|
423
|
+
if (target === "vite") return null;
|
|
424
|
+
cleanOutputDir(outputOptions, {
|
|
425
|
+
root: resolveRoot(options.root),
|
|
426
|
+
enabled: options.clean !== false,
|
|
427
|
+
cleanedOutputDirs
|
|
428
|
+
});
|
|
429
|
+
if (outputOptions.chunkFileNames) return null;
|
|
430
|
+
return {
|
|
431
|
+
...outputOptions,
|
|
432
|
+
chunkFileNames: "chunks/[name]-[hash].js"
|
|
433
|
+
};
|
|
434
|
+
},
|
|
376
435
|
async buildStart() {
|
|
377
436
|
var _options$components, _options$components2, _options$transform, _options$transform2, _options$plugins;
|
|
378
437
|
virtualModules.clear();
|
|
@@ -437,6 +496,14 @@ function createZeusBundlerPlugin(options = {}, createOptions) {
|
|
|
437
496
|
id: resolvedVirtual,
|
|
438
497
|
moduleSideEffects: "no-treeshake"
|
|
439
498
|
};
|
|
499
|
+
const cleanImporter = importer === null || importer === void 0 ? void 0 : importer.replace(/^\x00/, "");
|
|
500
|
+
if ((cleanImporter === null || cleanImporter === void 0 ? void 0 : cleanImporter.startsWith("zeus:")) && (id.startsWith("./") || id.startsWith("../"))) {
|
|
501
|
+
const virtualEntryId = resolveVirtualEntryImport(id, cleanImporter);
|
|
502
|
+
if (virtualEntryId && virtualModules.has(virtualEntryId)) return {
|
|
503
|
+
id: "\0" + virtualEntryId,
|
|
504
|
+
moduleSideEffects: "no-treeshake"
|
|
505
|
+
};
|
|
506
|
+
}
|
|
440
507
|
if (target === "rollup") {
|
|
441
508
|
const resolvedTs = resolveTsLikeImport(id, importer, { extensions: options.resolveExtensions });
|
|
442
509
|
if (resolvedTs) return resolvedTs;
|
|
@@ -484,6 +551,31 @@ function resolveRoot(root) {
|
|
|
484
551
|
if (typeof root === "function") return node_path.default.resolve(root());
|
|
485
552
|
return node_path.default.resolve(root !== null && root !== void 0 ? root : process.cwd());
|
|
486
553
|
}
|
|
554
|
+
function cleanOutputDir(outputOptions, options) {
|
|
555
|
+
if (!options.enabled) return;
|
|
556
|
+
const outputDir = resolveOutputDir(outputOptions, options.root);
|
|
557
|
+
if (!outputDir || !isSafeCleanTarget(outputDir, options.root)) return;
|
|
558
|
+
if (options.cleanedOutputDirs.has(outputDir)) return;
|
|
559
|
+
options.cleanedOutputDirs.add(outputDir);
|
|
560
|
+
node_fs.default.rmSync(outputDir, {
|
|
561
|
+
recursive: true,
|
|
562
|
+
force: true
|
|
563
|
+
});
|
|
564
|
+
}
|
|
565
|
+
function resolveOutputDir(outputOptions, root) {
|
|
566
|
+
const dir = outputOptions.dir;
|
|
567
|
+
if (typeof dir === "string" && dir.length > 0) return node_path.default.resolve(root, dir);
|
|
568
|
+
const file = outputOptions.file;
|
|
569
|
+
if (typeof file === "string" && file.length > 0) return node_path.default.dirname(node_path.default.resolve(root, file));
|
|
570
|
+
return node_path.default.resolve(root, "dist");
|
|
571
|
+
}
|
|
572
|
+
function isSafeCleanTarget(outputDir, root) {
|
|
573
|
+
const resolvedRoot = node_path.default.resolve(root);
|
|
574
|
+
const resolvedOutputDir = node_path.default.resolve(outputDir);
|
|
575
|
+
if (resolvedOutputDir === resolvedRoot) return false;
|
|
576
|
+
const relative = node_path.default.relative(resolvedRoot, resolvedOutputDir);
|
|
577
|
+
return Boolean(relative) && !relative.startsWith("..") && !node_path.default.isAbsolute(relative);
|
|
578
|
+
}
|
|
487
579
|
async function createManifest(root, include, exclude) {
|
|
488
580
|
if (!include.length) return {
|
|
489
581
|
manifest: {
|
|
@@ -564,23 +656,11 @@ function emitVirtualEntries(modules, pluginContext) {
|
|
|
564
656
|
});
|
|
565
657
|
}
|
|
566
658
|
}
|
|
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];
|
|
659
|
+
function resolveVirtualEntryImport(id, importer) {
|
|
660
|
+
const tagName = id.replace(/\.js$/, "").replace(/^\.\//, "").replace(/\.entry$/, "");
|
|
661
|
+
const lastColon = importer.lastIndexOf(":");
|
|
662
|
+
if (lastColon <= 0) return null;
|
|
663
|
+
return `${importer.slice(0, lastColon + 1)}entry:${tagName}`;
|
|
584
664
|
}
|
|
585
665
|
//#endregion
|
|
586
666
|
//#region packages/web-c/bundler-plugin/src/vite.ts
|