Skip to content

refactor: use ESM exports in ReactNativeViewConfigRegistry #40787

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

Closed

Conversation

jbroma
Copy link
Contributor

@jbroma jbroma commented Oct 11, 2023

Summary:

When transpiling react-native with swc this file caused some trouble as it mixes ESM and CJS import/export syntax. This PR addresses this by converting CJS exports to ESM exports. All other affected files were aligned to support this change.

Changelog:

[INTERNAL] [CHANGED] - use ESM exports in ReactNativeViewConfigRegistry

Test Plan:

@facebook-github-bot
Copy link
Contributor

Hi @jbroma!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. labels Oct 11, 2023
@facebook-github-bot
Copy link
Contributor

@javache has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@github-actions
Copy link

github-actions bot commented Oct 11, 2023

Warnings
⚠️ One hour and a half have passed and the E2E jobs haven't finished yet.

Generated by 🚫 dangerJS against 842a997

@javache
Copy link
Member

javache commented Oct 11, 2023

The source of truth for ReactNativeViewConfigRegistry is actually in React, and gets synced automatically to React Native - https://github.com/facebook/react/blob/main/scripts/rollup/shims/react-native/ReactNativeViewConfigRegistry.js

@jbroma
Copy link
Contributor Author

jbroma commented Oct 11, 2023

@javache ok, I will make open additional PR in React then.

@jbroma
Copy link
Contributor Author

jbroma commented Oct 11, 2023

@javache considering how these files are linked through the sync script, is there going to be an option to sync just this change? I've noticed there is a ton of changes related to server components that would get synced and that's definitely not desirable. How do you see this PR going forward? Thanks!

@javache
Copy link
Member

javache commented Oct 11, 2023

@javache considering how these files are linked through the sync script, is there going to be an option to sync just this change? I've noticed there is a ton of changes related to server components that would get synced and that's definitely not desirable. How do you see this PR going forward? Thanks!

Just this change will be synced. We only update the renderer as part of a React npm release.

@jbroma
Copy link
Contributor Author

jbroma commented Oct 12, 2023

I've added a PR in 'react': facebook/react#27508

I've also removed changes to ReactNativeViewConfigRegistry as it will be synced.

javache pushed a commit to facebook/react that referenced this pull request Oct 12, 2023
## Summary

When transpiling `react-native` with `swc` this file caused some trouble
as it mixes ESM and CJS import/export syntax. This PR addresses this by
converting CJS exports to ESM exports. As
`ReactNativeViewConfigRegistry` is synced from `react` to `react-native`
repository, it's required to make the change here. I've also aligned the
mock of `ReactNativeViewConfigRegistry` to reflect current
implementation.

Related PR in `react-native`:
facebook/react-native#40787
@javache
Copy link
Member

javache commented Oct 12, 2023

Merged the React PR, it should land here in the next few days, please rebase on top of that.

@facebook-github-bot
Copy link
Contributor

@javache has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@github-actions
Copy link

This pull request was successfully merged by @jbroma in 0e590c0.

When will my fix make it into a release? | Upcoming Releases

@github-actions github-actions bot added the Merged This PR has been merged. label Oct 13, 2023
EdisonVan pushed a commit to EdisonVan/react that referenced this pull request Apr 15, 2024
…27508)

## Summary

When transpiling `react-native` with `swc` this file caused some trouble
as it mixes ESM and CJS import/export syntax. This PR addresses this by
converting CJS exports to ESM exports. As
`ReactNativeViewConfigRegistry` is synced from `react` to `react-native`
repository, it's required to make the change here. I've also aligned the
mock of `ReactNativeViewConfigRegistry` to reflect current
implementation.

Related PR in `react-native`:
facebook/react-native#40787
Akshato07 pushed a commit to Akshato07/-Luffy that referenced this pull request Feb 20, 2025
## Summary

When transpiling `react-native` with `swc` this file caused some trouble
as it mixes ESM and CJS import/export syntax. This PR addresses this by
converting CJS exports to ESM exports. As
`ReactNativeViewConfigRegistry` is synced from `react` to `react-native`
repository, it's required to make the change here. I've also aligned the
mock of `ReactNativeViewConfigRegistry` to reflect current
implementation.

Related PR in `react-native`:
facebook/react-native#40787

DiffTrain build for commit facebook/react@ea8a861.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants