Replies: 5 comments 18 replies
-
It can be configured but the setup is non-trivial. // snowpack.config.json
{
"plugins": [
"@snowpack/plugin-react-refresh",
"@snowpack/plugin-babel" // 👈 have to add babel here
],
// ...
} // babel.config.json
{
"presets": [
"@babel/preset-typescript",
["@babel/preset-react", { "runtime": "automatic" }], // 👈 this is important
["@babel/preset-env", { "targets": { "esmodules": true }, "bugfixes": true, "modules": false }]
]
} // tsconfig.json
{
"compilerOptions": {
"jsx": "react-jsx", // 👈 for correct type checking
// ...
}
} # deps
npm install @snowpack/plugin-babel @babel/preset-{env,react,typescript} typescript@beta |
Beta Was this translation helpful? Give feedback.
-
@phaux Thanks for your explanation and example. In order to complete your exceptional answer, I had to update the install section of snowpack config as // snowpack.config.json
{
"install": [
"react/jsx-runtime"
// ...
],
// ...
} |
Beta Was this translation helpful? Give feedback.
-
It seems like a issue about esbuild If you don't want to use @snowpack/plugin-babel. |
Beta Was this translation helpful? Give feedback.
-
Support for the new JSX transform is independent of writing JSX without needing to import React. Not importing React in JSX with esbuild is already supported. You can do this using the I'm not sure how to pass this to esbuild using Snowpack since I don't use Snowpack myself. Just wanted to point out that esbuild can already do auto-importing. |
Beta Was this translation helpful? Give feedback.
-
Hi everyone, what is the latest state of this issue ? Snowpack document doesn't mention it and I am not sure how Snowpack works with React jsx-runtime ? Is there a way to achieve it at the moment without using babel ? |
Beta Was this translation helpful? Give feedback.
-
Since React introduced the new JSX transform right before React 17 importing React is not needed anymore when writing react components(JSX). Is it something that can be added to snowpack or maybe the snowpack react template? I'm relatively new to snowpack but this was the first thing I clearly noticed when started to use Snowpack.
https://reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html
Beta Was this translation helpful? Give feedback.
All reactions