From 3de989235365504468d2b6c0bb194e944bf1ce8e Mon Sep 17 00:00:00 2001 From: Alex Hunt Date: Thu, 21 Nov 2024 05:41:39 -0800 Subject: [PATCH] Skip hermes-parser under Babel for non-Flow JS code (#47568) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/47568 Resolves https://github.com/facebook/hermes/issues/1549. Changelog: [General][Fixed] - When using Babel with plain JavaScript files, support for additional user syntax plugins should be fixed (now uses Babel's parser instead of hermes-parser). There is no change for JS files annotated with `flow`, where extended JS syntax remains unsupported. Reviewed By: blakef Differential Revision: D65816797 fbshipit-source-id: 9f05e86019548ac8727ee65c2e2c417d78a406d8 --- packages/react-native-babel-preset/src/configs/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-native-babel-preset/src/configs/main.js b/packages/react-native-babel-preset/src/configs/main.js index c3b7f9d914224a..077e1a68b02287 100644 --- a/packages/react-native-babel-preset/src/configs/main.js +++ b/packages/react-native-babel-preset/src/configs/main.js @@ -25,7 +25,7 @@ function isTSXSource(fileName) { const loose = true; const defaultPlugins = [ - [require('babel-plugin-syntax-hermes-parser')], + [require('babel-plugin-syntax-hermes-parser'), {parseLangTypes: 'flow'}], [require('babel-plugin-transform-flow-enums')], [require('@babel/plugin-transform-block-scoping')], [require('@babel/plugin-transform-class-properties'), {loose}],