Meep
Meep2w ago

JXS/TSX Transformation from within browser code?

Background: I'm working on a small browser/pwa based project that allows a user to define TSX components in a web form and and then render them as previews. Question: Does Deno have a default or built in way to transform TSX that can be imbedded for use like this? My current plan was to import babel from it's npm package and use the typescript transform plugin; but if there's a more standard, efficient, or concise way built into deno that's be cool to know about! Thanks!
3 Replies
jeff.hykin
jeff.hykin2w ago
I'm decently-highly confident the answer is no, not without some hacks like writing to a file or calling a child process. Theres also a decent number of ways to create a security vulnerability on the backend with user generated code. So I think babel in the frontend is your best bet
HewloThere
HewloThere4d ago
sorry for reviving an old thread. i'm not sure if this works in the browser (and jsr isn't sure either) but does this somehow work? https://jsr.io/@deno/emit
JSR
@deno/emit - JSR
@deno/emit on JSR
HewloThere
HewloThere4d ago
alternatively, you could use esbuild-wasm and try to do something similar to the "try" part of the esbuild docs has? https://github.com/evanw/esbuild/blob/main/scripts/try.html https://esbuild.github.io/try/
GitHub
esbuild/scripts/try.html at main · evanw/esbuild
An extremely fast bundler for the web. Contribute to evanw/esbuild development by creating an account on GitHub.