@danielx/civet 0.6.74 → 0.6.76
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/browser.js +3566 -3401
- package/dist/civet +66 -13
- package/dist/esbuild.js +3 -3
- package/dist/main.js +3566 -3401
- package/dist/main.mjs +3612 -3447
- package/dist/rollup.js +3 -3
- package/dist/types.d.ts +1 -0
- package/dist/unplugin-shared.mjs +4 -3
- package/dist/unplugin.d.mts +4 -3
- package/dist/unplugin.d.ts +4 -3
- package/dist/unplugin.js +5 -3
- package/dist/unplugin.mjs +2 -0
- package/dist/vite.js +3 -3
- package/dist/webpack.js +3 -3
- package/package.json +1 -1
package/dist/civet
CHANGED
|
@@ -26,8 +26,10 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
// source/cli.civet
|
|
27
27
|
var import_main = require("./main.js");
|
|
28
28
|
var import_config = require("./config.js");
|
|
29
|
+
var import_unplugin = require("./unplugin");
|
|
29
30
|
var import_promises = __toESM(require("fs/promises"));
|
|
30
31
|
var import_path = __toESM(require("path"));
|
|
32
|
+
var unplugin;
|
|
31
33
|
function version() {
|
|
32
34
|
return require("../package.json").version;
|
|
33
35
|
}
|
|
@@ -68,6 +70,8 @@ Options:
|
|
|
68
70
|
--ast Print the AST instead of the compiled code
|
|
69
71
|
--inline-map Generate a sourcemap
|
|
70
72
|
--no-cache Disable compiler caching (slow, for debugging)
|
|
73
|
+
--typecheck Run TypeScript and output diagnostics
|
|
74
|
+
--emit-declaration Run TypeScript and emit .d.ts files (if no errors)
|
|
71
75
|
|
|
72
76
|
You can use - to read from stdin or (prefixed by -o) write to stdout.
|
|
73
77
|
|
|
@@ -82,7 +86,7 @@ function parseArgs(args) {
|
|
|
82
86
|
const options = {};
|
|
83
87
|
Object.defineProperty(options, "run", {
|
|
84
88
|
get: function() {
|
|
85
|
-
return !(this.ast || this.compile);
|
|
89
|
+
return !(this.ast || this.compile || this.typecheck || this.emitDeclaration);
|
|
86
90
|
}
|
|
87
91
|
});
|
|
88
92
|
const filenames = [];
|
|
@@ -165,6 +169,15 @@ function parseArgs(args) {
|
|
|
165
169
|
options.trace = args[++i];
|
|
166
170
|
break;
|
|
167
171
|
}
|
|
172
|
+
case "--typecheck": {
|
|
173
|
+
options.typecheck = true;
|
|
174
|
+
break;
|
|
175
|
+
}
|
|
176
|
+
case "--emit-declaration":
|
|
177
|
+
case "--emitDeclaration": {
|
|
178
|
+
options.emitDeclaration = true;
|
|
179
|
+
break;
|
|
180
|
+
}
|
|
168
181
|
case "--": {
|
|
169
182
|
endOfArgs(++i);
|
|
170
183
|
break;
|
|
@@ -326,6 +339,16 @@ async function cli() {
|
|
|
326
339
|
filenames = ["-"];
|
|
327
340
|
}
|
|
328
341
|
}
|
|
342
|
+
if (options.typecheck || options.emitDeclaration) {
|
|
343
|
+
const unpluginOptions = {
|
|
344
|
+
...options,
|
|
345
|
+
ts: options.js ? "civet" : "preserve",
|
|
346
|
+
outputExtension: ".tsx"
|
|
347
|
+
};
|
|
348
|
+
(unpluginOptions.parseOptions ??= {}).rewriteCivetImports = ".civet.tsx";
|
|
349
|
+
unplugin = (0, import_unplugin.rawPlugin)(unpluginOptions, { framework: "civet-cli" });
|
|
350
|
+
unplugin.buildStart();
|
|
351
|
+
}
|
|
329
352
|
if (options.run) {
|
|
330
353
|
options.js = true;
|
|
331
354
|
options.inlineMap = true;
|
|
@@ -356,25 +379,35 @@ async function cli() {
|
|
|
356
379
|
(options.parseOptions ??= {}).rewriteCivetImports ??= outputExt ?? ".civet" + (options.js ? ".jsx" : ".tsx");
|
|
357
380
|
}
|
|
358
381
|
}
|
|
359
|
-
|
|
382
|
+
let errors = 0;
|
|
360
383
|
for await (const { filename, error, content, stdin } of readFiles(filenames)) {
|
|
361
384
|
if (error) {
|
|
362
385
|
console.error(`${filename} failed to load:`);
|
|
363
386
|
console.error(error);
|
|
387
|
+
errors++;
|
|
364
388
|
continue;
|
|
365
389
|
}
|
|
366
390
|
let output;
|
|
367
391
|
try {
|
|
368
|
-
|
|
392
|
+
if (unplugin != null) {
|
|
393
|
+
output = (await unplugin.load.call({
|
|
394
|
+
addWatchFile() {
|
|
395
|
+
;
|
|
396
|
+
}
|
|
397
|
+
}, `${filename}.tsx`)).code;
|
|
398
|
+
} else {
|
|
399
|
+
output = (0, import_main.compile)(content, { ...options, filename });
|
|
400
|
+
}
|
|
369
401
|
} catch (error2) {
|
|
370
402
|
console.error(error2);
|
|
403
|
+
errors++;
|
|
371
404
|
continue;
|
|
372
405
|
}
|
|
373
406
|
if (options.ast) {
|
|
374
|
-
|
|
407
|
+
process.stdout.write(JSON.stringify(output, null, 2));
|
|
375
408
|
} else if (options.compile) {
|
|
376
409
|
if (stdin && !options.output || options.output === "-") {
|
|
377
|
-
|
|
410
|
+
process.stdout.write(output);
|
|
378
411
|
} else {
|
|
379
412
|
let targetPath = import_path.default.parse(filename);
|
|
380
413
|
delete targetPath.base;
|
|
@@ -397,13 +430,14 @@ async function cli() {
|
|
|
397
430
|
}
|
|
398
431
|
const targetFilename = import_path.default.format(targetPath);
|
|
399
432
|
try {
|
|
400
|
-
|
|
433
|
+
await import_promises.default.writeFile(targetFilename, output);
|
|
401
434
|
} catch (error2) {
|
|
402
435
|
console.error(`${targetFilename} failed to write:`);
|
|
403
|
-
|
|
436
|
+
console.error(error2);
|
|
437
|
+
errors++;
|
|
404
438
|
}
|
|
405
439
|
}
|
|
406
|
-
} else {
|
|
440
|
+
} else if (options.run) {
|
|
407
441
|
const esm = /^\s*(import|export)\b/m.test(output);
|
|
408
442
|
if (esm) {
|
|
409
443
|
if (stdin) {
|
|
@@ -432,12 +466,12 @@ async function cli() {
|
|
|
432
466
|
execArgv,
|
|
433
467
|
stdio: "inherit"
|
|
434
468
|
});
|
|
435
|
-
|
|
469
|
+
child.on("exit", async (code) => {
|
|
436
470
|
if (stdin) {
|
|
437
471
|
await import_promises.default.unlink(filename);
|
|
438
472
|
}
|
|
439
473
|
return process.exit(code ?? 1);
|
|
440
|
-
})
|
|
474
|
+
});
|
|
441
475
|
} else {
|
|
442
476
|
require("../register.js");
|
|
443
477
|
try {
|
|
@@ -448,17 +482,36 @@ async function cli() {
|
|
|
448
482
|
process.argv = ["civet", module.filename, ...scriptArgs];
|
|
449
483
|
module.paths = require("module")._nodeModulePaths(import_path.default.dirname(module.filename));
|
|
450
484
|
try {
|
|
451
|
-
|
|
485
|
+
module._compile(output, module.filename);
|
|
452
486
|
} catch (error2) {
|
|
453
487
|
console.error(`${filename} crashed while running in CJS mode:`);
|
|
454
488
|
console.error(error2);
|
|
455
|
-
|
|
489
|
+
process.exit(1);
|
|
456
490
|
}
|
|
457
491
|
}
|
|
458
492
|
}
|
|
459
493
|
}
|
|
494
|
+
process.exitCode = Math.min(255, errors);
|
|
495
|
+
if (unplugin != null) {
|
|
496
|
+
try {
|
|
497
|
+
return await unplugin.buildEnd.call({
|
|
498
|
+
emitFile({ source, fileName }) {
|
|
499
|
+
return import_promises.default.writeFile(fileName, source);
|
|
500
|
+
}
|
|
501
|
+
});
|
|
502
|
+
} catch (error) {
|
|
503
|
+
let ref1;
|
|
504
|
+
if (ref1 = error.message.match(/Aborting build because of (\d+) TypeScript diagnostic/)) {
|
|
505
|
+
const match = ref1;
|
|
506
|
+
return process.exitCode = Math.min(255, errors + +match[1]);
|
|
507
|
+
} else {
|
|
508
|
+
process.exitCode = 1;
|
|
509
|
+
throw error;
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
}
|
|
460
513
|
;
|
|
461
|
-
return
|
|
514
|
+
return;
|
|
462
515
|
}
|
|
463
516
|
if (require.main === module) {
|
|
464
517
|
cli();
|
package/dist/esbuild.js
CHANGED
|
@@ -80,7 +80,7 @@ function implicitCivet(file) {
|
|
|
80
80
|
return civet2;
|
|
81
81
|
return;
|
|
82
82
|
}
|
|
83
|
-
var
|
|
83
|
+
var rawPlugin = (options = {}, meta) => {
|
|
84
84
|
if (options.dts)
|
|
85
85
|
options.emitDeclaration = options.dts;
|
|
86
86
|
if (options.js)
|
|
@@ -389,8 +389,8 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}, meta) =>
|
|
|
389
389
|
}
|
|
390
390
|
}
|
|
391
391
|
};
|
|
392
|
-
}
|
|
393
|
-
var src_default =
|
|
392
|
+
};
|
|
393
|
+
var src_default = (0, import_unplugin.createUnplugin)(rawPlugin);
|
|
394
394
|
|
|
395
395
|
// src/esbuild.ts
|
|
396
396
|
var esbuild_default = src_default.esbuild;
|