Skip to content

Remove dead code useAndroidRippleForView#56344

Open
retyui wants to merge 1 commit intofacebook:mainfrom
retyui:remove-dead-code
Open

Remove dead code useAndroidRippleForView#56344
retyui wants to merge 1 commit intofacebook:mainfrom
retyui:remove-dead-code

Conversation

@retyui
Copy link
Copy Markdown
Contributor

@retyui retyui commented Apr 7, 2026

Summary:

Metro inline plugin won't work when es import is used for Platform, to remove dead-code I use require()

similar example:

const Platform = require('../../Utilities/Platform').default;

-import Platform from '../../Utilities/Platform';
+const Platform = require('../../Utilities/Platform').default;

Before:

Screenshot 2026-04-07 at 16 13 01

After:

Screenshot 2026-04-07 at 16 12 19

Changelog:

[IOS] [CHANGED] - RemoveuseAndroidRippleForView dead-code from iOS builds

Test Plan:

1. build the app 
2. finial bundle should include `return null` as body of `useAndroidRippleForView` hook

@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 Apr 7, 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 Apr 7, 2026
@javache
Copy link
Copy Markdown
Member

javache commented Apr 7, 2026

Metro should fully support dead-code elimination for Platfrom.OS === 'ios' - I believe this is a public transform. Please check with an optimized bundle (__DEV__ = false)

See https://github.com/facebook/metro/blob/main/packages/metro-transform-plugins/src/inline-plugin.js

Copy link
Copy Markdown
Member

@javache javache left a comment

Choose a reason for hiding this comment

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

Please validate this is a production issue

@retyui
Copy link
Copy Markdown
Contributor Author

retyui commented Apr 7, 2026

@javache well in case of Platfrom.OS no dead-code elimination can be applied, as Metro can't guarantee that OS value static and won't be changed in runtime (see PR: facebook/metro#1521)


but in cases __DEV__ or process.env.NODE_ENV === '...' it works well

Screenshot 2026-04-07 at 14 49 24 Screenshot 2026-04-07 at 14 48 11

@retyui retyui requested a review from javache April 7, 2026 12:56
@javache
Copy link
Copy Markdown
Member

javache commented Apr 7, 2026

Metro specifically optimizes Platform.OS and assumes its constant. The fix would be to ensure this transform works correctly in your configuration, which we prefer over forking this code.

@retyui retyui force-pushed the remove-dead-code branch from 82e0d8c to 377f6ea Compare April 7, 2026 14:15
@retyui retyui force-pushed the remove-dead-code branch from 377f6ea to 4620888 Compare April 7, 2026 14:20
@retyui
Copy link
Copy Markdown
Contributor Author

retyui commented Apr 7, 2026

@javache you are right, I fixed it in diff. way (see updated PR desc.)

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. 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.

2 participants