@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
|
@@ -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
|
**/
|
|
@@ -187,6 +187,42 @@ async function fileExists(file) {
|
|
|
187
187
|
}
|
|
188
188
|
}
|
|
189
189
|
//#endregion
|
|
190
|
+
//#region packages/web-c/bundler-plugin/src/external.ts
|
|
191
|
+
const ZEUS_LIBRARY_EXTERNALS = [/^@zeus-js\//];
|
|
192
|
+
function collectPluginExternals(options, collectOptions = {}) {
|
|
193
|
+
var _options$plugins;
|
|
194
|
+
const entries = [];
|
|
195
|
+
if (collectOptions.includeZeusLibraryExternals) entries.push(...ZEUS_LIBRARY_EXTERNALS);
|
|
196
|
+
for (const plugin of (_options$plugins = options.plugins) !== null && _options$plugins !== void 0 ? _options$plugins : []) {
|
|
197
|
+
var _plugin$external;
|
|
198
|
+
for (const dep of (_plugin$external = plugin.external) !== null && _plugin$external !== void 0 ? _plugin$external : []) entries.push(dep);
|
|
199
|
+
}
|
|
200
|
+
return uniqueExternalEntries(entries);
|
|
201
|
+
}
|
|
202
|
+
function mergeExternal(userExternal, pluginExternal) {
|
|
203
|
+
if (!userExternal) return pluginExternal;
|
|
204
|
+
if (typeof userExternal === "function") return (source, importer, isResolved) => {
|
|
205
|
+
return matchesExternal(source, pluginExternal) || userExternal(source, importer, isResolved);
|
|
206
|
+
};
|
|
207
|
+
return uniqueExternalEntries([...Array.isArray(userExternal) ? userExternal : [userExternal], ...pluginExternal]);
|
|
208
|
+
}
|
|
209
|
+
function matchesExternal(source, entries) {
|
|
210
|
+
return entries.some((entry) => {
|
|
211
|
+
return typeof entry === "string" ? entry === source : entry.test(source);
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
function uniqueExternalEntries(entries) {
|
|
215
|
+
const seen = /* @__PURE__ */ new Set();
|
|
216
|
+
const result = [];
|
|
217
|
+
for (const entry of entries) {
|
|
218
|
+
const key = typeof entry === "string" ? `s:${entry}` : `r:${entry.source}/${entry.flags}`;
|
|
219
|
+
if (seen.has(key)) continue;
|
|
220
|
+
seen.add(key);
|
|
221
|
+
result.push(entry);
|
|
222
|
+
}
|
|
223
|
+
return result;
|
|
224
|
+
}
|
|
225
|
+
//#endregion
|
|
190
226
|
//#region packages/web-c/bundler-plugin/src/outputRegistry.ts
|
|
191
227
|
function createOutputRegistry() {
|
|
192
228
|
const map = /* @__PURE__ */ new Map();
|
|
@@ -368,9 +404,32 @@ function createZeusBundlerPlugin(options = {}, createOptions) {
|
|
|
368
404
|
let shouldCompileZeus = (_id) => false;
|
|
369
405
|
let ctx;
|
|
370
406
|
let root = process.cwd();
|
|
407
|
+
const cleanedOutputDirs = /* @__PURE__ */ new Set();
|
|
371
408
|
const virtualModules = new VirtualModuleRegistry();
|
|
372
409
|
return {
|
|
373
410
|
name: resolvePluginName(target),
|
|
411
|
+
options(inputOptions) {
|
|
412
|
+
if (target === "vite") return null;
|
|
413
|
+
const pluginExternals = collectPluginExternals(options, { includeZeusLibraryExternals: true });
|
|
414
|
+
if (!pluginExternals.length) return null;
|
|
415
|
+
return {
|
|
416
|
+
...inputOptions,
|
|
417
|
+
external: mergeExternal(inputOptions.external, pluginExternals)
|
|
418
|
+
};
|
|
419
|
+
},
|
|
420
|
+
outputOptions(outputOptions) {
|
|
421
|
+
if (target === "vite") return null;
|
|
422
|
+
cleanOutputDir(outputOptions, {
|
|
423
|
+
root: resolveRoot(options.root),
|
|
424
|
+
enabled: options.clean !== false,
|
|
425
|
+
cleanedOutputDirs
|
|
426
|
+
});
|
|
427
|
+
if (outputOptions.chunkFileNames) return null;
|
|
428
|
+
return {
|
|
429
|
+
...outputOptions,
|
|
430
|
+
chunkFileNames: "chunks/[name]-[hash].js"
|
|
431
|
+
};
|
|
432
|
+
},
|
|
374
433
|
async buildStart() {
|
|
375
434
|
var _options$components, _options$components2, _options$transform, _options$transform2, _options$plugins;
|
|
376
435
|
virtualModules.clear();
|
|
@@ -435,6 +494,14 @@ function createZeusBundlerPlugin(options = {}, createOptions) {
|
|
|
435
494
|
id: resolvedVirtual,
|
|
436
495
|
moduleSideEffects: "no-treeshake"
|
|
437
496
|
};
|
|
497
|
+
const cleanImporter = importer === null || importer === void 0 ? void 0 : importer.replace(/^\x00/, "");
|
|
498
|
+
if ((cleanImporter === null || cleanImporter === void 0 ? void 0 : cleanImporter.startsWith("zeus:")) && (id.startsWith("./") || id.startsWith("../"))) {
|
|
499
|
+
const virtualEntryId = resolveVirtualEntryImport(id, cleanImporter);
|
|
500
|
+
if (virtualEntryId && virtualModules.has(virtualEntryId)) return {
|
|
501
|
+
id: "\0" + virtualEntryId,
|
|
502
|
+
moduleSideEffects: "no-treeshake"
|
|
503
|
+
};
|
|
504
|
+
}
|
|
438
505
|
if (target === "rollup") {
|
|
439
506
|
const resolvedTs = resolveTsLikeImport(id, importer, { extensions: options.resolveExtensions });
|
|
440
507
|
if (resolvedTs) return resolvedTs;
|
|
@@ -482,6 +549,31 @@ function resolveRoot(root) {
|
|
|
482
549
|
if (typeof root === "function") return node_path.default.resolve(root());
|
|
483
550
|
return node_path.default.resolve(root !== null && root !== void 0 ? root : process.cwd());
|
|
484
551
|
}
|
|
552
|
+
function cleanOutputDir(outputOptions, options) {
|
|
553
|
+
if (!options.enabled) return;
|
|
554
|
+
const outputDir = resolveOutputDir(outputOptions, options.root);
|
|
555
|
+
if (!outputDir || !isSafeCleanTarget(outputDir, options.root)) return;
|
|
556
|
+
if (options.cleanedOutputDirs.has(outputDir)) return;
|
|
557
|
+
options.cleanedOutputDirs.add(outputDir);
|
|
558
|
+
node_fs.default.rmSync(outputDir, {
|
|
559
|
+
recursive: true,
|
|
560
|
+
force: true
|
|
561
|
+
});
|
|
562
|
+
}
|
|
563
|
+
function resolveOutputDir(outputOptions, root) {
|
|
564
|
+
const dir = outputOptions.dir;
|
|
565
|
+
if (typeof dir === "string" && dir.length > 0) return node_path.default.resolve(root, dir);
|
|
566
|
+
const file = outputOptions.file;
|
|
567
|
+
if (typeof file === "string" && file.length > 0) return node_path.default.dirname(node_path.default.resolve(root, file));
|
|
568
|
+
return node_path.default.resolve(root, "dist");
|
|
569
|
+
}
|
|
570
|
+
function isSafeCleanTarget(outputDir, root) {
|
|
571
|
+
const resolvedRoot = node_path.default.resolve(root);
|
|
572
|
+
const resolvedOutputDir = node_path.default.resolve(outputDir);
|
|
573
|
+
if (resolvedOutputDir === resolvedRoot) return false;
|
|
574
|
+
const relative = node_path.default.relative(resolvedRoot, resolvedOutputDir);
|
|
575
|
+
return Boolean(relative) && !relative.startsWith("..") && !node_path.default.isAbsolute(relative);
|
|
576
|
+
}
|
|
485
577
|
async function createManifest(root, include, exclude) {
|
|
486
578
|
if (!include.length) return {
|
|
487
579
|
manifest: {
|
|
@@ -562,14 +654,11 @@ function emitVirtualEntries(modules, pluginContext) {
|
|
|
562
654
|
});
|
|
563
655
|
}
|
|
564
656
|
}
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
if (
|
|
569
|
-
|
|
570
|
-
return pluginExternal.includes(source) || userExternal(source, importer, isResolved);
|
|
571
|
-
};
|
|
572
|
-
return [...Array.isArray(userExternal) ? userExternal : [userExternal], ...pluginExternal];
|
|
657
|
+
function resolveVirtualEntryImport(id, importer) {
|
|
658
|
+
const tagName = id.replace(/\.js$/, "").replace(/^\.\//, "").replace(/\.entry$/, "");
|
|
659
|
+
const lastColon = importer.lastIndexOf(":");
|
|
660
|
+
if (lastColon <= 0) return null;
|
|
661
|
+
return `${importer.slice(0, lastColon + 1)}entry:${tagName}`;
|
|
573
662
|
}
|
|
574
663
|
//#endregion
|
|
575
664
|
//#region packages/web-c/bundler-plugin/src/rollup.ts
|
|
@@ -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
|
**/
|
|
@@ -187,6 +187,42 @@ async function fileExists(file) {
|
|
|
187
187
|
}
|
|
188
188
|
}
|
|
189
189
|
//#endregion
|
|
190
|
+
//#region packages/web-c/bundler-plugin/src/external.ts
|
|
191
|
+
const ZEUS_LIBRARY_EXTERNALS = [/^@zeus-js\//];
|
|
192
|
+
function collectPluginExternals(options, collectOptions = {}) {
|
|
193
|
+
var _options$plugins;
|
|
194
|
+
const entries = [];
|
|
195
|
+
if (collectOptions.includeZeusLibraryExternals) entries.push(...ZEUS_LIBRARY_EXTERNALS);
|
|
196
|
+
for (const plugin of (_options$plugins = options.plugins) !== null && _options$plugins !== void 0 ? _options$plugins : []) {
|
|
197
|
+
var _plugin$external;
|
|
198
|
+
for (const dep of (_plugin$external = plugin.external) !== null && _plugin$external !== void 0 ? _plugin$external : []) entries.push(dep);
|
|
199
|
+
}
|
|
200
|
+
return uniqueExternalEntries(entries);
|
|
201
|
+
}
|
|
202
|
+
function mergeExternal(userExternal, pluginExternal) {
|
|
203
|
+
if (!userExternal) return pluginExternal;
|
|
204
|
+
if (typeof userExternal === "function") return (source, importer, isResolved) => {
|
|
205
|
+
return matchesExternal(source, pluginExternal) || userExternal(source, importer, isResolved);
|
|
206
|
+
};
|
|
207
|
+
return uniqueExternalEntries([...Array.isArray(userExternal) ? userExternal : [userExternal], ...pluginExternal]);
|
|
208
|
+
}
|
|
209
|
+
function matchesExternal(source, entries) {
|
|
210
|
+
return entries.some((entry) => {
|
|
211
|
+
return typeof entry === "string" ? entry === source : entry.test(source);
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
function uniqueExternalEntries(entries) {
|
|
215
|
+
const seen = /* @__PURE__ */ new Set();
|
|
216
|
+
const result = [];
|
|
217
|
+
for (const entry of entries) {
|
|
218
|
+
const key = typeof entry === "string" ? `s:${entry}` : `r:${entry.source}/${entry.flags}`;
|
|
219
|
+
if (seen.has(key)) continue;
|
|
220
|
+
seen.add(key);
|
|
221
|
+
result.push(entry);
|
|
222
|
+
}
|
|
223
|
+
return result;
|
|
224
|
+
}
|
|
225
|
+
//#endregion
|
|
190
226
|
//#region packages/web-c/bundler-plugin/src/outputRegistry.ts
|
|
191
227
|
function createOutputRegistry() {
|
|
192
228
|
const map = /* @__PURE__ */ new Map();
|
|
@@ -368,9 +404,32 @@ function createZeusBundlerPlugin(options = {}, createOptions) {
|
|
|
368
404
|
let shouldCompileZeus = (_id) => false;
|
|
369
405
|
let ctx;
|
|
370
406
|
let root = process.cwd();
|
|
407
|
+
const cleanedOutputDirs = /* @__PURE__ */ new Set();
|
|
371
408
|
const virtualModules = new VirtualModuleRegistry();
|
|
372
409
|
return {
|
|
373
410
|
name: resolvePluginName(target),
|
|
411
|
+
options(inputOptions) {
|
|
412
|
+
if (target === "vite") return null;
|
|
413
|
+
const pluginExternals = collectPluginExternals(options, { includeZeusLibraryExternals: true });
|
|
414
|
+
if (!pluginExternals.length) return null;
|
|
415
|
+
return {
|
|
416
|
+
...inputOptions,
|
|
417
|
+
external: mergeExternal(inputOptions.external, pluginExternals)
|
|
418
|
+
};
|
|
419
|
+
},
|
|
420
|
+
outputOptions(outputOptions) {
|
|
421
|
+
if (target === "vite") return null;
|
|
422
|
+
cleanOutputDir(outputOptions, {
|
|
423
|
+
root: resolveRoot(options.root),
|
|
424
|
+
enabled: options.clean !== false,
|
|
425
|
+
cleanedOutputDirs
|
|
426
|
+
});
|
|
427
|
+
if (outputOptions.chunkFileNames) return null;
|
|
428
|
+
return {
|
|
429
|
+
...outputOptions,
|
|
430
|
+
chunkFileNames: "chunks/[name]-[hash].js"
|
|
431
|
+
};
|
|
432
|
+
},
|
|
374
433
|
async buildStart() {
|
|
375
434
|
var _options$components, _options$components2, _options$transform, _options$transform2, _options$plugins;
|
|
376
435
|
virtualModules.clear();
|
|
@@ -435,6 +494,14 @@ function createZeusBundlerPlugin(options = {}, createOptions) {
|
|
|
435
494
|
id: resolvedVirtual,
|
|
436
495
|
moduleSideEffects: "no-treeshake"
|
|
437
496
|
};
|
|
497
|
+
const cleanImporter = importer === null || importer === void 0 ? void 0 : importer.replace(/^\x00/, "");
|
|
498
|
+
if ((cleanImporter === null || cleanImporter === void 0 ? void 0 : cleanImporter.startsWith("zeus:")) && (id.startsWith("./") || id.startsWith("../"))) {
|
|
499
|
+
const virtualEntryId = resolveVirtualEntryImport(id, cleanImporter);
|
|
500
|
+
if (virtualEntryId && virtualModules.has(virtualEntryId)) return {
|
|
501
|
+
id: "\0" + virtualEntryId,
|
|
502
|
+
moduleSideEffects: "no-treeshake"
|
|
503
|
+
};
|
|
504
|
+
}
|
|
438
505
|
if (target === "rollup") {
|
|
439
506
|
const resolvedTs = resolveTsLikeImport(id, importer, { extensions: options.resolveExtensions });
|
|
440
507
|
if (resolvedTs) return resolvedTs;
|
|
@@ -482,6 +549,31 @@ function resolveRoot(root) {
|
|
|
482
549
|
if (typeof root === "function") return node_path.default.resolve(root());
|
|
483
550
|
return node_path.default.resolve(root !== null && root !== void 0 ? root : process.cwd());
|
|
484
551
|
}
|
|
552
|
+
function cleanOutputDir(outputOptions, options) {
|
|
553
|
+
if (!options.enabled) return;
|
|
554
|
+
const outputDir = resolveOutputDir(outputOptions, options.root);
|
|
555
|
+
if (!outputDir || !isSafeCleanTarget(outputDir, options.root)) return;
|
|
556
|
+
if (options.cleanedOutputDirs.has(outputDir)) return;
|
|
557
|
+
options.cleanedOutputDirs.add(outputDir);
|
|
558
|
+
node_fs.default.rmSync(outputDir, {
|
|
559
|
+
recursive: true,
|
|
560
|
+
force: true
|
|
561
|
+
});
|
|
562
|
+
}
|
|
563
|
+
function resolveOutputDir(outputOptions, root) {
|
|
564
|
+
const dir = outputOptions.dir;
|
|
565
|
+
if (typeof dir === "string" && dir.length > 0) return node_path.default.resolve(root, dir);
|
|
566
|
+
const file = outputOptions.file;
|
|
567
|
+
if (typeof file === "string" && file.length > 0) return node_path.default.dirname(node_path.default.resolve(root, file));
|
|
568
|
+
return node_path.default.resolve(root, "dist");
|
|
569
|
+
}
|
|
570
|
+
function isSafeCleanTarget(outputDir, root) {
|
|
571
|
+
const resolvedRoot = node_path.default.resolve(root);
|
|
572
|
+
const resolvedOutputDir = node_path.default.resolve(outputDir);
|
|
573
|
+
if (resolvedOutputDir === resolvedRoot) return false;
|
|
574
|
+
const relative = node_path.default.relative(resolvedRoot, resolvedOutputDir);
|
|
575
|
+
return Boolean(relative) && !relative.startsWith("..") && !node_path.default.isAbsolute(relative);
|
|
576
|
+
}
|
|
485
577
|
async function createManifest(root, include, exclude) {
|
|
486
578
|
if (!include.length) return {
|
|
487
579
|
manifest: {
|
|
@@ -562,14 +654,11 @@ function emitVirtualEntries(modules, pluginContext) {
|
|
|
562
654
|
});
|
|
563
655
|
}
|
|
564
656
|
}
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
if (
|
|
569
|
-
|
|
570
|
-
return pluginExternal.includes(source) || userExternal(source, importer, isResolved);
|
|
571
|
-
};
|
|
572
|
-
return [...Array.isArray(userExternal) ? userExternal : [userExternal], ...pluginExternal];
|
|
657
|
+
function resolveVirtualEntryImport(id, importer) {
|
|
658
|
+
const tagName = id.replace(/\.js$/, "").replace(/^\.\//, "").replace(/\.entry$/, "");
|
|
659
|
+
const lastColon = importer.lastIndexOf(":");
|
|
660
|
+
if (lastColon <= 0) return null;
|
|
661
|
+
return `${importer.slice(0, lastColon + 1)}entry:${tagName}`;
|
|
573
662
|
}
|
|
574
663
|
//#endregion
|
|
575
664
|
//#region packages/web-c/bundler-plugin/src/rollup.ts
|
package/dist/bundler-plugin.d.ts
CHANGED
|
@@ -79,7 +79,7 @@ export interface ZeusComponentPlugin {
|
|
|
79
79
|
* Used by the Vite adapter, defineZeusRollupConfig(), and
|
|
80
80
|
* defineZeusRolldownConfig().
|
|
81
81
|
*/
|
|
82
|
-
external?: string
|
|
82
|
+
external?: Array<string | RegExp>;
|
|
83
83
|
}
|
|
84
84
|
export interface ZeusBundlerPluginOptions {
|
|
85
85
|
/**
|
|
@@ -137,6 +137,14 @@ export interface ZeusBundlerPluginOptions {
|
|
|
137
137
|
* - vite: false
|
|
138
138
|
*/
|
|
139
139
|
transpile?: boolean;
|
|
140
|
+
/**
|
|
141
|
+
* Clean the resolved Rollup/Rolldown output directory before writing.
|
|
142
|
+
*
|
|
143
|
+
* Vite keeps using its own emptyOutDir behavior.
|
|
144
|
+
*
|
|
145
|
+
* @default true
|
|
146
|
+
*/
|
|
147
|
+
clean?: boolean;
|
|
140
148
|
/**
|
|
141
149
|
* Rollup adapter only. Additional extensions to try when resolving imports.
|
|
142
150
|
* Set to `false` to disable extension resolution.
|
|
@@ -155,6 +163,7 @@ export declare function resolveComponentExclude(exclude?: string[]): string[];
|
|
|
155
163
|
|
|
156
164
|
export declare function resolvePluginDts(value: DtsMode | undefined, ctx: ZeusBuildContext): boolean;
|
|
157
165
|
|
|
158
|
-
|
|
166
|
+
type ZeusExternalEntry = string | RegExp;
|
|
167
|
+
export declare function mergeExternal(userExternal: RollupExternalOption | undefined, pluginExternal: ZeusExternalEntry[]): RollupExternalOption;
|
|
159
168
|
|
|
160
169
|
export { zeus as default, };
|
|
@@ -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,14 +758,11 @@ function emitVirtualEntries(modules, pluginContext) {
|
|
|
672
758
|
});
|
|
673
759
|
}
|
|
674
760
|
}
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
if (
|
|
679
|
-
|
|
680
|
-
return pluginExternal.includes(source) || userExternal(source, importer, isResolved);
|
|
681
|
-
};
|
|
682
|
-
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}`;
|
|
683
766
|
}
|
|
684
767
|
//#endregion
|
|
685
768
|
//#region packages/web-c/bundler-plugin/src/rollup.ts
|