Skip to content

Commit 69b6531

Browse files
authored
fix(react): Revert back to jsxRuntime: 'classic' to prevent breaking react 17 (#12775)
Undoes some of the changes in #12204 and #12740 to fix #12608.
1 parent 1845bf4 commit 69b6531

File tree

4 files changed

+8
-19
lines changed

4 files changed

+8
-19
lines changed

dev-packages/rollup-utils/npmHelpers.mjs

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import {
2222
makeSetSDKSourcePlugin,
2323
makeSucrasePlugin,
2424
} from './plugins/index.mjs';
25-
import { makePackageNodeEsm, makeReactEsmJsxRuntimePlugin } from './plugins/make-esm-plugin.mjs';
25+
import { makePackageNodeEsm } from './plugins/make-esm-plugin.mjs';
2626
import { mergePlugins } from './utils.mjs';
2727

2828
const __dirname = path.dirname(fileURLToPath(import.meta.url));
@@ -143,7 +143,7 @@ export function makeNPMConfigVariants(baseConfig, options = {}) {
143143
output: {
144144
format: 'esm',
145145
dir: path.join(baseConfig.output.dir, 'esm'),
146-
plugins: [makePackageNodeEsm(), makeReactEsmJsxRuntimePlugin()],
146+
plugins: [makePackageNodeEsm()],
147147
},
148148
});
149149
}

dev-packages/rollup-utils/plugins/make-esm-plugin.mjs

-15
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import fs from 'node:fs';
2-
import replacePlugin from '@rollup/plugin-replace';
32

43
/**
54
* Outputs a package.json file with {type: module} in the root of the output directory so that Node
@@ -30,17 +29,3 @@ export function makePackageNodeEsm() {
3029
},
3130
};
3231
}
33-
34-
/**
35-
* Makes sure that whenever we add an `react/jsx-runtime` import, we add a `.js` to make the import esm compatible.
36-
*/
37-
export function makeReactEsmJsxRuntimePlugin() {
38-
return replacePlugin({
39-
preventAssignment: false,
40-
sourceMap: true,
41-
values: {
42-
"'react/jsx-runtime'": "'react/jsx-runtime.js'",
43-
'"react/jsx-runtime"': '"react/jsx-runtime.js"',
44-
},
45-
});
46-
}

packages/react/rollup.npm.config.mjs

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ export default makeNPMConfigVariants(
77
external: ['react', 'react/jsx-runtime'],
88
},
99
sucrase: {
10-
jsxRuntime: 'automatic', // React 19 emits a warning if we don't use the newer jsx transform: https://legacy.reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html
10+
// React 19 emits a warning if we don't use the newer jsx transform: https://legacy.reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html
11+
// but this breaks react 17, so we keep it at `classic` for now
12+
jsxRuntime: 'classic',
1113
production: true, // This is needed so that sucrase uses the production jsx runtime (ie `import { jsx } from 'react/jsx-runtime'` instead of `import { jsxDEV as _jsxDEV } from 'react/jsx-dev-runtime'`)
1214
},
1315
}),

packages/remix/rollup.npm.config.mjs

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ export default [
1212
},
1313
},
1414
sucrase: {
15-
jsxRuntime: 'automatic', // React 19 emits a warning if we don't use the newer jsx transform: https://legacy.reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html
15+
// React 19 emits a warning if we don't use the newer jsx transform: https://legacy.reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html
16+
// but this breaks react 17, so we keep it at `classic` for now
17+
jsxRuntime: 'classic',
1618
production: true, // This is needed so that sucrase uses the production jsx runtime (ie `import { jsx } from 'react/jsx-runtime'` instead of `import { jsxDEV as _jsxDEV } from 'react/jsx-dev-runtime'`)
1719
},
1820
}),

0 commit comments

Comments
 (0)