Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
[standards] Umbrella issue to track migration to standard path-based requires (remove Haste) #24316
This issue tracks commits that rewrite
All modules in the RN repository will still be requireable via Haste. That is, if there's Facebook application code that uses Haste, there will be no change.
This is a spiritual continuation of #18598, which has more technical details.
Draft Announcement Notes
Replacing Haste with standard imports
In the 0.61 release of React Native, we are internally replacing "Haste"-style module imports with standard path-based imports. Instead of
Some out-of-tree implementations of other platforms, like React Native Windows, may be affected by this change if they rely on overriding files using overlapping Haste module names. There are two potential solutions for maintainers of platforms like this.
Vendoring React Native
One solution is to follow React Native for Web's approach of vendoring (copying) React Native's code into the out-of-tree platform repository. This approach is also more future-proof and works if React Native were to publish itself as a single "flat bundle" in the same manner as React, which would also be a breaking change for out-of-tree platform implementations. It also simplifies the work required if React Native were to rely on the JS interpreter's built-in import/export module system, which does not implement Haste.
React Native for Web's entry point (
import PanResponder from '../../vendor/react-native/PanResponder'; export default PanResponder;
Finally, React Native for Web provides a Babel plugin that rewrites all imports of
React Native for Web's approach provides stability, as newly published patch versions of React Native -- which may have internal breaking changes despite keeping the public API unchanged -- will not affect the vendored code at all until the maintainer intentionally updates it.
Overriding imports with Babel
Another solution is to write a Babel plugin that rewrites imports to files that need to be overridden. For example, let's say an out-of-tree platform needs to override React Native's