-
Couldn't load subscription status.
- Fork 257
Migrate JSX runtime in Express + Next.js apps #13313
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
Draft
amoore108
wants to merge
67
commits into
latest
Choose a base branch
from
migrate-jsx-runtime
base: latest
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
+1,244
−2,208
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This reverts commit 189a993.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Changes the JSX runtime/transform from
classictoautomaticto enable future upgrades to the likes of Turbopack and the Next.js App RouterThis is an 'under-the-hood' change with no visible/user-facing benefit, but allows for slightly better developer experience as it removes the need to have the
/** @jsx jsx */pragma defined at the top of components that use Emotioncssstyles. It also removes the need to explicitly importReactand the Emotionjsxfunction into components.The Babel config is also removed from the Next.js app. This hands over compliation to Next itself, meaning we leverage its built in SWC compiler to improve build speed slightly, but ultimately removes dev overhead maintaining Babel configuration and its dependencies.
Code Changes
classictoautomaticin the Express app. The Next.js app does this automatically.importSourceto@emotion/reactin Express Babel andtsconfigto allow Emotion to control JSX behaviour:simorgh/babel.config.main.js
Lines 62 to 65 in 7321aba
simorgh/tsconfig.json
Lines 17 to 18 in 7321aba
/** @jsx jsx */pragma requirement for components styled with Emotioncssfunctionjsxfrom@emotion/reactfrom all components as this is handled byimportSource: @emotion/reactin the Express app andcompiler: { emotion: true }in the Next appReactfrom all components as this is no longer needed under the new runtimebabelconfig from Next.js app, instead deferring to its built-in compilernext/jestto build Jest configs in the Next app. This removes the need to define atransformin each config as Next uses its own compiler to do this: https://nextjs.org/docs/pages/guides/testing/jest#manual-setuptransform-rename-importplugin, moving it to the Express app instead of being in the Next.js app:simorgh/babel.config.main.js
Lines 8 to 11 in 7321aba
Developer Checklist
Testing
Ready-For-Test, Local)Ready-For-Test, Test)Ready-For-Test, Preview)Ready-For-Test, Live)Additional Testing Steps
Useful Links