Skip to content

Commit

Permalink
Use React's "automatic" runtime instead of "classic"
Browse files Browse the repository at this point in the history
- https://legacy.reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html
- https://swc.rs/docs/configuration/compilation#jsctransformreactruntime

> "Use `runtime: automatic` to use a JSX runtime module
  (e.g. `react/jsx-runtime` introduced in React 17)."

(Note that with the new jsx transform, you can now use jsx/tsx in a file
without importing React. TS knows this now, too. Feel free to take its
suggestion.)

(The $schema key added to .swcrc just adds better hints when editing the
JSON config, it's unrelated to the runtime change.)
  • Loading branch information
p2edwards committed Jul 1, 2024
1 parent 8742e60 commit 0ba49c3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .swcrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"$schema": "https://swc.rs/schema.json",
"sourceMaps": true,
"jsc": {
"parser": {
Expand All @@ -7,7 +8,7 @@
},
"transform": {
"react": {
"runtime": "classic",
"runtime": "automatic",
"refresh": true
}
}
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"skipLibCheck": true,
"allowJs": true,
"outDir": "out",
"jsx": "react",
"jsx": "react-jsx",
"plugins": [{ "name": "typescript-plugin-css-modules"}]
},
"include": [
Expand Down

0 comments on commit 0ba49c3

Please sign in to comment.