metro icon indicating copy to clipboard operation
metro copied to clipboard

Add `@babel/plugin-proposal-numeric-separator` to the babel plugins when not in Hermes

Open SConaway opened this issue 3 years ago β€’ 3 comments

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.

SConaway avatar Jul 05 '21 21:07 SConaway

@motiz88 has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

facebook-github-bot avatar Jul 06 '21 11:07 facebook-github-bot

@motiz88 any updates on the state of this one?

kelset avatar Sep 02 '21 08:09 kelset

Until this is merged, the current workaround is outlined here: https://github.com/facebook/metro/issues/645#issuecomment-1144385337

chriswiggins avatar Jun 02 '22 03:06 chriswiggins

Hi, do you plan to merge this request?

aamagda avatar Dec 01 '22 10:12 aamagda

@motiz88 is there any updates on this? Would love it if this could land ☺️

LinusU avatar Dec 14 '22 17:12 LinusU

@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! πŸ™πŸ»

huntie avatar Dec 20 '22 11:12 huntie

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)

robhogan avatar Dec 20 '22 12:12 robhogan

@motiz88 merged this pull request in facebook/metro@22bc39f620d2f1e72e714fe9d79d49f5a46190aa.

facebook-github-bot avatar Jan 11 '23 19:01 facebook-github-bot