LavaMoat / docs

React Native docs
1 stars 3 forks source link

Proof of Concept Insights - Removing the Promise Polyfill at RN #5

Closed bentobox19 closed 1 year ago

bentobox19 commented 2 years ago

PoC

https://github.com/LavaMoat/docs/blob/main/react-native-and-ses-lockdown.md

Discussion

Even after forfeiting certain plugins, creating a custom preset the following error appears:

failed to delete intrinsics.Promise.resolve.prototype

Tracking on which procedure is replacing the built-in promise takes us to the following chain of facts:

require('./setUpSystrace');
require('./setUpErrorHandling');
require('./polyfillPromise');
require('./setUpRegeneratorRuntime');
require('./setUpTimers');
if (global?.HermesInternal?.hasPromise?.()) {

//  <snippet>

} else {
  polyfillGlobal('Promise', () => require('../Promise'));
}
const Promise = require('promise/setimmediate/es6-extensions');

which calls the Promise polyfill at node_modules/promise/src/es6-extensions.js.

PoC Solution

// require('./polyfillPromise');

Items of Action

Similar to https://github.com/LavaMoat/docs/issues/4

leotm commented 1 year ago

following up latest RN PoCs

we only have warnings instead of previous errors 🎉

tolerable as we have fully functioning Android/iOS RN apps ignorable via RN's internal LogBox like we're doing

so we can close this as no longer blocking now under more complete analysis in above issue

in order to fix SES-detected non-standard Promiseness on either

to arrive at 0 warnings