fix: remove dead promise polyfill import from polyfillPromise.js - #57807
fix: remove dead promise polyfill import from polyfillPromise.js#57807stareezy-1 wants to merge 1 commit into
Conversation
Since Hermes is the only supported JS engine and always provides a native Promise implementation, the `else` branch in polyfillPromise.js that imports the `promise` package via `../Promise` is dead code that can never execute (`hasPromise()` is always true). This dead import causes the bundler to include the entire `promise` package (~15KB) in every app's JS bundle despite it never being used. Remove the dead branch and the unused `polyfillGlobal` import. Fixes react#57702
|
Hi @stareezy-1! 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! |
Summary
Removes the dead
elsebranch inpolyfillPromise.jsthat imports thepromisepackage. Since Hermes is the only supported JS engine and always provides a native Promise,hasPromise()is always true and the polyfill path can never execute.Fixes #57702
Changelog:
[GENERAL] [REMOVED] - Dead promise polyfill code path in polyfillPromise.js
Problem
polyfillPromise.jsconditionally imports thepromisepackage (~15KB) via../Promisein anelsebranch that can never execute:This adds unnecessary weight to every React Native app's JS bundle.
Changes
elsebranchpolyfillGlobalimport__DEV__promise rejection tracking setupTest Plan
promisepackage is no longer bundled in the JS outputHermesInternal.enablePromiseRejectionTracker