From e08c7eb22adbe427aaa6f76268b37f01b781285e Mon Sep 17 00:00:00 2001 From: Vitali Zaidman Date: Mon, 14 Oct 2024 06:30:59 -0700 Subject: [PATCH] fix how @babel/register is used and update it (#46987) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/46987 X-link: https://github.com/facebook/metro/pull/1371 Update `babel/register` to latest version, fixing the bug that were preventing us from updating it previously. Changelog: [Internal] Reviewed By: huntie Differential Revision: D64245277 fbshipit-source-id: f3d07b06a11fbe3a0ed28e22f5b687541782dda9 --- scripts/build/babel-register.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/build/babel-register.js b/scripts/build/babel-register.js index cc1513fa1abf3c..dec78cafbd6f11 100644 --- a/scripts/build/babel-register.js +++ b/scripts/build/babel-register.js @@ -30,7 +30,12 @@ function registerForMonorepo() { return; } - require('metro-babel-register')([PACKAGES_DIR]); + if (process.env.FBSOURCE_ENV === '1') { + // $FlowExpectedError[cannot-resolve-module] - Won't resolve in OSS + require('@fb-tools/babel-register'); + } else { + require('metro-babel-register')([PACKAGES_DIR]); + } isRegisteredForMonorepo = true; }