dector
dector5mo ago

[Solved] How to use precompile TSX transform

Hi! I'm trying to use https://deno.com/blog/v1.38#fastest-jsx-transform . Configured everything and it works. However, I don't understand how to properly do rendering before sending result to the client. Currently I'm doing
import { render } from 'npm:preact-render-to-string'

return new Response(render(<MyJSX />))
import { render } from 'npm:preact-render-to-string'

return new Response(render(<MyJSX />))
but I guess there should be some Deno-native option which I don't know about.
2 Replies
marvinh.
marvinh.5mo ago
What you're doing is already the Deno native solution. Deno is based on web standards so return a Response instance with the html string (+ setting appropriate content type headers) is the way to go Rendering with the jsx precompile transform works the same way as without it from a user perspective. The main difference is how JSX is transpiled behind the scenes and that's where all the benefits are coming from
dector
dectorOP5mo ago
Got it, thanks for the explanation.

Did you find this page helpful?