Skip to content

Proof of Concept Insights - Removing Babel Plugins #4

@bentobox19

Description

@bentobox19

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

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions