-
Notifications
You must be signed in to change notification settings - Fork 636
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ES Numeric Separators broken by babel (Unexpected token: name (_000)) #645
Comments
Hey @westphalen, would you be interested in sending a PR that adds |
@motiz88 after having a weird issue where numeric separators were only an issue when building for iOS without Hermes (it works fine in Should it go in https://github.com/facebook/metro/blob/master/packages/metro-react-native-babel-preset/src/passthrough-syntax-plugins.js or https://github.com/facebook/metro/blob/master/packages/metro-react-native-babel-preset/src/configs/main.js? |
@SConaway I'd happily review a PR that adds the numeric separator plugin to https://github.com/facebook/metro/blob/master/packages/metro-react-native-babel-preset/src/configs/main.js. We need to transform this syntax rather than just pass it through, because some of the engines we target don't natively support it. I guess that's what you may have seen on iOS, since JavaScriptCore only added support for this syntax in iOS 13 per https://caniuse.com/mdn-javascript_grammar_numeric_separators. |
Ok cool! Working on getting my developer environment setup now. Is there are a reason why |
|
Yes, fair. Let me know if there's anything else needed. I did update the list of included syntax transforms. |
Any work around for libraries that use this syntax and need to be transformed in react-native? |
Nope, my PR (#681) hasn’t been merged yet. |
is there any update on this issue ? |
on module.exports = {
transformer: {
getTransformOptions: async () => ({
transform: {
experimentalImportSupport: false,
inlineRequires: true,
},
}),
plugins: ['@babel/plugin-proposal-numeric-separator'],
},
} |
@felipemillhouse this works for me in debug mode, but not when building a release build from Xcode. Have you experienced this?
Edit: It seems like this issue is caused by |
@grit96 For me it also works on release (archiving). I'm using Don't forget to |
Very strange. I'm on
|
For those wondering what may have caused this check your code for a number like |
Any thoughts on supporting this with metro? |
Just switch to https://github.com/omgovich/colord |
thanks! In my case i just needed to convert hex to rgb, i used https://github.com/sindresorhus/hex-rgb for that, but its actually a quite simple functions. By the way, I was really puzzled about the attitude of the maintainer of |
The maintainer is kind of stubborn, but hey, anyone is free to fork this and fix that 1 char issue. |
actually a lot of people did ;-) It must be hard to have such a prominent name on github and npm and to have to deal with all those poor souls who have to use "old" bundlers ;-) but thats off-topic.... i had the same issue with storybook and decided to remove the library, but i am curious if anyone knows the actual fix |
@macrozone any drop-in replacement for it? |
@cristianoccazinsp scroll up a little to my reply 😉 |
replace uglify-es with terser // metro.config.js
module.exports = {
transformer: {
minifierPath: 'metro-minify-terser',
},
} |
I stumbled into this issue today too, doing the following sorted the issue for me (YMMV):
In the root of your project, create the file /**
* Babel configuration override for React Native
* Includes the @babel/plugin-proposal-numeric-separator plugin to fix _ numerical formatting
*
*/
module.exports = {
plugins: ['@babel/plugin-proposal-numeric-separator'],
presets: ["module:metro-react-native-babel-preset"]
} |
@chriswiggins Thanks, this fixed it for me! Simple solution. |
* feat: make sfu call object to accept rn webrtc * patch rtcrtpsender and rtcrtpreceiver and add polyfill for uuid * chore: fix issues after merge with main * fix: remove numeric symbols as its not compatible with metro for react-native ref: facebook/metro#645 * feat: add healper to get username fragment in rn webrtc * feat: add callID randomiser to RN * feat: add callID randomiser to RN * fix: typing issues with stream video client * chore(react-native): remove unused modules * fix: remove numeric symbols as its not compatible with metro for react-native ref: facebook/metro#645 * chore(react-native): remove unused modules * fix: remove numeric symbols as its not compatible with metro for react-native ref: facebook/metro#645 * chore: remove usage of webrtc/types * chore: remove the previously made generics for connection config and use global polyfilling * feat: add polyfill of rn-webrtc * feat: wip use participant videos from the shared state store * feat: add timeout in measureResourceLoadLatencyTo * chore: remove the temporary method that was used by react native * chore: remove unnecessary console log * fix: floating point numbers are not allowed in update subscriptions * chore: remove unnecessary console log * feat: filter out current user participant * fix: remove linking event listener * chore: remove unused imports * fix: patch crash in rn webrtc for undefined method on track * chore: revert to using the staging urls by default * chore: update yarn lock for webrtc patch * chore: update the rn webrtc patch * chore: remove the generics implementation in react-sdk * chore: remove the generics implementation in react dogfood * fix: latency call must get the blob of response * chore: revert the changes done to sfu call object * feat: patch ice candidate getter for react-native * fix: if only local participant is present then show it as full view * chore: align coordinator ws url * chore: use same length to get random call id as react dogfood app * fix: adding angular-sdk dir to metro.config blockList Co-authored-by: vanGalilea <galiliziv@gmail.com>
This should be fixed by the release of Metro 0.73, which is bundled with React Native 0.71. The root cause here is Metro's previous use of the In Metro 0.67 we introduced support for async minifiers, and therefore Terser 5 (#606). In Metro 0.73 we made Terser the default minifier (#871). Using Terser with React Native
|
…hen not in Hermes (#681) Summary: Changelog: * **[Feature]**: Enable ES2021 numeric separator syntax in React Native **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](#645 (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. Pull Request resolved: #681 Reviewed By: rubennorte Differential Revision: D29556107 Pulled By: motiz88 fbshipit-source-id: 2d66bf8993cb10dd1f020939f4ad1bbf49cccc19
Do you want to request a feature or report a bug?
Bug / improvement for
metro-react-native-babel-preset
What is the current behavior?
A build error that makes little sense in the context of a larger code base. The line:col isn't true to the original code, I had to
console.log
from within/metro/src/JSTransformer/worker.js
to find the problematic line.If the current behavior is a bug, please provide the steps to reproduce and a minimal repository on GitHub that we can
yarn install
andyarn test
.react-native init MyApp --template react-native-template-typescript
const thousand = 1_000;
Minimal repository reproducing the issue:
git clone https://github.com/westphalen/metro-babel-preset-numeric-separators
yarn install
yarn build
What is the expected behavior?
Since the boilerplate project is set up to support TypeScript and es2017/esnext, one would expect that ES Numeric Separators were supported out of the box.
Solution
yarn install @babel/plugin-proposal-numeric-separator
Update
babel.config.js
with this line:Would suggest this plugin is included by default in
metro-react-native-babel-preset
Please provide your exact Metro configuration and mention your Metro, node, yarn/npm version and operating system.
node -v
v10.22.0"metro-react-native-babel-preset": "0.63.0"
metro "0.58.0"
The text was updated successfully, but these errors were encountered: