From 2c8d037d0630825de378fc6b110bdec744a1d3e2 Mon Sep 17 00:00:00 2001 From: Alex Hunt Date: Tue, 12 Nov 2024 07:53:31 -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. Differential Revision: D65816797 --- 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}],