metro
metro copied to clipboard
Add `@babel/plugin-proposal-numeric-separator` to the babel plugins when not in Hermes
Summary
This PR solves issue #645. It adds @babel/plugin-proposal-numeric-separator
to the list of babel plugins when not using Hermes to more closely match ES2021. Now that ES2021 has been finalized, people will probably (?βI know I did) expect 1_000_000
to be treated as a valid number.
As I noted in a comment in #645, should @babel/preset-env
be included instead of including many different plugins manually? Even for engines like Hermes which don't need all the same transforms as JSC, I don't think the unneeded transforms would drastically increase the bundle size, right?
Test plan
Tested it using a sample app on "react-native": "0.65.0-rc.2"
. Solves the react-native bundle
issue on iOS (only tested on device as I encountered issues compiling for the simulator) and Android production / release builds when not using Hermes.
@motiz88 has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
@motiz88 any updates on the state of this one?
Until this is merged, the current workaround is outlined here: https://github.com/facebook/metro/issues/645#issuecomment-1144385337
Hi, do you plan to merge this request?
@motiz88 is there any updates on this? Would love it if this could land βΊοΈ
@kelset @aamagda @LinusU This PR is all good to go, however at this point we'll need to wait until after Meta's internal holiday code freeze. Changes should land in very early 2023, apologies! ππ»
I'm not sure this is actually necessary any more - the error came from uglify-es
minifier, which is no longer our default and is due for removal. Since the switch to terser
, I believe we support numeric separators all the way through the stack.
A bit more on how you can use Terser with an older Metro version here: https://github.com/facebook/metro/issues/645#issuecomment-1359307444
(Edit: There is actually very niche use case - because RN supports iOS 12.4 which pre-dates numeric separator support, anyone running unminified code through JSC on iOS 12.4 could still be caught out)
@motiz88 merged this pull request in facebook/metro@22bc39f620d2f1e72e714fe9d79d49f5a46190aa.