Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow use react-jsx transform in React 16.14.0 #7728

Merged
merged 6 commits into from Mar 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -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"
}
}
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