Skip to content

Commit

Permalink
Allow use react-jsx transform in React 16.14.0 (#7728)
Browse files Browse the repository at this point in the history
  • Loading branch information
Akridian committed Mar 20, 2022
1 parent 96c847b commit ec8ed46
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 1 deletion.
@@ -0,0 +1 @@
module.exports = <div />;

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

@@ -0,0 +1,6 @@
{
"private": true,
"dependencies": {
"react": "16.14.0"
}
}
Empty file.
10 changes: 10 additions & 0 deletions packages/core/integration-tests/test/transpilation.js
Expand Up @@ -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'),
Expand Down
2 changes: 1 addition & 1 deletion packages/transformers/js/src/JSTransformer.js
Expand Up @@ -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',
Expand Down

0 comments on commit ec8ed46

Please sign in to comment.