@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/rollup.js
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
|
**/
|
|
@@ -9,9 +9,10 @@ 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
|
+
import { createRequire } from "node:module";
|
|
15
16
|
//#region packages/web-c/bundler-plugin/src/filter.ts
|
|
16
17
|
function cleanUrl(id) {
|
|
17
18
|
return id.replace(/[?#].*$/, "");
|
|
@@ -359,6 +360,7 @@ function normalizeTagName(tag, stripPrefix) {
|
|
|
359
360
|
if (stripPrefix && tag.startsWith(stripPrefix)) return tag.slice(stripPrefix.length);
|
|
360
361
|
return tag;
|
|
361
362
|
}
|
|
363
|
+
const { transformModule } = createRequire(import.meta.url)("@zeus-js/compiler-native");
|
|
362
364
|
//#endregion
|
|
363
365
|
//#region packages/web-c/bundler-plugin/src/transform.ts
|
|
364
366
|
function transformZeus(_x) {
|
|
@@ -372,40 +374,81 @@ function _transformZeus() {
|
|
|
372
374
|
const shouldRunCompiler = compiler !== false;
|
|
373
375
|
const shouldStripTs = transpile && isTs;
|
|
374
376
|
if (!shouldRunCompiler && !shouldStripTs) return null;
|
|
375
|
-
const compilerOptions = compiler === false ? {} : compiler
|
|
376
|
-
|
|
377
|
+
const compilerOptions = compiler === false ? {} : compiler !== null && compiler !== void 0 ? compiler : {};
|
|
378
|
+
let transformedCode = code;
|
|
379
|
+
let map = null;
|
|
377
380
|
if (shouldRunCompiler) {
|
|
378
|
-
var _compilerOptions$modu;
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
381
|
+
var _compilerOptions$modu, _compilerOptions$dele;
|
|
382
|
+
const result = transformModule({
|
|
383
|
+
source: code,
|
|
384
|
+
filename,
|
|
385
|
+
target: "dom",
|
|
386
|
+
runtimeModule: (_compilerOptions$modu = compilerOptions.moduleName) !== null && _compilerOptions$modu !== void 0 ? _compilerOptions$modu : "@zeus-js/runtime-dom",
|
|
387
|
+
delegateEvents: (_compilerOptions$dele = compilerOptions.delegateEvents) !== null && _compilerOptions$dele !== void 0 ? _compilerOptions$dele : true,
|
|
388
|
+
sourceMap: sourcemap
|
|
389
|
+
});
|
|
390
|
+
const diagnostic = result.diagnostics.find((entry) => entry.severity === "error");
|
|
391
|
+
if (diagnostic) throw createCompilerError(diagnostic);
|
|
392
|
+
transformedCode = result.code;
|
|
393
|
+
map = result.map;
|
|
394
|
+
}
|
|
395
|
+
if (shouldStripTs) {
|
|
396
|
+
const result = ts.transpileModule(transformedCode, {
|
|
397
|
+
fileName: filename,
|
|
398
|
+
compilerOptions: {
|
|
399
|
+
module: ts.ModuleKind.Preserve,
|
|
400
|
+
target: ts.ScriptTarget.ES2016,
|
|
401
|
+
jsx: ts.JsxEmit.Preserve,
|
|
402
|
+
sourceMap: sourcemap
|
|
403
|
+
}
|
|
404
|
+
});
|
|
405
|
+
transformedCode = result.outputText.replace(/\n?\/\/# sourceMappingURL=.*$/u, "");
|
|
406
|
+
const transpileMap = result.sourceMapText ? JSON.parse(result.sourceMapText) : null;
|
|
407
|
+
map = transpileMap ? map ? composeSourceMaps(transpileMap, map) : transpileMap : map;
|
|
385
408
|
}
|
|
386
|
-
if (shouldStripTs) plugins.push([transformTypeScript, {}]);
|
|
387
|
-
const result = yield transformAsync(code, {
|
|
388
|
-
filename,
|
|
389
|
-
sourceMaps: sourcemap,
|
|
390
|
-
plugins,
|
|
391
|
-
parserOpts: {
|
|
392
|
-
sourceType: "module",
|
|
393
|
-
plugins: ["typescript", "jsx"]
|
|
394
|
-
},
|
|
395
|
-
generatorOpts: {
|
|
396
|
-
retainLines: false,
|
|
397
|
-
compact: false,
|
|
398
|
-
jsescOption: { minimal: true }
|
|
399
|
-
}
|
|
400
|
-
});
|
|
401
|
-
if (!(result === null || result === void 0 ? void 0 : result.code)) return null;
|
|
402
409
|
return {
|
|
403
|
-
code:
|
|
404
|
-
map
|
|
410
|
+
code: transformedCode,
|
|
411
|
+
map
|
|
405
412
|
};
|
|
406
413
|
});
|
|
407
414
|
return _transformZeus.apply(this, arguments);
|
|
408
415
|
}
|
|
416
|
+
function composeSourceMaps(outer, inner) {
|
|
417
|
+
const outerMap = new TraceMap(outer);
|
|
418
|
+
const innerMap = new TraceMap(inner);
|
|
419
|
+
const generated = new GenMapping({ file: outerMap.file });
|
|
420
|
+
for (const [line, segments] of decodedMappings(outerMap).entries()) for (const segment of segments) {
|
|
421
|
+
if (segment.length < 4) continue;
|
|
422
|
+
const originalLine = segment[2];
|
|
423
|
+
const originalColumn = segment[3];
|
|
424
|
+
if (originalLine == null || originalColumn == null) continue;
|
|
425
|
+
const original = originalPositionFor(innerMap, {
|
|
426
|
+
line: originalLine + 1,
|
|
427
|
+
column: originalColumn
|
|
428
|
+
});
|
|
429
|
+
if (original.source == null || original.line == null || original.column == null) continue;
|
|
430
|
+
addSegment(generated, line, segment[0], original.source, original.line - 1, original.column);
|
|
431
|
+
}
|
|
432
|
+
for (const source of innerMap.sources) {
|
|
433
|
+
if (source == null) continue;
|
|
434
|
+
setSourceContent(generated, source, sourceContentFor(innerMap, source));
|
|
435
|
+
}
|
|
436
|
+
return toEncodedMap(generated);
|
|
437
|
+
}
|
|
438
|
+
function createCompilerError(diagnostic) {
|
|
439
|
+
const error = /* @__PURE__ */ new Error(`${diagnostic.code}: ${diagnostic.message}`);
|
|
440
|
+
error.name = "ZeusCompilerDiagnostic";
|
|
441
|
+
Object.assign(error, {
|
|
442
|
+
code: diagnostic.code,
|
|
443
|
+
filename: diagnostic.filename,
|
|
444
|
+
loc: diagnostic.span ? {
|
|
445
|
+
line: diagnostic.span.start.line,
|
|
446
|
+
column: diagnostic.span.start.column
|
|
447
|
+
} : void 0,
|
|
448
|
+
diagnostic
|
|
449
|
+
});
|
|
450
|
+
return error;
|
|
451
|
+
}
|
|
409
452
|
//#endregion
|
|
410
453
|
//#region packages/web-c/bundler-plugin/src/virtual.ts
|
|
411
454
|
const RESOLVED_VIRTUAL_PREFIX = "\0";
|
package/dist/rollup.prod.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/rollup.prod.js
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
|
**/
|
|
@@ -9,9 +9,10 @@ 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
|
+
import { createRequire } from "node:module";
|
|
15
16
|
//#region packages/web-c/bundler-plugin/src/filter.ts
|
|
16
17
|
function cleanUrl(id) {
|
|
17
18
|
return id.replace(/[?#].*$/, "");
|
|
@@ -359,6 +360,7 @@ function normalizeTagName(tag, stripPrefix) {
|
|
|
359
360
|
if (stripPrefix && tag.startsWith(stripPrefix)) return tag.slice(stripPrefix.length);
|
|
360
361
|
return tag;
|
|
361
362
|
}
|
|
363
|
+
const { transformModule } = createRequire(import.meta.url)("@zeus-js/compiler-native");
|
|
362
364
|
//#endregion
|
|
363
365
|
//#region packages/web-c/bundler-plugin/src/transform.ts
|
|
364
366
|
function transformZeus(_x) {
|
|
@@ -372,40 +374,81 @@ function _transformZeus() {
|
|
|
372
374
|
const shouldRunCompiler = compiler !== false;
|
|
373
375
|
const shouldStripTs = transpile && isTs;
|
|
374
376
|
if (!shouldRunCompiler && !shouldStripTs) return null;
|
|
375
|
-
const compilerOptions = compiler === false ? {} : compiler
|
|
376
|
-
|
|
377
|
+
const compilerOptions = compiler === false ? {} : compiler !== null && compiler !== void 0 ? compiler : {};
|
|
378
|
+
let transformedCode = code;
|
|
379
|
+
let map = null;
|
|
377
380
|
if (shouldRunCompiler) {
|
|
378
|
-
var _compilerOptions$modu;
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
381
|
+
var _compilerOptions$modu, _compilerOptions$dele;
|
|
382
|
+
const result = transformModule({
|
|
383
|
+
source: code,
|
|
384
|
+
filename,
|
|
385
|
+
target: "dom",
|
|
386
|
+
runtimeModule: (_compilerOptions$modu = compilerOptions.moduleName) !== null && _compilerOptions$modu !== void 0 ? _compilerOptions$modu : "@zeus-js/runtime-dom",
|
|
387
|
+
delegateEvents: (_compilerOptions$dele = compilerOptions.delegateEvents) !== null && _compilerOptions$dele !== void 0 ? _compilerOptions$dele : true,
|
|
388
|
+
sourceMap: sourcemap
|
|
389
|
+
});
|
|
390
|
+
const diagnostic = result.diagnostics.find((entry) => entry.severity === "error");
|
|
391
|
+
if (diagnostic) throw createCompilerError(diagnostic);
|
|
392
|
+
transformedCode = result.code;
|
|
393
|
+
map = result.map;
|
|
394
|
+
}
|
|
395
|
+
if (shouldStripTs) {
|
|
396
|
+
const result = ts.transpileModule(transformedCode, {
|
|
397
|
+
fileName: filename,
|
|
398
|
+
compilerOptions: {
|
|
399
|
+
module: ts.ModuleKind.Preserve,
|
|
400
|
+
target: ts.ScriptTarget.ES2016,
|
|
401
|
+
jsx: ts.JsxEmit.Preserve,
|
|
402
|
+
sourceMap: sourcemap
|
|
403
|
+
}
|
|
404
|
+
});
|
|
405
|
+
transformedCode = result.outputText.replace(/\n?\/\/# sourceMappingURL=.*$/u, "");
|
|
406
|
+
const transpileMap = result.sourceMapText ? JSON.parse(result.sourceMapText) : null;
|
|
407
|
+
map = transpileMap ? map ? composeSourceMaps(transpileMap, map) : transpileMap : map;
|
|
385
408
|
}
|
|
386
|
-
if (shouldStripTs) plugins.push([transformTypeScript, {}]);
|
|
387
|
-
const result = yield transformAsync(code, {
|
|
388
|
-
filename,
|
|
389
|
-
sourceMaps: sourcemap,
|
|
390
|
-
plugins,
|
|
391
|
-
parserOpts: {
|
|
392
|
-
sourceType: "module",
|
|
393
|
-
plugins: ["typescript", "jsx"]
|
|
394
|
-
},
|
|
395
|
-
generatorOpts: {
|
|
396
|
-
retainLines: false,
|
|
397
|
-
compact: false,
|
|
398
|
-
jsescOption: { minimal: true }
|
|
399
|
-
}
|
|
400
|
-
});
|
|
401
|
-
if (!(result === null || result === void 0 ? void 0 : result.code)) return null;
|
|
402
409
|
return {
|
|
403
|
-
code:
|
|
404
|
-
map
|
|
410
|
+
code: transformedCode,
|
|
411
|
+
map
|
|
405
412
|
};
|
|
406
413
|
});
|
|
407
414
|
return _transformZeus.apply(this, arguments);
|
|
408
415
|
}
|
|
416
|
+
function composeSourceMaps(outer, inner) {
|
|
417
|
+
const outerMap = new TraceMap(outer);
|
|
418
|
+
const innerMap = new TraceMap(inner);
|
|
419
|
+
const generated = new GenMapping({ file: outerMap.file });
|
|
420
|
+
for (const [line, segments] of decodedMappings(outerMap).entries()) for (const segment of segments) {
|
|
421
|
+
if (segment.length < 4) continue;
|
|
422
|
+
const originalLine = segment[2];
|
|
423
|
+
const originalColumn = segment[3];
|
|
424
|
+
if (originalLine == null || originalColumn == null) continue;
|
|
425
|
+
const original = originalPositionFor(innerMap, {
|
|
426
|
+
line: originalLine + 1,
|
|
427
|
+
column: originalColumn
|
|
428
|
+
});
|
|
429
|
+
if (original.source == null || original.line == null || original.column == null) continue;
|
|
430
|
+
addSegment(generated, line, segment[0], original.source, original.line - 1, original.column);
|
|
431
|
+
}
|
|
432
|
+
for (const source of innerMap.sources) {
|
|
433
|
+
if (source == null) continue;
|
|
434
|
+
setSourceContent(generated, source, sourceContentFor(innerMap, source));
|
|
435
|
+
}
|
|
436
|
+
return toEncodedMap(generated);
|
|
437
|
+
}
|
|
438
|
+
function createCompilerError(diagnostic) {
|
|
439
|
+
const error = /* @__PURE__ */ new Error(`${diagnostic.code}: ${diagnostic.message}`);
|
|
440
|
+
error.name = "ZeusCompilerDiagnostic";
|
|
441
|
+
Object.assign(error, {
|
|
442
|
+
code: diagnostic.code,
|
|
443
|
+
filename: diagnostic.filename,
|
|
444
|
+
loc: diagnostic.span ? {
|
|
445
|
+
line: diagnostic.span.start.line,
|
|
446
|
+
column: diagnostic.span.start.column
|
|
447
|
+
} : void 0,
|
|
448
|
+
diagnostic
|
|
449
|
+
});
|
|
450
|
+
return error;
|
|
451
|
+
}
|
|
409
452
|
//#endregion
|
|
410
453
|
//#region packages/web-c/bundler-plugin/src/virtual.ts
|
|
411
454
|
const RESOLVED_VIRTUAL_PREFIX = "\0";
|
package/dist/vite.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
|
**/
|
|
@@ -42,11 +42,10 @@ let node_fs_promises = require("node:fs/promises");
|
|
|
42
42
|
node_fs_promises = __toESM(node_fs_promises, 1);
|
|
43
43
|
let fast_glob = require("fast-glob");
|
|
44
44
|
fast_glob = __toESM(fast_glob, 1);
|
|
45
|
-
let
|
|
46
|
-
let
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
_zeus_js_compiler = __toESM(_zeus_js_compiler, 1);
|
|
45
|
+
let _jridgewell_gen_mapping = require("@jridgewell/gen-mapping");
|
|
46
|
+
let _jridgewell_trace_mapping = require("@jridgewell/trace-mapping");
|
|
47
|
+
let typescript = require("typescript");
|
|
48
|
+
typescript = __toESM(typescript, 1);
|
|
50
49
|
//#region packages/web-c/bundler-plugin/src/filter.ts
|
|
51
50
|
function cleanUrl(id) {
|
|
52
51
|
return id.replace(/[?#].*$/, "");
|
|
@@ -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/vite.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 { Plugin } from 'vite';
|
|
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
|