Skip to content
Discussion options

You must be logged in to vote

@ras0q use jsr:@deno/emit's transpile() but pass compilerOptions explicitly -- by default it doesn't read your deno.json, which is why the JSX output doesn't match what deno run produces.

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 compilerOptions (including jsx, 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…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@ras0q
Comment options

Answer selected by ras0q
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants