Skip to content

Remove unused .babelrc.js from metro-runtime polyfills - #1935

Open
robhogan wants to merge 1 commit into
mainfrom
pr1935
Open

robhogan wants to merge 1 commit into
mainfrom
pr1935

Conversation

@robhogan

@robhogan robhogan commented Sep 16, 2026

Copy link
Copy Markdown
Collaborator

packages/metro-runtime/src/polyfills/.babelrc.js has 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 on babel-jest, before Babel 7.

It isn't exported or published - npm pack metro-runtime --dry-run doesn't include it - and nothing else references it. require.js alongside 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.js suitable for running on device without further transformation, but we now treat it the same as any other runtime code.)

Changelog: Internal

Test plan:
CI

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.
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 16, 2026
@robhogan
robhogan marked this pull request as ready for review September 16, 2026 13:47
@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Sep 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant