question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Hermes transforms not enabled by default when creating a new 0.70.0 project

See original GitHub issue

Description

I can tell that the Hermes Babel transforms are not enabled in brand new 0.70.0 projects.

Version

0.70.0

Output of npx react-native info

System:
    OS: macOS 12.5.1
    CPU: (8) arm64 Apple M1
    Memory: 112.94 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 18.7.0 - /opt/homebrew/bin/node
    Yarn: 1.22.15 - /usr/local/bin/yarn
    npm: 8.15.0 - /opt/homebrew/bin/npm
    Watchman: 2022.07.04.00 - /opt/homebrew/bin/watchman
  Managers:
    CocoaPods: 1.11.3 - /opt/homebrew/bin/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 21.4, iOS 15.5, macOS 12.3, tvOS 15.4, watchOS 8.5
    Android SDK: Not Found
  IDEs:
    Android Studio: 2021.2 AI-212.5712.43.2112.8512546
    Xcode: 13.4.1/13F100 - /usr/bin/xcodebuild
  Languages:
    Java: 11.0.15 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 18.1.0 => 18.1.0 
    react-native: 0.70.0 => 0.70.0 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Steps to reproduce

  1. Create a new project
    npx react-native@0.70.0 init ExampleApp
    cd ExampleApp
    
  2. Add the following code to App.js
    console.log(2n ** 42n);
    
  3. Start the project
    yarn android
    

Observe that the app crashes with:

 ERROR  TypeError: Cannot convert BigInt to number

This is because the project is using the non Hermes transforms that convert the code you added to this invalid code:

Math.pow(2n, 42n);  // You can't use `Math.pow` with `BigInt`!

The workaround is to enable the transforms in babel.config.js, but it would be preferable if 0.70.0 did this by virtue of Hermes being enabled:

module.exports = {
   presets: [
     [
       'module:metro-react-native-babel-preset',
       {unstable_transformProfile: 'hermes-stable'},
     ],
   ],
};

Snack, code example, screenshot, or link to a repository

https://snack.expo.dev/haG_X4VvG

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
motiz88commented, Sep 20, 2022

To add to @huntie’s comment: Longer-term solutions aside, we’re looking to unblock the use of BigInt by removing the exponentiation operator transform (a ** bMath.pow(a, b)) from metro-react-native-babel-preset altogether, given that both JSC and Hermes support this syntax natively. This will likely depend on https://github.com/facebook/metro/pull/871, which will be part of the next Metro version.

4reactions
lexercommented, Sep 19, 2022

@kelset is there any update or another issue we should track?

Read more comments on GitHub >

github_iconTop Results From Across the Web

React Native (Android) - Failed to transform hermes-debug.aar
1. After using command npx react-native upgrade , there are changes in number version of dependencies. I also edit build.gradle in ...
Read more >
Announcing React Native 0.70
We are excited to release a new version of React Native, 0.70.0. ... first version with Hermes, our in-house JS engine, enabled by...
Read more >
react-native | Yarn - Package Manager
Changelog. v0.69.1. Changed. iOS specific. Make all Yoga headers public and add #ifdef __cplusplus (43f831b23c by @janicduplessis) ...
Read more >
error failed to load configuration of your project. info run cli with
"Xcode no longer creates every available iOS simulator device by default. ... The issue can be reproduced using yarn or npm on a...
Read more >
Using Hermes in React Native - LogRocket Blog
Hermes is not just good for React Native applications, but contributes a ... To create a new React Native project, navigate to your...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found