diff --git a/packages/core/integration-tests/test/integration/jsx-automatic-16/index.js b/packages/core/integration-tests/test/integration/jsx-automatic-16/index.js new file mode 100644 index 00000000000..8d097d55d7f --- /dev/null +++ b/packages/core/integration-tests/test/integration/jsx-automatic-16/index.js @@ -0,0 +1 @@ +module.exports =
; diff --git a/packages/core/integration-tests/test/integration/jsx-automatic-16/node_modules/react/jsx-dev-runtime.js b/packages/core/integration-tests/test/integration/jsx-automatic-16/node_modules/react/jsx-dev-runtime.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/packages/core/integration-tests/test/integration/jsx-automatic-16/node_modules/react/jsx-runtime.js b/packages/core/integration-tests/test/integration/jsx-automatic-16/node_modules/react/jsx-runtime.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/packages/core/integration-tests/test/integration/jsx-automatic-16/node_modules/react/package.json b/packages/core/integration-tests/test/integration/jsx-automatic-16/node_modules/react/package.json new file mode 100644 index 00000000000..bcbea4166f7 --- /dev/null +++ b/packages/core/integration-tests/test/integration/jsx-automatic-16/node_modules/react/package.json @@ -0,0 +1,3 @@ +{ + "name": "react" +} diff --git a/packages/core/integration-tests/test/integration/jsx-automatic-16/package.json b/packages/core/integration-tests/test/integration/jsx-automatic-16/package.json new file mode 100644 index 00000000000..8716e63d8d1 --- /dev/null +++ b/packages/core/integration-tests/test/integration/jsx-automatic-16/package.json @@ -0,0 +1,6 @@ +{ + "private": true, + "dependencies": { + "react": "16.14.0" + } +} diff --git a/packages/core/integration-tests/test/integration/jsx-automatic-16/yarn.lock b/packages/core/integration-tests/test/integration/jsx-automatic-16/yarn.lock new file mode 100644 index 00000000000..e69de29bb2d diff --git a/packages/core/integration-tests/test/transpilation.js b/packages/core/integration-tests/test/transpilation.js index c5e52a89bc7..a630267eee5 100644 --- a/packages/core/integration-tests/test/transpilation.js +++ b/packages/core/integration-tests/test/transpilation.js @@ -203,6 +203,16 @@ describe('transpilation', function () { assert(file.includes('_jsxDevRuntime.jsxDEV("div"')); }); + it('should support the automatic JSX runtime with React ^16.14.0', async function () { + let b = await bundle( + path.join(__dirname, '/integration/jsx-automatic-16/index.js'), + ); + + let file = await outputFS.readFile(b.getBundles()[0].filePath, 'utf8'); + assert(file.includes('react/jsx-dev-runtime')); + assert(file.includes('_jsxDevRuntime.jsxDEV("div"')); + }); + it('should support the automatic JSX runtime with React 18 prereleases', async function () { let b = await bundle( path.join(__dirname, '/integration/jsx-automatic-18/index.js'), diff --git a/packages/transformers/js/src/JSTransformer.js b/packages/transformers/js/src/JSTransformer.js index e65989c700b..b513df85c6f 100644 --- a/packages/transformers/js/src/JSTransformer.js +++ b/packages/transformers/js/src/JSTransformer.js @@ -22,7 +22,7 @@ const JSX_PRAGMA = { react: { pragma: 'React.createElement', pragmaFrag: 'React.Fragment', - automatic: '>= 17.0.0 || >= 0.0.0-0 < 0.0.0', + automatic: '>= 17.0.0 || ^16.14.0 || >= 0.0.0-0 < 0.0.0', }, preact: { pragma: 'h',