@danielx/civet 0.11.1 → 0.11.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/CHANGELOG.md +13 -0
- package/dist/browser.js +250 -193
- package/dist/civet +27 -29
- package/dist/main.js +306 -215
- package/dist/main.mjs +306 -215
- package/dist/types.d.ts +4 -0
- package/dist/unplugin/unplugin.js +17 -10
- package/dist/unplugin/unplugin.mjs +17 -10
- package/package.json +1 -1
package/dist/civet
CHANGED
|
@@ -549,6 +549,20 @@ You can override this behavior via: --civet rewriteCivetImports=.ext
|
|
|
549
549
|
errors++;
|
|
550
550
|
continue;
|
|
551
551
|
}
|
|
552
|
+
let ref1;
|
|
553
|
+
const outputPath = (delete (ref1 = options.outputPath ?? import_node_path.default.parse(filename)).base, // use name and ext
|
|
554
|
+
ref1.ext += // default extension
|
|
555
|
+
options.js ? ".jsx" : ".tsx", (($) => {
|
|
556
|
+
if (options.outputDir != null) {
|
|
557
|
+
$.dir = options.outputDir;
|
|
558
|
+
}
|
|
559
|
+
if (options.outputExt != null) {
|
|
560
|
+
return $.ext = options.outputExt;
|
|
561
|
+
}
|
|
562
|
+
;
|
|
563
|
+
return;
|
|
564
|
+
})(ref1), ref1);
|
|
565
|
+
const outputFilename = import_node_path.default.format(outputPath);
|
|
552
566
|
let output;
|
|
553
567
|
try {
|
|
554
568
|
if (unplugin != null) {
|
|
@@ -558,7 +572,7 @@ You can override this behavior via: --civet rewriteCivetImports=.ext
|
|
|
558
572
|
}
|
|
559
573
|
}, `${filename}.tsx`)).code;
|
|
560
574
|
} else {
|
|
561
|
-
output = await (0, import_main.compile)(content, { ...options, filename });
|
|
575
|
+
output = await (0, import_main.compile)(content, { ...options, filename, outputFilename });
|
|
562
576
|
}
|
|
563
577
|
} catch (error2) {
|
|
564
578
|
console.error(error2);
|
|
@@ -571,46 +585,30 @@ You can override this behavior via: --civet rewriteCivetImports=.ext
|
|
|
571
585
|
if (stdin && !options.output || options.output === "-") {
|
|
572
586
|
process.stdout.write(output);
|
|
573
587
|
} else {
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
targetPath.ext += ".jsx";
|
|
578
|
-
} else {
|
|
579
|
-
targetPath.ext += ".tsx";
|
|
580
|
-
}
|
|
581
|
-
if (options.outputDir != null) {
|
|
582
|
-
targetPath.dir = options.outputDir;
|
|
588
|
+
const outputDir = import_node_path.default.dirname(outputFilename);
|
|
589
|
+
if (!(outputDir === ".")) {
|
|
590
|
+
await import_promises.default.mkdir(outputDir, { recursive: true });
|
|
583
591
|
}
|
|
584
|
-
if (options.outputExt != null) {
|
|
585
|
-
targetPath.ext = options.outputExt;
|
|
586
|
-
}
|
|
587
|
-
if (options.outputPath != null) {
|
|
588
|
-
targetPath = options.outputPath;
|
|
589
|
-
}
|
|
590
|
-
if (targetPath.dir) {
|
|
591
|
-
await import_promises.default.mkdir(targetPath.dir, { recursive: true });
|
|
592
|
-
}
|
|
593
|
-
const targetFilename = import_node_path.default.format(targetPath);
|
|
594
592
|
try {
|
|
595
|
-
await import_promises.default.writeFile(
|
|
593
|
+
await import_promises.default.writeFile(outputFilename, output);
|
|
596
594
|
} catch (error2) {
|
|
597
|
-
console.error(`${
|
|
595
|
+
console.error(`${outputFilename} failed to write:`);
|
|
598
596
|
console.error(error2);
|
|
599
597
|
errors++;
|
|
600
598
|
}
|
|
601
599
|
}
|
|
602
600
|
} else if (options.run) {
|
|
603
|
-
let
|
|
601
|
+
let ref2;
|
|
604
602
|
{
|
|
605
603
|
if (typeof output === "string" && /\b(await|import|export)\b/.test(output)) {
|
|
606
604
|
const ast = await (0, import_main.compile)(content, { ...options, ast: true, filename });
|
|
607
|
-
|
|
605
|
+
ref2 = import_main.lib.hasAwait(ast) || import_main.lib.hasImportDeclaration(ast) || import_main.lib.hasExportDeclaration(ast);
|
|
608
606
|
} else {
|
|
609
|
-
|
|
607
|
+
ref2 = void 0;
|
|
610
608
|
}
|
|
611
609
|
}
|
|
612
610
|
;
|
|
613
|
-
const esm =
|
|
611
|
+
const esm = ref2;
|
|
614
612
|
if (esm) {
|
|
615
613
|
if (stdin) {
|
|
616
614
|
filename = `.stdin-${process.pid}.civet`;
|
|
@@ -690,9 +688,9 @@ You can override this behavior via: --civet rewriteCivetImports=.ext
|
|
|
690
688
|
}
|
|
691
689
|
}, !filenames.length);
|
|
692
690
|
} catch (error) {
|
|
693
|
-
let
|
|
694
|
-
if (
|
|
695
|
-
const match =
|
|
691
|
+
let ref3;
|
|
692
|
+
if (ref3 = error.message.match(/Aborting build because of (\d+) TypeScript diagnostic/)) {
|
|
693
|
+
const match = ref3;
|
|
696
694
|
return process.exitCode = Math.min(255, errors + +match[1]);
|
|
697
695
|
} else {
|
|
698
696
|
process.exitCode = 1;
|