Skip to content

fix: use ES import for Platform instead of require - #58453

Closed
retyui wants to merge 1 commit into
react:mainfrom
retyui:feat/retyui/no-require-for-platform
Closed

retyui wants to merge 1 commit into
react:mainfrom
retyui:feat/retyui/no-require-for-platform

Conversation

@retyui

@retyui retyui commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Summary:

Previously, the Metro inline plugin for Platform didn't work inside React Native files that used ES imports for Platform (making require() the only way for the inline plugin to do its job).

Read more: react/metro#1521 (comment)

Since the inline plugin was moved from metro to react-native-babel-preset (PR: #57848), this issue has been resolved, so using require() is no longer necessary.

Changelog:

[INTERNAL] [CHANGED] - Use ES module imports for Platform API

Test Plan:

...

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 10, 2026
@facebook-github-tools facebook-github-tools Bot added p: Callstack Partner: Callstack Partner Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. labels Sep 10, 2026
@vzaidman
vzaidman requested review from coado and robhogan September 15, 2026 08:48
@vzaidman

Copy link
Copy Markdown
Contributor

@robhogan was there a reason to require it and not import it?

@retyui

retyui commented Sep 15, 2026

Copy link
Copy Markdown
Contributor Author

@vzaidman also for reference PR that did opposite : #57121

@robhogan

robhogan commented Sep 15, 2026 •

Copy link
Copy Markdown
Collaborator

@robhogan was there a reason to require it and not import it?

Yes, previously the Metro inline plugin wouldn't detect imports of Platform unless experimentalImportSupport was enabled to replace Babel ESM->CJS. So Meta's pipeline would inline imports of Platflorm but OSS by default only inlined require.

The new RN inline plugin can handle import because it works on source before ESM lowering, so this change should be safe.

It's be great to see an end-to-end release JS bundle before and after to prove that this doesn't change what's inlined.

@meta-codesync

meta-codesync Bot commented Sep 15, 2026

Copy link
Copy Markdown

@vzaidman has imported this pull request. If you are a Meta employee, you can view this in D120122290.

@meta-codesync meta-codesync Bot closed this in b9adf95 Sep 16, 2026
@meta-codesync meta-codesync Bot added the Merged This PR has been merged. label Sep 16, 2026
@meta-codesync

meta-codesync Bot commented Sep 16, 2026

Copy link
Copy Markdown

@vzaidman merged this pull request in b9adf95.

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. p: Callstack Partner: Callstack Partner 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