Fix: platform inline transformation#1521
Fix: platform inline transformation#1521IvanIhnatsiuk wants to merge 2 commits intofacebook:mainfrom
Conversation
|
Hi @IvanIhnatsiuk! Thank you for your pull request and welcome to our community. Action RequiredIn 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. ProcessIn 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 If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
|
@rshest has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
|
@robhogan Sorry for the tag, but I do not know who can I tag to ask about this PR 😄 Do you have any plans to merge/close this one? |
|
Hi @IvanIhnatsiuk - sorry this got dropped, I think #1641 might've superseded it? That was released in 0.83.4 |
|
@robhogan I've checked it on the latest ver. of react native (0.84.1) and issue is still exist facebook/react-native#56344 (comment) |
Summary
I noticed that when using esmodule named import of platform dead code elimination of Platform.OS did not work.
In this PR, I added logic to find to check that Platform.OS was used from
require('react-native). That way, it doesn't matter what name the react-native import has.Changelog:
Before:
Transformed:
After:
Transformed:
Test plan
Added a test for the case similar to how code looks in the transformed bundle before being passed to the inline plugin. Also tested this in an app bundle and looked for instances of Platform.OS than should be inlined and made sure there was none.