FredKSchott / snowpack

ESM-powered frontend build tool. Instant, lightweight, unbundled development. ✌️
https://www.snowpack.dev
MIT License
19.48k stars 922 forks source link

How does snowpack transform JSX internally? #3085

Closed marialovesbeans closed 3 years ago

marialovesbeans commented 3 years ago

The guide says Snowpack has built-in support for JSX and TypeScript transpilation. However when fiddling through source code I cannot pinpoint the line where JSX transformation is performed. Can anyone please point out where exactly does this happen? I need to Monkey Patch something to test. Thanks so much!!

drwpow commented 3 years ago

esbuild takes care of this using the Transform API (docs). This happens inside plugin-esbuild which we include in Snowpack, and we load by default if you haven’t specified another plugin for JS. But it’s also a good example of how pluggable Snowpack is—if you wanted to, you could copy this plugin, load it externally, and make whatever changes you’d like! Then you could run any transforms on JS you’d like to.