Skip to content
Open
Changes from 1 commit
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
Next Next commit
fix(eject): preserve React 17 automatic JSX runtime in Babel config a…
…fter eject
  • Loading branch information
DipakHalkude committed Sep 23, 2025
commit 46732f2a83e79378954ceb4ecbddb13968bed355
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