Open source our jest-haste-map fork as metro-file-map by robhogan · Pull Request #812 · react/metro (original) (raw)

@robhogan @facebook-github-bot

Summary:

Motivation

Internally at Meta we need to make various modifications to jest-haste-map for use by Metro (eg instrumentation, internal cache support), which up to now we've achieved using a fork, a subclass, the hasteMapModulePath option and some monkey-patching.

This isn't an ideal situation, and we're also coming up against the limits of what we can do whilst remaining faithful to the jest-haste-map API. We don't want to bloat an open source Jest subpackage (which rightly serves Jest first) with Metro-specific accommodations, and we want to be able to make changes, including breaking changes, at Metro's release cadence.

Approach

Therefore, we're publishing our lightly-modified fork of jest-haste-map@27.3.1 as metro-file-map and making it a first-class Metro citizen, with the intention to decouple from Jest and make updates and modifications with fewer constraints.

jest-haste-map is still heavily in use at Meta by Jest itself, so we'll still look to share/upstream as much as makes sense, and we'll be open to re-partitioning (for direct code sharing) or even re-converging down the line.

Possibilities

Additionally, I'm optimistic that reducing the friction around Metro-oriented file crawling/watching might enable/encourage tackling some longstanding issues, such as symlink support and lazy loading.

Reviewed By: motiz88

Differential Revision: D35744151

fbshipit-source-id: 0e2b621dccec464b377b0ae0d91436149890b1d7