How to check transpired code from jsx/tsx → js/ts ? #28862
-
|
I know that I can run the tsx file in deno with |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
@ras0q use import { transpile } from "jsr:@deno/emit";
const denoConfig = JSON.parse(await Deno.readTextFile("./deno.json"));
const url = new URL("./foo.tsx", import.meta.url);
const result = await transpile(url, {
compilerOptions: denoConfig.compilerOptions,
});
console.log(result.get(url.href));this reads your project's if you just want a quick one-off check without writing a script, you can also use deno eval "import { transpile } from 'jsr:@deno/emit'; const r = await transpile(new URL('./foo.tsx', import.meta.url)); console.log([...r.values()][0])"ref: |
Beta Was this translation helpful? Give feedback.
@ras0q use
jsr:@deno/emit'stranspile()but passcompilerOptionsexplicitly -- by default it doesn't read yourdeno.json, which is why the JSX output doesn't match whatdeno runproduces.this reads your project's
compilerOptions(includingjsx,jsxImportSource,jsxFactory, etc.) and passes them to the transpiler so the output matches what deno generates internally.if you just want a quick one-off ch…