Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion packages/react-scripts/scripts/eject.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,29 @@ prompts({

// Add Babel config
console.log(` Adding ${cyan('Babel')} preset`);
// Detect if the new JSX transform is available and prefer it after eject
const hasJsxRuntime = (() => {
if (process.env.DISABLE_NEW_JSX_TRANSFORM === 'true') {
return false;
}
try {
require.resolve('react/jsx-runtime');
return true;
} catch (e) {
return false;
}
})();

appPackage.babel = {
presets: ['react-app'],
// Preserve preset with explicit runtime so ejected apps keep working without importing React
presets: [
[
'react-app',
{
runtime: hasJsxRuntime ? 'automatic' : 'classic',
},
],
],
};

// Add ESlint config
Expand Down