PoC
https://github.com/LavaMoat/docs/blob/main/react-native-and-ses-lockdown.md
Discussion
The following errors while running the lockdown() function:
TypeError: (0 , _getPrototypeOf2.default) is not a function
or
ERROR failed to delete intrinsics.%PromisePrototype%.then.prototype [TypeError: Unable to delete property.]
After a number of patching iterations, including:
It was concluded that is more straightforward to just forfeit some plugins at the React Native preset.
PoC Solution
- Forfeit the React Native Preset at
babel.config.js.
- Manually add to the above configuration file the plugins from this very preset in the folllowing fashion:
Items of action
- Investigate the minimum RN plugins needed to actually run the mobile application
- Find out which procedure is actually calling to polyfill
Promise
- Suggestion (by @naugtur) Instead of patching RN we need to look at how they are checking the built-in promise on the global object because they shouldn't be overwriting this.
- Maybe we want to create a transform for the build package to prevent babel regenerator to put these monkey patches.
- So, if RN is changing things, we could change them back!
- This approach avoids patches, avoids creating a custom preset, and require us to just add a plugin at
babel.config.js just after the preset.
- Add
isHermes plugins.
PoC
https://github.com/LavaMoat/docs/blob/main/react-native-and-ses-lockdown.md
Discussion
The following errors while running the
lockdown()function:or
After a number of patching iterations, including:
It was concluded that is more straightforward to just forfeit some plugins at the React Native preset.
@babel/plugin-transform-runtime_extendshelper adds a polyfill atnode_modules/@babel/runtime/helpers/extends.js_getPrototypeOfhelper adds a polyfill atnode_modules/@babel/runtime/helpers/getPrototypeOf.jspromisePromiseprotoytpeproperty of its function instances@babel/plugin-transform-regeneratorlockdown()o write readonly objects.PoC Solution
babel.config.js.Items of action
Promisebabel.config.jsjust after the preset.isHermesplugins.