diff --git a/scripts/build/babel-register.js b/scripts/build/babel-register.js index b94a0a803c1a71..e105daae90d12b 100644 --- a/scripts/build/babel-register.js +++ b/scripts/build/babel-register.js @@ -44,11 +44,16 @@ function registerForMonorepo() { function registerPackage(packageName /*: string */) { const packageDir = path.join(PACKAGES_DIR, packageName); - require('@babel/register')({ + // Prepare the config object before calling `require('@babel/register')` to + // prevent `require` calls within `getBabelConfig` triggering Babel to + // attempt to load its config from a babel.config file. + const registerConfig = { ...getBabelConfig(packageName), root: packageDir, ignore: [/\/node_modules\//], - }); + }; + + require('@babel/register')(registerConfig); } module.exports = {registerForMonorepo};