Conversation
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.
robhogan
marked this pull request as ready for review
September 16, 2026 13:47
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
packages/metro-runtime/src/polyfills/.babelrc.jshas had no effect since 2019, and would throw if it were ever loaded, since it lists plugins we no longer have installed. It's an artifact of Metro's previous reliance onbabel-jest, before Babel 7.It isn't exported or published -
npm pack metro-runtime --dry-rundoesn't include it - and nothing else references it.require.jsalongside it is transformed the same way as any other Flow source in Metro.(Archaeology: It was added in d02b939 and became a no-op in dd0b429 . The idea was that we'd npm-publish a version of
require.jssuitable for running on device without further transformation, but we now treat it the same as any other runtime code.)Changelog: Internal
Test plan:
CI