🚇 The JavaScript bundler for React Native. https://facebook.github.io/metro
Go to file
Jean Lauliac 86eb9680ac ModuleResolution: integrate Haste resolution as part of the overall resolution logic
Summary:
This is part of the efforts to clean up and extract the resolution logic. In this diff, the haste resolution is moved as part of the main resolution function rather than having 2 separate top-level functions. The reason for doing this is that logic is duplicated otherwise, making the already complex code harder to follow still. An example of duplicated logic is the call to `isRelativeImport`, that is done both in ResolutionRequest and ModuleResolution's node resolver. In that case, we never want to use Haste. Another duplication is the redirect of requires of package/haste names. With this changeset it is done in a single place at the beginning of the algo.

This changeset causes slight changes in behaviors. For example, consider `require('Foo/')`. A lookup of `Foo` would be done in the package `browser` field for a potential redirect. With this new code, we'll only look for `Foo/` in the redirect map. My opinion is that this is for the better, as this uniformize the way it works with Node.js `node_module` packages, making resolution more predictable. We should, additionally, actively strive to get rid of trailing slashes anywhere they might be in RN as they bring no apparent technical feature, but more confusion (I might be missing context, naturally).

Next steps will be to clean up `_resolveHasteDependency` completely, removing the callsite `try..catch` in favor of saner conditionals, and enforcing Haste packages to resolve if they exist (right now if a Haste package is found but corrupted, we just continue merrily trying to resolve the module with the rest of the logic; we should hash-crash instead, same as has been done for `resolvePackage`).

Reviewed By: cpojer

Differential Revision: D6642347

fbshipit-source-id: 2f40575b35916b644f342e0267c465a89bee202c
2017-12-29 04:45:07 -08:00
.github Rename metro-bundler to metro 2017-11-30 11:56:25 +00:00
docs Capitalized ‘Express’ 2017-12-05 11:29:42 -08:00
flow-typed Fix flow in assetTransformer 2017-12-20 14:29:01 -08:00
packages ModuleResolution: integrate Haste resolution as part of the overall resolution logic 2017-12-29 04:45:07 -08:00
scripts Rename metro-bundler to metro 2017-11-30 11:56:25 +00:00
website Fix 404 on front page 'Learn more' link 2017-12-07 13:01:55 -08:00
.babelrc fix support for node v4 2017-06-26 05:08:50 -07:00
.eslintignore Initial repository structure. 2017-01-26 12:56:40 +00:00
.eslintrc.js Consolidate eslint config + fix some issues 2017-12-11 12:32:20 -08:00
.flowconfig @allow-large-files [flow] deploy flow 0.60 2017-12-04 13:30:30 -08:00
.gitignore Rename metro-bundler to metro 2017-11-30 11:56:25 +00:00
.npmignore Initial repository structure. 2017-01-26 12:56:40 +00:00
.travis.yml Initial repository structure. 2017-01-26 12:56:40 +00:00
CHANGELOG.md Rename metro-bundler to metro 2017-11-30 11:56:25 +00:00
CODE_OF_CONDUCT.md Add CODE_OF_CONDUCT.md 2017-11-22 02:58:16 -08:00
CONTRIBUTING.md Rename metro-bundler to metro 2017-11-30 11:56:25 +00:00
LICENSE Rename metro-bundler to metro 2017-11-30 11:56:25 +00:00
PATENTS Rename metro-bundler to metro 2017-11-30 11:56:25 +00:00
README.md Rename metro-bundler to metro 2017-11-30 11:56:25 +00:00
appveyor.yml Initial repository structure. 2017-01-26 12:56:40 +00:00
circle.yml Add script to automatically deploy the website 2017-11-30 04:03:29 -08:00
lerna.json Bump metro to v0.24.3 2017-12-20 19:31:01 -08:00
package.json Update to Jest 22.0.0 2017-12-18 05:20:08 -08:00
yarn.lock Update to Jest 22.0.0 2017-12-18 05:20:08 -08:00

README.md

Metro Bundler

CircleCI Build Status npm version

🚇 The JavaScript bundler for React Native.

  • 🚅 Fast: We aim for sub-second reload cycles, fast startup and quick bundling speeds.
  • ⚖️ Scalable: Works with thousands of modules in a single application.
  • ⚛️ Integrated: Supports every React Native project out of the box.

This project was previously part of the react-native repository. In this smaller repository it is easier for the team working on Metro Bundler to respond to both issues and pull requests. See react-native#13976 for the initial announcement.

Installation & Documentation

See the Metro website for documentation.