From e46d928be9fe670e816f6c35412321669028f36e Mon Sep 17 00:00:00 2001 From: Rob Hogan Date: Wed, 16 Sep 2026 14:36:46 +0100 Subject: [PATCH] Remove unused .babelrc.js from metro-runtime polyfills Summary: `packages/metro-runtime/src/polyfills/.babelrc.js` has had no effect since 2019, and would throw if it were ever loaded. It was added (as `packages/metro/src/lib/polyfills/.babelrc`) in 2018, when the separate `build-es5` output was dropped from `scripts/build.js`, so that the published `require` polyfill was still transpiled down to ES5 via `preset-env`. After the Babel 7 upgrade it stopped applying, because Babel 7 only loads `.babelrc` files from the root package by default - that was fixed by converting it to `.babelrc.js` and adding `babelrcRoots: ['.', 'packages/*']` to the root `babel.config.js`. A few months later, the move from `babel-jest` to a custom transformer replaced `babelrcRoots` with `babelrc: false`, and it's been dead ever since. When `preset-env` was removed in 2020 it was swapped for the `@babel/plugin-proposal-nullish-coalescing-operator` and `@babel/plugin-proposal-optional-chaining` plugins, neither of which is installed any more, so `require.resolve` would fail if Babel ever did pick it up. It isn't exported or published - `npm pack metro-runtime@0.87.0 --dry-run` doesn't include it - and nothing else references it. `require.js` gets the same build as the rest of Metro, and is transformed again by the app's own Babel config when bundled. Changelog: Internal Test plan: ``` yarn jest packages/metro-runtime node scripts/build.js ``` Tests pass, and the built `packages/metro-runtime/build/polyfills/require.js` is byte-identical to a build with the file present. --- .../metro-runtime/src/polyfills/.babelrc.js | 19 ------------------- 1 file changed, 19 deletions(-) delete mode 100644 packages/metro-runtime/src/polyfills/.babelrc.js diff --git a/packages/metro-runtime/src/polyfills/.babelrc.js b/packages/metro-runtime/src/polyfills/.babelrc.js deleted file mode 100644 index 8e59d72a06..0000000000 --- a/packages/metro-runtime/src/polyfills/.babelrc.js +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @format - * @oncall react_native - */ - -'use strict'; - -module.exports = { - plugins: [ - require.resolve('@babel/plugin-transform-flow-strip-types'), - require.resolve('@babel/plugin-proposal-nullish-coalescing-operator'), - require.resolve('@babel/plugin-proposal-optional-chaining'), - ], -};