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

fix(react): avoid JSX transform for <= React 18 interop #1759

Merged
merged 5 commits into from
Feb 9, 2023

Conversation

CodyJasonBennett
Copy link
Member

@CodyJasonBennett CodyJasonBennett commented Feb 8, 2023

Summary

Prefers to use React's classic transform import { createElement } from 'react' to the new JSX transform import { jsx } from 'react/jsx-runtime' which relies on use of package#exports not present before React 18 (facebook/react#20235). In earlier versions, this would need to point to react/jsx-runtime.js, so it's not trivial to support React 17-18 when using automatic transform in an ESM context. I'd very much prefer for this to not require the use of the React namespace since that can be lost in refactor (e.g. https://github.com/kaqiinono/babel-jsx-pragma-module-auto-import), but I'll have to defer that to someone more familiar with the library and its build system.

@vercel
Copy link

vercel bot commented Feb 8, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated
jotai ❌ Failed (Inspect) Feb 9, 2023 at 1:55PM (UTC)

@codesandbox-ci
Copy link

codesandbox-ci bot commented Feb 8, 2023

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit bff0713:

Sandbox Source
React Configuration
React Typescript Configuration
React Browserify Configuration
React Snowpack Configuration
Next.js Configuration
Next.js with custom Babel config Configuration
React with custom Babel config Configuration

@dai-shi
Copy link
Member

dai-shi commented Feb 8, 2023

I thought it's fine as React 18 is still CJS and not a big difference, but I see "exports" is the difference.
If this causes too much trouble, we can go back to createElement as did in v1.

@dai-shi dai-shi changed the title fix(react): use classic JSX transform for <= 18 interop fix(react): avoid JSX transform for <= React 18 interop Feb 9, 2023
@dai-shi dai-shi added this to the v2.0.1 milestone Feb 9, 2023
@dai-shi dai-shi merged commit 052c64d into pmndrs:main Feb 9, 2023
@CodyJasonBennett CodyJasonBennett deleted the fix/react-classic-jsx branch February 9, 2023 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants