Skip to content

feat: add automatic transform for jsx runtime #5973

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

Merged
merged 3 commits into from
Apr 28, 2025
Merged

Conversation

joshblack
Copy link
Member

Realized when going through our eslint setup that we're not using the new jsx transform when building and testing our components. For more information, see: https://legacy.reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html

Changelog

New

Changed

  • Update our babel config to use the automatic transform instead of classic which is default
  • Update components that were failing tests since key was not being explicitly passed to a component

Removed

Rollout strategy

  • Minor release

@Copilot Copilot AI review requested due to automatic review settings April 25, 2025 19:51
@joshblack joshblack requested a review from a team as a code owner April 25, 2025 19:51
@joshblack joshblack requested a review from jonrohan April 25, 2025 19:51
@github-actions github-actions bot added the staff Author is a staff member label Apr 25, 2025
Copy link
Contributor

👋 Hi, this pull request contains changes to the source code that github/github depends on. If you are GitHub staff, we recommend testing these changes with github/github using the integration workflow. Thanks!

@github-actions github-actions bot added the integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm label Apr 25, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR switches the project’s Babel configuration to use React’s new automatic jsx runtime and updates component tests and implementations to accommodate the change. Key changes include updating the Babel and Rollup configurations, modifying component key handling in tests and render functions, and updating the changeset.

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/react/src/tests/Pagination/Pagination.test.tsx Updated renderPage to explicitly pass a key prop to the link component.
packages/react/src/FilteredActionList/FilteredActionListWithModernActionList.tsx Refactored key extraction in the mapping of action list items.
packages/react/src/Autocomplete/AutocompleteMenu.tsx Adjusted key handling in ActionList.Item to work with TS definitions.
packages/react/rollup.config.mjs Updated Babel preset configuration to use the automatic jsx runtime.
packages/react/babel.config.js Updated Babel preset configuration to use the automatic jsx runtime.
.changeset/wise-gifts-see.md Documented the jsx transform update in the changeset.

Comment on lines +367 to +368
// @ts-expect-error this is defined in the items above but is
// missing in TS
Copy link
Preview

Copilot AI Apr 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider updating the TypeScript type definitions for the items to include the 'key' property instead of suppressing the error with @ts-expect-error.

Suggested change
// @ts-expect-error this is defined in the items above but is
// missing in TS

Copilot uses AI. Check for mistakes.

@@ -31,7 +31,7 @@ describe('Pagination', () => {
<Pagination
pageCount={10}
currentPage={1}
renderPage={({number, ...props}) => <ReactRouterLikeLink to={`#${number}`} {...props} />}
renderPage={({key, number, ...props}) => <ReactRouterLikeLink key={key} to={`#${number}`} {...props} />}
Copy link
Preview

Copilot AI Apr 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Ensure that the 'key' prop provided here is unique and aligns with React's recommendations for maintaining element identity during re-renders.

Suggested change
renderPage={({key, number, ...props}) => <ReactRouterLikeLink key={key} to={`#${number}`} {...props} />}
renderPage={({key, number, ...props}) => <ReactRouterLikeLink key={number} to={`#${number}`} {...props} />}

Copilot uses AI. Check for mistakes.

Comment on lines +185 to +192
const key = itemKey ?? item.id?.toString() ?? index.toString()
return <MappedActionListItem key={key} {...item} renderItem={listProps.renderItem} />
})}
</ActionList.Group>
)
})
: items.map((item, index) => {
const key = item.key ?? item.id?.toString() ?? index.toString()
: items.map(({key: itemKey, ...item}, index) => {
const key = itemKey ?? item.id?.toString() ?? index.toString()
Copy link
Preview

Copilot AI Apr 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Verify that destructuring 'itemKey' for generating the key is consistently applied and clearly documented when key fallback values are used.

Copilot uses AI. Check for mistakes.

Copy link
Contributor

size-limit report 📦

Path Size
packages/react/dist/browser.esm.js 99.71 KB (-0.06% 🔽)
packages/react/dist/browser.umd.js 99.91 KB (-0.02% 🔽)

@primer-integration
Copy link

👋 Hi from github/github! Your integration PR is ready: https://github.com/github/github/pull/375036

@primer-integration
Copy link

🟢 golden-jobs completed with status success.

@github-actions github-actions bot added integration-tests: passing Changes in this PR do NOT cause breaking changes in gh/gh and removed integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm labels Apr 25, 2025
@joshblack joshblack enabled auto-merge April 28, 2025 17:21
@joshblack joshblack added this pull request to the merge queue Apr 28, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Apr 28, 2025
@joshblack joshblack added this pull request to the merge queue Apr 28, 2025
Merged via the queue into main with commit 6d3fc05 Apr 28, 2025
49 checks passed
@joshblack joshblack deleted the feat/update-jsx-runtime branch April 28, 2025 20:34
@primer primer bot mentioned this pull request Apr 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integration-tests: passing Changes in this PR do NOT cause breaking changes in gh/gh staff Author is a staff member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants