React Native with hermes-js-engine struggling to build release version
See original GitHub issueSmall description:
There are some new RegExp(/^.../)
statements used in the aws-sdk source code that hermes-js cannot parse (is not yet able to parse) and therefore leads to unsuccessful (failed) builds.
After some quick search (using
grep -r --exclude=\*map\* --exclude=\*min\* "new RegExp(/^" ./node_modules
), I found that these regular expressions are located in @aws-sdk/smithy-client/dist/cjs/date-utils.js
file.
If I remove all the usages of the @aws-sdk
everything works as expected.
My environment:
SDK version number
@aws-sdk/client-location@3.34.0
Is the issue in the browser/Node.js/ReactNative?
ReactNative (only on release builds)
Details of the browser/Node.js/ReactNative version
Output of yarn react-native info
:
info Fetching system and libraries information...
System:
OS: Linux 5.14 Arch Linux
CPU: (4) x64 Intel(R) Core(TM) i5-6200U CPU @ 2.30GHz
Memory: 383.89 MB / 15.06 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 16.9.1 - /tmp/yarn--1632607664796-0.5372215827563698/node
Yarn: 1.22.11 - /tmp/yarn--1632607664796-0.5372215827563698/yarn
npm: 7.24.1 - ~/.nvm/versions/node/v16.9.1/bin/npm
Watchman: 20210523.214641.0 - /usr/local/bin/watchman
SDKs:
Android SDK:
API Levels: 29, 30, 31
Build Tools: 28.0.3, 29.0.2, 30.0.2, 31.0.0, 31.0.0
System Images: android-30 | Google APIs Intel x86 Atom, android-30 | Google Play Intel x86 Atom
Android NDK: 22.1.7171670
IDEs:
Android Studio: AI-203.7717.56.2031.7678000
Languages:
Java: 1.8.0_292 - /usr/bin/javac
npmPackages:
@react-native-community/cli: Not Found
react: 17.0.2 => 17.0.2
react-native: 0.65.1 => 0.65.1
npmGlobalPackages:
*react-native*: Not Found
Done in 4.63s.
yarn react-native info 9.60s user 0.58s system 206% cpu 4.927 total
Steps to reproduce
Install @aws-sdk/client-location and just try to use it. Development builds are successful, but the release ones are doomed. Of course, don’t forget to enable hermes engine.
Observed behavior
Image above (in the description)
Expected behavior
At least a successful release build would be nice.
Extra text for search results (if others get stuck)
/home/darapsas/Projects/inhyr-mobile/android/app/build/generated/assets/react/release/index.android.bundle:372076:28: error: Invalid regular expression: Quantifier has nothing to repeat
var RFC3339 = new RegExp(/^(?<Y>\d{4})-(?<M>\d{2})-(?<D>\d{2})[tT](?<H>\d{2}):(?<m>\d{2}):(?<s>\d{2})(?:\.(?<frac>\d+))?[zZ]$/);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/darapsas/Projects/inhyr-mobile/android/app/build/generated/assets/react/release/index.android.bundle:372101:32: error: Invalid regular expression: Quantifier has nothing to repeat
var IMF_FIXDATE = new RegExp(/^(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun), (?<D>\d{2}) (?<M>Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (?<Y>\d{4}) (?<H>\d{2}):(?<m>\d{2}):(?<s>\d{2})(?:\.(?<frac>\d+))? GMT$/);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/darapsas/Projects/inhyr-mobile/android/app/build/generated/assets/react/release/index.android.bundle:372102:33: error: Invalid regular expression: Quantifier has nothing to repeat
var RFC_850_DATE = new RegExp(/^(?:Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (?<D>\d{2})-(?<M>Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-(?<Y>\d{2}) (?<H>\d{2}):(?<m>\d{2}):(?<s>\d{2})(?:\.(?<frac>\d+))? GMT$/);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/darapsas/Projects/inhyr-mobile/android/app/build/generated/assets/react/release/index.android.bundle:372103:29: error: Invalid regular expression: Quantifier has nothing to repeat
var ASC_TIME = new RegExp(/^(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun) (?<M>Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (?<D> [1-9]|\d{2}) (?<H>\d{2}):(?<m>\d{2}):(?<s>\d{2})(?:\.(?<frac>\d+))? (?<Y>\d{4})$/);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:7 (1 by maintainers)
@Darapsas @StampixSMO
This issue should be fixed in https://github.com/aws/aws-sdk-js-v3/pull/3008, it will be out in next release!
This is most likely due to Hermes not supporting named capturing groups: https://github.com/facebook/hermes/blob/main/doc/RegExp.md
To resolve this, named capturing groups should not be used.