From 0ba49c3f623e07877aa37ed96be2d4c9e51516f3 Mon Sep 17 00:00:00 2001 From: Phil Edwards Date: Mon, 1 Jul 2024 17:36:55 -0400 Subject: [PATCH] Use React's "automatic" runtime instead of "classic" - 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.) --- .swcrc | 3 ++- tsconfig.json | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.swcrc b/.swcrc index 298f73452a..120cb676a5 100644 --- a/.swcrc +++ b/.swcrc @@ -1,4 +1,5 @@ { + "$schema": "https://swc.rs/schema.json", "sourceMaps": true, "jsc": { "parser": { @@ -7,7 +8,7 @@ }, "transform": { "react": { - "runtime": "classic", + "runtime": "automatic", "refresh": true } } diff --git a/tsconfig.json b/tsconfig.json index 429fa55461..d20e9a2598 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -25,7 +25,7 @@ "skipLibCheck": true, "allowJs": true, "outDir": "out", - "jsx": "react", + "jsx": "react-jsx", "plugins": [{ "name": "typescript-plugin-css-modules"}] }, "include": [