@zeus-js/bundler-plugin 0.1.1-beta.0 → 0.1.1-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundler-plugin.cjs +74 -34
- package/dist/bundler-plugin.d.ts +7 -3
- package/dist/bundler-plugin.esm-bundler.js +73 -31
- package/dist/bundler-plugin.prod.cjs +74 -34
- package/dist/outputPlugins/manifest.cjs +1 -1
- package/dist/outputPlugins/manifest.js +1 -1
- package/dist/outputPlugins/manifest.prod.cjs +1 -1
- package/dist/outputPlugins/manifest.prod.js +1 -1
- package/dist/rolldown.cjs +75 -34
- package/dist/rolldown.d.ts +7 -3
- package/dist/rolldown.js +74 -31
- package/dist/rolldown.prod.cjs +75 -34
- package/dist/rolldown.prod.js +74 -31
- package/dist/rollup.cjs +75 -34
- package/dist/rollup.d.ts +7 -3
- package/dist/rollup.js +74 -31
- package/dist/rollup.prod.cjs +75 -34
- package/dist/rollup.prod.js +74 -31
- package/dist/vite.cjs +74 -34
- package/dist/vite.d.ts +7 -3
- package/dist/vite.js +73 -31
- package/dist/vite.prod.cjs +74 -34
- package/dist/vite.prod.js +73 -31
- package/package.json +7 -6
package/dist/bundler-plugin.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* bundler-plugin v0.1.1-beta.
|
|
2
|
+
* bundler-plugin v0.1.1-beta.2
|
|
3
3
|
* (c) 2026 baicie
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
**/
|
|
@@ -40,11 +40,10 @@ let node_fs_promises = require("node:fs/promises");
|
|
|
40
40
|
node_fs_promises = __toESM(node_fs_promises, 1);
|
|
41
41
|
let fast_glob = require("fast-glob");
|
|
42
42
|
fast_glob = __toESM(fast_glob, 1);
|
|
43
|
-
let
|
|
44
|
-
let
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
_zeus_js_compiler = __toESM(_zeus_js_compiler, 1);
|
|
43
|
+
let _jridgewell_gen_mapping = require("@jridgewell/gen-mapping");
|
|
44
|
+
let _jridgewell_trace_mapping = require("@jridgewell/trace-mapping");
|
|
45
|
+
let typescript = require("typescript");
|
|
46
|
+
typescript = __toESM(typescript, 1);
|
|
48
47
|
let node_module = require("node:module");
|
|
49
48
|
let vite = require("vite");
|
|
50
49
|
//#region packages/web-c/bundler-plugin/src/filter.ts
|
|
@@ -276,6 +275,7 @@ function normalizeTagName(tag, stripPrefix) {
|
|
|
276
275
|
if (stripPrefix && tag.startsWith(stripPrefix)) return tag.slice(stripPrefix.length);
|
|
277
276
|
return tag;
|
|
278
277
|
}
|
|
278
|
+
const { transformModule } = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href)("@zeus-js/compiler-native");
|
|
279
279
|
//#endregion
|
|
280
280
|
//#region packages/web-c/bundler-plugin/src/transform.ts
|
|
281
281
|
async function transformZeus(options) {
|
|
@@ -285,39 +285,79 @@ async function transformZeus(options) {
|
|
|
285
285
|
const shouldRunCompiler = compiler !== false;
|
|
286
286
|
const shouldStripTs = transpile && isTs;
|
|
287
287
|
if (!shouldRunCompiler && !shouldStripTs) return null;
|
|
288
|
-
const compilerOptions = compiler === false ? {} : compiler
|
|
289
|
-
|
|
288
|
+
const compilerOptions = compiler === false ? {} : compiler !== null && compiler !== void 0 ? compiler : {};
|
|
289
|
+
let transformedCode = code;
|
|
290
|
+
let map = null;
|
|
290
291
|
if (shouldRunCompiler) {
|
|
291
|
-
var _compilerOptions$modu;
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
292
|
+
var _compilerOptions$modu, _compilerOptions$dele;
|
|
293
|
+
const result = transformModule({
|
|
294
|
+
source: code,
|
|
295
|
+
filename,
|
|
296
|
+
target: "dom",
|
|
297
|
+
runtimeModule: (_compilerOptions$modu = compilerOptions.moduleName) !== null && _compilerOptions$modu !== void 0 ? _compilerOptions$modu : "@zeus-js/runtime-dom",
|
|
298
|
+
delegateEvents: (_compilerOptions$dele = compilerOptions.delegateEvents) !== null && _compilerOptions$dele !== void 0 ? _compilerOptions$dele : true,
|
|
299
|
+
sourceMap: sourcemap
|
|
300
|
+
});
|
|
301
|
+
const diagnostic = result.diagnostics.find((entry) => entry.severity === "error");
|
|
302
|
+
if (diagnostic) throw createCompilerError(diagnostic);
|
|
303
|
+
transformedCode = result.code;
|
|
304
|
+
map = result.map;
|
|
305
|
+
}
|
|
306
|
+
if (shouldStripTs) {
|
|
307
|
+
const result = typescript.default.transpileModule(transformedCode, {
|
|
308
|
+
fileName: filename,
|
|
309
|
+
compilerOptions: {
|
|
310
|
+
module: typescript.default.ModuleKind.Preserve,
|
|
311
|
+
target: typescript.default.ScriptTarget.ES2016,
|
|
312
|
+
jsx: typescript.default.JsxEmit.Preserve,
|
|
313
|
+
sourceMap: sourcemap
|
|
314
|
+
}
|
|
315
|
+
});
|
|
316
|
+
transformedCode = result.outputText.replace(/\n?\/\/# sourceMappingURL=.*$/u, "");
|
|
317
|
+
const transpileMap = result.sourceMapText ? JSON.parse(result.sourceMapText) : null;
|
|
318
|
+
map = transpileMap ? map ? composeSourceMaps(transpileMap, map) : transpileMap : map;
|
|
299
319
|
}
|
|
300
|
-
if (shouldStripTs) plugins.push([_babel_plugin_transform_typescript.default, {}]);
|
|
301
|
-
const result = await (0, _babel_core.transformAsync)(code, {
|
|
302
|
-
filename,
|
|
303
|
-
sourceMaps: sourcemap,
|
|
304
|
-
plugins,
|
|
305
|
-
parserOpts: {
|
|
306
|
-
sourceType: "module",
|
|
307
|
-
plugins: ["typescript", "jsx"]
|
|
308
|
-
},
|
|
309
|
-
generatorOpts: {
|
|
310
|
-
retainLines: false,
|
|
311
|
-
compact: false,
|
|
312
|
-
jsescOption: { minimal: true }
|
|
313
|
-
}
|
|
314
|
-
});
|
|
315
|
-
if (!(result === null || result === void 0 ? void 0 : result.code)) return null;
|
|
316
320
|
return {
|
|
317
|
-
code:
|
|
318
|
-
map
|
|
321
|
+
code: transformedCode,
|
|
322
|
+
map
|
|
319
323
|
};
|
|
320
324
|
}
|
|
325
|
+
function composeSourceMaps(outer, inner) {
|
|
326
|
+
const outerMap = new _jridgewell_trace_mapping.TraceMap(outer);
|
|
327
|
+
const innerMap = new _jridgewell_trace_mapping.TraceMap(inner);
|
|
328
|
+
const generated = new _jridgewell_gen_mapping.GenMapping({ file: outerMap.file });
|
|
329
|
+
for (const [line, segments] of (0, _jridgewell_trace_mapping.decodedMappings)(outerMap).entries()) for (const segment of segments) {
|
|
330
|
+
if (segment.length < 4) continue;
|
|
331
|
+
const originalLine = segment[2];
|
|
332
|
+
const originalColumn = segment[3];
|
|
333
|
+
if (originalLine == null || originalColumn == null) continue;
|
|
334
|
+
const original = (0, _jridgewell_trace_mapping.originalPositionFor)(innerMap, {
|
|
335
|
+
line: originalLine + 1,
|
|
336
|
+
column: originalColumn
|
|
337
|
+
});
|
|
338
|
+
if (original.source == null || original.line == null || original.column == null) continue;
|
|
339
|
+
(0, _jridgewell_gen_mapping.addSegment)(generated, line, segment[0], original.source, original.line - 1, original.column);
|
|
340
|
+
}
|
|
341
|
+
for (const source of innerMap.sources) {
|
|
342
|
+
if (source == null) continue;
|
|
343
|
+
(0, _jridgewell_gen_mapping.setSourceContent)(generated, source, (0, _jridgewell_trace_mapping.sourceContentFor)(innerMap, source));
|
|
344
|
+
}
|
|
345
|
+
return (0, _jridgewell_gen_mapping.toEncodedMap)(generated);
|
|
346
|
+
}
|
|
347
|
+
function createCompilerError(diagnostic) {
|
|
348
|
+
const error = /* @__PURE__ */ new Error(`${diagnostic.code}: ${diagnostic.message}`);
|
|
349
|
+
error.name = "ZeusCompilerDiagnostic";
|
|
350
|
+
Object.assign(error, {
|
|
351
|
+
code: diagnostic.code,
|
|
352
|
+
filename: diagnostic.filename,
|
|
353
|
+
loc: diagnostic.span ? {
|
|
354
|
+
line: diagnostic.span.start.line,
|
|
355
|
+
column: diagnostic.span.start.column
|
|
356
|
+
} : void 0,
|
|
357
|
+
diagnostic
|
|
358
|
+
});
|
|
359
|
+
return error;
|
|
360
|
+
}
|
|
321
361
|
//#endregion
|
|
322
362
|
//#region packages/web-c/bundler-plugin/src/virtual.ts
|
|
323
363
|
const RESOLVED_VIRTUAL_PREFIX = "\0";
|
package/dist/bundler-plugin.d.ts
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import { CompilerOptions } from '@zeus-js/compiler';
|
|
2
1
|
import { ComponentManifest, AnalyzerDiagnostic } from '@zeus-js/component-analyzer';
|
|
3
2
|
import { RollupOptions, Plugin } from 'rollup';
|
|
4
3
|
import { Plugin as Plugin$1 } from 'vite';
|
|
5
4
|
import { RolldownOptions, Plugin as Plugin$2 } from 'rolldown';
|
|
6
5
|
|
|
6
|
+
interface NativeCompilerOptions {
|
|
7
|
+
moduleName?: string;
|
|
8
|
+
delegateEvents?: boolean;
|
|
9
|
+
}
|
|
10
|
+
|
|
7
11
|
type MaybePromise<T> = T | Promise<T>;
|
|
8
12
|
export type RollupExternalOption = string | RegExp | Array<string | RegExp> | ((source: string, importer: string | undefined, isResolved: boolean) => boolean);
|
|
9
13
|
type RootOption = string | (() => string);
|
|
@@ -119,7 +123,7 @@ export interface ZeusBundlerPluginOptions {
|
|
|
119
123
|
/**
|
|
120
124
|
* Compiler options.
|
|
121
125
|
*/
|
|
122
|
-
compiler?: Partial<
|
|
126
|
+
compiler?: Partial<NativeCompilerOptions>;
|
|
123
127
|
/**
|
|
124
128
|
* Print analyzer diagnostics.
|
|
125
129
|
*
|
|
@@ -131,7 +135,7 @@ export interface ZeusBundlerPluginOptions {
|
|
|
131
135
|
*/
|
|
132
136
|
plugins?: ZeusComponentPlugin[];
|
|
133
137
|
/**
|
|
134
|
-
* Enable TypeScript transpilation
|
|
138
|
+
* Enable TypeScript downlevel transpilation after native JSX lowering.
|
|
135
139
|
*
|
|
136
140
|
* @default
|
|
137
141
|
* - rollup: true
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* bundler-plugin v0.1.1-beta.
|
|
2
|
+
* bundler-plugin v0.1.1-beta.2
|
|
3
3
|
* (c) 2026 baicie
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
**/
|
|
@@ -9,9 +9,9 @@ import { analyzeComponentsWithDependencies } from "@zeus-js/component-analyzer";
|
|
|
9
9
|
import picomatch from "picomatch";
|
|
10
10
|
import fs$1 from "node:fs/promises";
|
|
11
11
|
import fg from "fast-glob";
|
|
12
|
-
import {
|
|
13
|
-
import
|
|
14
|
-
import
|
|
12
|
+
import { GenMapping, addSegment, setSourceContent, toEncodedMap } from "@jridgewell/gen-mapping";
|
|
13
|
+
import { TraceMap, decodedMappings, originalPositionFor, sourceContentFor } from "@jridgewell/trace-mapping";
|
|
14
|
+
import ts from "typescript";
|
|
15
15
|
import { createRequire } from "node:module";
|
|
16
16
|
import { mergeConfig } from "vite";
|
|
17
17
|
//#region packages/web-c/bundler-plugin/src/filter.ts
|
|
@@ -361,6 +361,7 @@ function normalizeTagName(tag, stripPrefix) {
|
|
|
361
361
|
if (stripPrefix && tag.startsWith(stripPrefix)) return tag.slice(stripPrefix.length);
|
|
362
362
|
return tag;
|
|
363
363
|
}
|
|
364
|
+
const { transformModule } = createRequire(import.meta.url)("@zeus-js/compiler-native");
|
|
364
365
|
//#endregion
|
|
365
366
|
//#region packages/web-c/bundler-plugin/src/transform.ts
|
|
366
367
|
function transformZeus(_x) {
|
|
@@ -374,40 +375,81 @@ function _transformZeus() {
|
|
|
374
375
|
const shouldRunCompiler = compiler !== false;
|
|
375
376
|
const shouldStripTs = transpile && isTs;
|
|
376
377
|
if (!shouldRunCompiler && !shouldStripTs) return null;
|
|
377
|
-
const compilerOptions = compiler === false ? {} : compiler
|
|
378
|
-
|
|
378
|
+
const compilerOptions = compiler === false ? {} : compiler !== null && compiler !== void 0 ? compiler : {};
|
|
379
|
+
let transformedCode = code;
|
|
380
|
+
let map = null;
|
|
379
381
|
if (shouldRunCompiler) {
|
|
380
|
-
var _compilerOptions$modu;
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
382
|
+
var _compilerOptions$modu, _compilerOptions$dele;
|
|
383
|
+
const result = transformModule({
|
|
384
|
+
source: code,
|
|
385
|
+
filename,
|
|
386
|
+
target: "dom",
|
|
387
|
+
runtimeModule: (_compilerOptions$modu = compilerOptions.moduleName) !== null && _compilerOptions$modu !== void 0 ? _compilerOptions$modu : "@zeus-js/runtime-dom",
|
|
388
|
+
delegateEvents: (_compilerOptions$dele = compilerOptions.delegateEvents) !== null && _compilerOptions$dele !== void 0 ? _compilerOptions$dele : true,
|
|
389
|
+
sourceMap: sourcemap
|
|
390
|
+
});
|
|
391
|
+
const diagnostic = result.diagnostics.find((entry) => entry.severity === "error");
|
|
392
|
+
if (diagnostic) throw createCompilerError(diagnostic);
|
|
393
|
+
transformedCode = result.code;
|
|
394
|
+
map = result.map;
|
|
395
|
+
}
|
|
396
|
+
if (shouldStripTs) {
|
|
397
|
+
const result = ts.transpileModule(transformedCode, {
|
|
398
|
+
fileName: filename,
|
|
399
|
+
compilerOptions: {
|
|
400
|
+
module: ts.ModuleKind.Preserve,
|
|
401
|
+
target: ts.ScriptTarget.ES2016,
|
|
402
|
+
jsx: ts.JsxEmit.Preserve,
|
|
403
|
+
sourceMap: sourcemap
|
|
404
|
+
}
|
|
405
|
+
});
|
|
406
|
+
transformedCode = result.outputText.replace(/\n?\/\/# sourceMappingURL=.*$/u, "");
|
|
407
|
+
const transpileMap = result.sourceMapText ? JSON.parse(result.sourceMapText) : null;
|
|
408
|
+
map = transpileMap ? map ? composeSourceMaps(transpileMap, map) : transpileMap : map;
|
|
387
409
|
}
|
|
388
|
-
if (shouldStripTs) plugins.push([transformTypeScript, {}]);
|
|
389
|
-
const result = yield transformAsync(code, {
|
|
390
|
-
filename,
|
|
391
|
-
sourceMaps: sourcemap,
|
|
392
|
-
plugins,
|
|
393
|
-
parserOpts: {
|
|
394
|
-
sourceType: "module",
|
|
395
|
-
plugins: ["typescript", "jsx"]
|
|
396
|
-
},
|
|
397
|
-
generatorOpts: {
|
|
398
|
-
retainLines: false,
|
|
399
|
-
compact: false,
|
|
400
|
-
jsescOption: { minimal: true }
|
|
401
|
-
}
|
|
402
|
-
});
|
|
403
|
-
if (!(result === null || result === void 0 ? void 0 : result.code)) return null;
|
|
404
410
|
return {
|
|
405
|
-
code:
|
|
406
|
-
map
|
|
411
|
+
code: transformedCode,
|
|
412
|
+
map
|
|
407
413
|
};
|
|
408
414
|
});
|
|
409
415
|
return _transformZeus.apply(this, arguments);
|
|
410
416
|
}
|
|
417
|
+
function composeSourceMaps(outer, inner) {
|
|
418
|
+
const outerMap = new TraceMap(outer);
|
|
419
|
+
const innerMap = new TraceMap(inner);
|
|
420
|
+
const generated = new GenMapping({ file: outerMap.file });
|
|
421
|
+
for (const [line, segments] of decodedMappings(outerMap).entries()) for (const segment of segments) {
|
|
422
|
+
if (segment.length < 4) continue;
|
|
423
|
+
const originalLine = segment[2];
|
|
424
|
+
const originalColumn = segment[3];
|
|
425
|
+
if (originalLine == null || originalColumn == null) continue;
|
|
426
|
+
const original = originalPositionFor(innerMap, {
|
|
427
|
+
line: originalLine + 1,
|
|
428
|
+
column: originalColumn
|
|
429
|
+
});
|
|
430
|
+
if (original.source == null || original.line == null || original.column == null) continue;
|
|
431
|
+
addSegment(generated, line, segment[0], original.source, original.line - 1, original.column);
|
|
432
|
+
}
|
|
433
|
+
for (const source of innerMap.sources) {
|
|
434
|
+
if (source == null) continue;
|
|
435
|
+
setSourceContent(generated, source, sourceContentFor(innerMap, source));
|
|
436
|
+
}
|
|
437
|
+
return toEncodedMap(generated);
|
|
438
|
+
}
|
|
439
|
+
function createCompilerError(diagnostic) {
|
|
440
|
+
const error = /* @__PURE__ */ new Error(`${diagnostic.code}: ${diagnostic.message}`);
|
|
441
|
+
error.name = "ZeusCompilerDiagnostic";
|
|
442
|
+
Object.assign(error, {
|
|
443
|
+
code: diagnostic.code,
|
|
444
|
+
filename: diagnostic.filename,
|
|
445
|
+
loc: diagnostic.span ? {
|
|
446
|
+
line: diagnostic.span.start.line,
|
|
447
|
+
column: diagnostic.span.start.column
|
|
448
|
+
} : void 0,
|
|
449
|
+
diagnostic
|
|
450
|
+
});
|
|
451
|
+
return error;
|
|
452
|
+
}
|
|
411
453
|
//#endregion
|
|
412
454
|
//#region packages/web-c/bundler-plugin/src/virtual.ts
|
|
413
455
|
const RESOLVED_VIRTUAL_PREFIX = "\0";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* bundler-plugin v0.1.1-beta.
|
|
2
|
+
* bundler-plugin v0.1.1-beta.2
|
|
3
3
|
* (c) 2026 baicie
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
**/
|
|
@@ -40,11 +40,10 @@ let node_fs_promises = require("node:fs/promises");
|
|
|
40
40
|
node_fs_promises = __toESM(node_fs_promises, 1);
|
|
41
41
|
let fast_glob = require("fast-glob");
|
|
42
42
|
fast_glob = __toESM(fast_glob, 1);
|
|
43
|
-
let
|
|
44
|
-
let
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
_zeus_js_compiler = __toESM(_zeus_js_compiler, 1);
|
|
43
|
+
let _jridgewell_gen_mapping = require("@jridgewell/gen-mapping");
|
|
44
|
+
let _jridgewell_trace_mapping = require("@jridgewell/trace-mapping");
|
|
45
|
+
let typescript = require("typescript");
|
|
46
|
+
typescript = __toESM(typescript, 1);
|
|
48
47
|
let node_module = require("node:module");
|
|
49
48
|
let vite = require("vite");
|
|
50
49
|
//#region packages/web-c/bundler-plugin/src/filter.ts
|
|
@@ -276,6 +275,7 @@ function normalizeTagName(tag, stripPrefix) {
|
|
|
276
275
|
if (stripPrefix && tag.startsWith(stripPrefix)) return tag.slice(stripPrefix.length);
|
|
277
276
|
return tag;
|
|
278
277
|
}
|
|
278
|
+
const { transformModule } = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href)("@zeus-js/compiler-native");
|
|
279
279
|
//#endregion
|
|
280
280
|
//#region packages/web-c/bundler-plugin/src/transform.ts
|
|
281
281
|
async function transformZeus(options) {
|
|
@@ -285,39 +285,79 @@ async function transformZeus(options) {
|
|
|
285
285
|
const shouldRunCompiler = compiler !== false;
|
|
286
286
|
const shouldStripTs = transpile && isTs;
|
|
287
287
|
if (!shouldRunCompiler && !shouldStripTs) return null;
|
|
288
|
-
const compilerOptions = compiler === false ? {} : compiler
|
|
289
|
-
|
|
288
|
+
const compilerOptions = compiler === false ? {} : compiler !== null && compiler !== void 0 ? compiler : {};
|
|
289
|
+
let transformedCode = code;
|
|
290
|
+
let map = null;
|
|
290
291
|
if (shouldRunCompiler) {
|
|
291
|
-
var _compilerOptions$modu;
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
292
|
+
var _compilerOptions$modu, _compilerOptions$dele;
|
|
293
|
+
const result = transformModule({
|
|
294
|
+
source: code,
|
|
295
|
+
filename,
|
|
296
|
+
target: "dom",
|
|
297
|
+
runtimeModule: (_compilerOptions$modu = compilerOptions.moduleName) !== null && _compilerOptions$modu !== void 0 ? _compilerOptions$modu : "@zeus-js/runtime-dom",
|
|
298
|
+
delegateEvents: (_compilerOptions$dele = compilerOptions.delegateEvents) !== null && _compilerOptions$dele !== void 0 ? _compilerOptions$dele : true,
|
|
299
|
+
sourceMap: sourcemap
|
|
300
|
+
});
|
|
301
|
+
const diagnostic = result.diagnostics.find((entry) => entry.severity === "error");
|
|
302
|
+
if (diagnostic) throw createCompilerError(diagnostic);
|
|
303
|
+
transformedCode = result.code;
|
|
304
|
+
map = result.map;
|
|
305
|
+
}
|
|
306
|
+
if (shouldStripTs) {
|
|
307
|
+
const result = typescript.default.transpileModule(transformedCode, {
|
|
308
|
+
fileName: filename,
|
|
309
|
+
compilerOptions: {
|
|
310
|
+
module: typescript.default.ModuleKind.Preserve,
|
|
311
|
+
target: typescript.default.ScriptTarget.ES2016,
|
|
312
|
+
jsx: typescript.default.JsxEmit.Preserve,
|
|
313
|
+
sourceMap: sourcemap
|
|
314
|
+
}
|
|
315
|
+
});
|
|
316
|
+
transformedCode = result.outputText.replace(/\n?\/\/# sourceMappingURL=.*$/u, "");
|
|
317
|
+
const transpileMap = result.sourceMapText ? JSON.parse(result.sourceMapText) : null;
|
|
318
|
+
map = transpileMap ? map ? composeSourceMaps(transpileMap, map) : transpileMap : map;
|
|
299
319
|
}
|
|
300
|
-
if (shouldStripTs) plugins.push([_babel_plugin_transform_typescript.default, {}]);
|
|
301
|
-
const result = await (0, _babel_core.transformAsync)(code, {
|
|
302
|
-
filename,
|
|
303
|
-
sourceMaps: sourcemap,
|
|
304
|
-
plugins,
|
|
305
|
-
parserOpts: {
|
|
306
|
-
sourceType: "module",
|
|
307
|
-
plugins: ["typescript", "jsx"]
|
|
308
|
-
},
|
|
309
|
-
generatorOpts: {
|
|
310
|
-
retainLines: false,
|
|
311
|
-
compact: false,
|
|
312
|
-
jsescOption: { minimal: true }
|
|
313
|
-
}
|
|
314
|
-
});
|
|
315
|
-
if (!(result === null || result === void 0 ? void 0 : result.code)) return null;
|
|
316
320
|
return {
|
|
317
|
-
code:
|
|
318
|
-
map
|
|
321
|
+
code: transformedCode,
|
|
322
|
+
map
|
|
319
323
|
};
|
|
320
324
|
}
|
|
325
|
+
function composeSourceMaps(outer, inner) {
|
|
326
|
+
const outerMap = new _jridgewell_trace_mapping.TraceMap(outer);
|
|
327
|
+
const innerMap = new _jridgewell_trace_mapping.TraceMap(inner);
|
|
328
|
+
const generated = new _jridgewell_gen_mapping.GenMapping({ file: outerMap.file });
|
|
329
|
+
for (const [line, segments] of (0, _jridgewell_trace_mapping.decodedMappings)(outerMap).entries()) for (const segment of segments) {
|
|
330
|
+
if (segment.length < 4) continue;
|
|
331
|
+
const originalLine = segment[2];
|
|
332
|
+
const originalColumn = segment[3];
|
|
333
|
+
if (originalLine == null || originalColumn == null) continue;
|
|
334
|
+
const original = (0, _jridgewell_trace_mapping.originalPositionFor)(innerMap, {
|
|
335
|
+
line: originalLine + 1,
|
|
336
|
+
column: originalColumn
|
|
337
|
+
});
|
|
338
|
+
if (original.source == null || original.line == null || original.column == null) continue;
|
|
339
|
+
(0, _jridgewell_gen_mapping.addSegment)(generated, line, segment[0], original.source, original.line - 1, original.column);
|
|
340
|
+
}
|
|
341
|
+
for (const source of innerMap.sources) {
|
|
342
|
+
if (source == null) continue;
|
|
343
|
+
(0, _jridgewell_gen_mapping.setSourceContent)(generated, source, (0, _jridgewell_trace_mapping.sourceContentFor)(innerMap, source));
|
|
344
|
+
}
|
|
345
|
+
return (0, _jridgewell_gen_mapping.toEncodedMap)(generated);
|
|
346
|
+
}
|
|
347
|
+
function createCompilerError(diagnostic) {
|
|
348
|
+
const error = /* @__PURE__ */ new Error(`${diagnostic.code}: ${diagnostic.message}`);
|
|
349
|
+
error.name = "ZeusCompilerDiagnostic";
|
|
350
|
+
Object.assign(error, {
|
|
351
|
+
code: diagnostic.code,
|
|
352
|
+
filename: diagnostic.filename,
|
|
353
|
+
loc: diagnostic.span ? {
|
|
354
|
+
line: diagnostic.span.start.line,
|
|
355
|
+
column: diagnostic.span.start.column
|
|
356
|
+
} : void 0,
|
|
357
|
+
diagnostic
|
|
358
|
+
});
|
|
359
|
+
return error;
|
|
360
|
+
}
|
|
321
361
|
//#endregion
|
|
322
362
|
//#region packages/web-c/bundler-plugin/src/virtual.ts
|
|
323
363
|
const RESOLVED_VIRTUAL_PREFIX = "\0";
|
package/dist/rolldown.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* bundler-plugin v0.1.1-beta.
|
|
2
|
+
* bundler-plugin v0.1.1-beta.2
|
|
3
3
|
* (c) 2026 baicie
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
**/
|
|
@@ -40,11 +40,11 @@ let node_fs_promises = require("node:fs/promises");
|
|
|
40
40
|
node_fs_promises = __toESM(node_fs_promises, 1);
|
|
41
41
|
let fast_glob = require("fast-glob");
|
|
42
42
|
fast_glob = __toESM(fast_glob, 1);
|
|
43
|
-
let
|
|
44
|
-
let
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
43
|
+
let _jridgewell_gen_mapping = require("@jridgewell/gen-mapping");
|
|
44
|
+
let _jridgewell_trace_mapping = require("@jridgewell/trace-mapping");
|
|
45
|
+
let typescript = require("typescript");
|
|
46
|
+
typescript = __toESM(typescript, 1);
|
|
47
|
+
let node_module = require("node:module");
|
|
48
48
|
//#region packages/web-c/bundler-plugin/src/filter.ts
|
|
49
49
|
function cleanUrl(id) {
|
|
50
50
|
return id.replace(/[?#].*$/, "");
|
|
@@ -274,6 +274,7 @@ function normalizeTagName(tag, stripPrefix) {
|
|
|
274
274
|
if (stripPrefix && tag.startsWith(stripPrefix)) return tag.slice(stripPrefix.length);
|
|
275
275
|
return tag;
|
|
276
276
|
}
|
|
277
|
+
const { transformModule } = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href)("@zeus-js/compiler-native");
|
|
277
278
|
//#endregion
|
|
278
279
|
//#region packages/web-c/bundler-plugin/src/transform.ts
|
|
279
280
|
async function transformZeus(options) {
|
|
@@ -283,39 +284,79 @@ async function transformZeus(options) {
|
|
|
283
284
|
const shouldRunCompiler = compiler !== false;
|
|
284
285
|
const shouldStripTs = transpile && isTs;
|
|
285
286
|
if (!shouldRunCompiler && !shouldStripTs) return null;
|
|
286
|
-
const compilerOptions = compiler === false ? {} : compiler
|
|
287
|
-
|
|
287
|
+
const compilerOptions = compiler === false ? {} : compiler !== null && compiler !== void 0 ? compiler : {};
|
|
288
|
+
let transformedCode = code;
|
|
289
|
+
let map = null;
|
|
288
290
|
if (shouldRunCompiler) {
|
|
289
|
-
var _compilerOptions$modu;
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
291
|
+
var _compilerOptions$modu, _compilerOptions$dele;
|
|
292
|
+
const result = transformModule({
|
|
293
|
+
source: code,
|
|
294
|
+
filename,
|
|
295
|
+
target: "dom",
|
|
296
|
+
runtimeModule: (_compilerOptions$modu = compilerOptions.moduleName) !== null && _compilerOptions$modu !== void 0 ? _compilerOptions$modu : "@zeus-js/runtime-dom",
|
|
297
|
+
delegateEvents: (_compilerOptions$dele = compilerOptions.delegateEvents) !== null && _compilerOptions$dele !== void 0 ? _compilerOptions$dele : true,
|
|
298
|
+
sourceMap: sourcemap
|
|
299
|
+
});
|
|
300
|
+
const diagnostic = result.diagnostics.find((entry) => entry.severity === "error");
|
|
301
|
+
if (diagnostic) throw createCompilerError(diagnostic);
|
|
302
|
+
transformedCode = result.code;
|
|
303
|
+
map = result.map;
|
|
304
|
+
}
|
|
305
|
+
if (shouldStripTs) {
|
|
306
|
+
const result = typescript.default.transpileModule(transformedCode, {
|
|
307
|
+
fileName: filename,
|
|
308
|
+
compilerOptions: {
|
|
309
|
+
module: typescript.default.ModuleKind.Preserve,
|
|
310
|
+
target: typescript.default.ScriptTarget.ES2016,
|
|
311
|
+
jsx: typescript.default.JsxEmit.Preserve,
|
|
312
|
+
sourceMap: sourcemap
|
|
313
|
+
}
|
|
314
|
+
});
|
|
315
|
+
transformedCode = result.outputText.replace(/\n?\/\/# sourceMappingURL=.*$/u, "");
|
|
316
|
+
const transpileMap = result.sourceMapText ? JSON.parse(result.sourceMapText) : null;
|
|
317
|
+
map = transpileMap ? map ? composeSourceMaps(transpileMap, map) : transpileMap : map;
|
|
297
318
|
}
|
|
298
|
-
if (shouldStripTs) plugins.push([_babel_plugin_transform_typescript.default, {}]);
|
|
299
|
-
const result = await (0, _babel_core.transformAsync)(code, {
|
|
300
|
-
filename,
|
|
301
|
-
sourceMaps: sourcemap,
|
|
302
|
-
plugins,
|
|
303
|
-
parserOpts: {
|
|
304
|
-
sourceType: "module",
|
|
305
|
-
plugins: ["typescript", "jsx"]
|
|
306
|
-
},
|
|
307
|
-
generatorOpts: {
|
|
308
|
-
retainLines: false,
|
|
309
|
-
compact: false,
|
|
310
|
-
jsescOption: { minimal: true }
|
|
311
|
-
}
|
|
312
|
-
});
|
|
313
|
-
if (!(result === null || result === void 0 ? void 0 : result.code)) return null;
|
|
314
319
|
return {
|
|
315
|
-
code:
|
|
316
|
-
map
|
|
320
|
+
code: transformedCode,
|
|
321
|
+
map
|
|
317
322
|
};
|
|
318
323
|
}
|
|
324
|
+
function composeSourceMaps(outer, inner) {
|
|
325
|
+
const outerMap = new _jridgewell_trace_mapping.TraceMap(outer);
|
|
326
|
+
const innerMap = new _jridgewell_trace_mapping.TraceMap(inner);
|
|
327
|
+
const generated = new _jridgewell_gen_mapping.GenMapping({ file: outerMap.file });
|
|
328
|
+
for (const [line, segments] of (0, _jridgewell_trace_mapping.decodedMappings)(outerMap).entries()) for (const segment of segments) {
|
|
329
|
+
if (segment.length < 4) continue;
|
|
330
|
+
const originalLine = segment[2];
|
|
331
|
+
const originalColumn = segment[3];
|
|
332
|
+
if (originalLine == null || originalColumn == null) continue;
|
|
333
|
+
const original = (0, _jridgewell_trace_mapping.originalPositionFor)(innerMap, {
|
|
334
|
+
line: originalLine + 1,
|
|
335
|
+
column: originalColumn
|
|
336
|
+
});
|
|
337
|
+
if (original.source == null || original.line == null || original.column == null) continue;
|
|
338
|
+
(0, _jridgewell_gen_mapping.addSegment)(generated, line, segment[0], original.source, original.line - 1, original.column);
|
|
339
|
+
}
|
|
340
|
+
for (const source of innerMap.sources) {
|
|
341
|
+
if (source == null) continue;
|
|
342
|
+
(0, _jridgewell_gen_mapping.setSourceContent)(generated, source, (0, _jridgewell_trace_mapping.sourceContentFor)(innerMap, source));
|
|
343
|
+
}
|
|
344
|
+
return (0, _jridgewell_gen_mapping.toEncodedMap)(generated);
|
|
345
|
+
}
|
|
346
|
+
function createCompilerError(diagnostic) {
|
|
347
|
+
const error = /* @__PURE__ */ new Error(`${diagnostic.code}: ${diagnostic.message}`);
|
|
348
|
+
error.name = "ZeusCompilerDiagnostic";
|
|
349
|
+
Object.assign(error, {
|
|
350
|
+
code: diagnostic.code,
|
|
351
|
+
filename: diagnostic.filename,
|
|
352
|
+
loc: diagnostic.span ? {
|
|
353
|
+
line: diagnostic.span.start.line,
|
|
354
|
+
column: diagnostic.span.start.column
|
|
355
|
+
} : void 0,
|
|
356
|
+
diagnostic
|
|
357
|
+
});
|
|
358
|
+
return error;
|
|
359
|
+
}
|
|
319
360
|
//#endregion
|
|
320
361
|
//#region packages/web-c/bundler-plugin/src/virtual.ts
|
|
321
362
|
const RESOLVED_VIRTUAL_PREFIX = "\0";
|
package/dist/rolldown.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import { CompilerOptions } from '@zeus-js/compiler';
|
|
2
1
|
import { ComponentManifest, AnalyzerDiagnostic } from '@zeus-js/component-analyzer';
|
|
3
2
|
import { RolldownOptions, Plugin } from 'rolldown';
|
|
4
3
|
|
|
4
|
+
interface NativeCompilerOptions {
|
|
5
|
+
moduleName?: string;
|
|
6
|
+
delegateEvents?: boolean;
|
|
7
|
+
}
|
|
8
|
+
|
|
5
9
|
type MaybePromise<T> = T | Promise<T>;
|
|
6
10
|
type RootOption = string | (() => string);
|
|
7
11
|
type ZeusOutputKind = 'wc' | 'react' | 'vue' | 'icons-react' | 'icons-vue' | 'icons-wc' | 'asset';
|
|
@@ -116,7 +120,7 @@ interface ZeusBundlerPluginOptions {
|
|
|
116
120
|
/**
|
|
117
121
|
* Compiler options.
|
|
118
122
|
*/
|
|
119
|
-
compiler?: Partial<
|
|
123
|
+
compiler?: Partial<NativeCompilerOptions>;
|
|
120
124
|
/**
|
|
121
125
|
* Print analyzer diagnostics.
|
|
122
126
|
*
|
|
@@ -128,7 +132,7 @@ interface ZeusBundlerPluginOptions {
|
|
|
128
132
|
*/
|
|
129
133
|
plugins?: ZeusComponentPlugin[];
|
|
130
134
|
/**
|
|
131
|
-
* Enable TypeScript transpilation
|
|
135
|
+
* Enable TypeScript downlevel transpilation after native JSX lowering.
|
|
132
136
|
*
|
|
133
137
|
* @default
|
|
134
138
|
* - rollup: true
|