From 0a0af59d2f78ba3973c8c7a2b20ec435e63a0cae Mon Sep 17 00:00:00 2001 From: Satyajit Sahoo Date: Tue, 2 Jul 2024 16:41:14 +0200 Subject: [PATCH] feat: switch to new jsx runtime --- .../templates/common-example/example/src/App.tsx | 2 -- .../templates/common/tsconfig.json | 2 +- packages/react-native-builder-bob/babel-preset.js | 7 ++++++- packages/react-native-builder-bob/src/index.ts | 2 +- tsconfig.json | 2 +- 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/packages/create-react-native-library/templates/common-example/example/src/App.tsx b/packages/create-react-native-library/templates/common-example/example/src/App.tsx index 55ebf1f82..e45ef16fb 100644 --- a/packages/create-react-native-library/templates/common-example/example/src/App.tsx +++ b/packages/create-react-native-library/templates/common-example/example/src/App.tsx @@ -1,5 +1,3 @@ -import * as React from 'react'; - <% if (project.view && project.module) { -%> import { StyleSheet, View, Text } from 'react-native'; import { <%- project.name -%>View, multiply } from '<%- project.slug -%>'; diff --git a/packages/create-react-native-library/templates/common/tsconfig.json b/packages/create-react-native-library/templates/common/tsconfig.json index d76cc5f8c..7472abcad 100644 --- a/packages/create-react-native-library/templates/common/tsconfig.json +++ b/packages/create-react-native-library/templates/common/tsconfig.json @@ -8,7 +8,7 @@ "allowUnusedLabels": false, "esModuleInterop": true, "forceConsistentCasingInFileNames": true, - "jsx": "react", + "jsx": "react-jsx", "lib": ["ESNext"], "module": "ESNext", "moduleResolution": "Bundler", diff --git a/packages/react-native-builder-bob/babel-preset.js b/packages/react-native-builder-bob/babel-preset.js index 7f5d51614..2b725e98d 100644 --- a/packages/react-native-builder-bob/babel-preset.js +++ b/packages/react-native-builder-bob/babel-preset.js @@ -29,7 +29,12 @@ module.exports = function (api, options, cwd) { modules: cjs ? 'commonjs' : false, }, ], - require.resolve('@babel/preset-react'), + [ + require.resolve('@babel/preset-react'), + { + runtime: 'automatic', + }, + ], require.resolve('@babel/preset-typescript'), require.resolve('@babel/preset-flow'), ], diff --git a/packages/react-native-builder-bob/src/index.ts b/packages/react-native-builder-bob/src/index.ts index 55e052a1a..d16f2b189 100644 --- a/packages/react-native-builder-bob/src/index.ts +++ b/packages/react-native-builder-bob/src/index.ts @@ -181,7 +181,7 @@ yargs allowUnusedLabels: false, esModuleInterop: true, forceConsistentCasingInFileNames: true, - jsx: 'react', + jsx: 'react-jsx', lib: ['ESNext'], module: 'ESNext', moduleResolution: 'Bundler', diff --git a/tsconfig.json b/tsconfig.json index 520914d78..3f73ea820 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -13,7 +13,7 @@ "allowUnusedLabels": false, "esModuleInterop": true, "forceConsistentCasingInFileNames": true, - "jsx": "react", + "jsx": "react-jsx", "lib": ["esnext", "dom"], "module": "esnext", "moduleResolution": "node",