Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Respect transitive deps when using
nodeModulesPaths
(#738)
Summary: **Summary** This fixes #737 take a look at the issue for more info. I've also added a test case to hopefully catch this in the future. The order of the paths is important in this change. This change changes the resolution order slightly, we can see this by observing `allDirPaths` https://github.com/facebook/metro/blob/02fade69cad95488e1afba0c3dba8e25d8453bc5/packages/metro-resolver/src/resolve.js#L126-L128 Without this change, the `allDirPaths` looks like this: ``` [ '/other-root/node_modules/banana-module', '/other-root/node_modules/banana/node_modules/banana-module', '/other-root/node_modules/node_modules/banana-module', '/other-root/node_modules/banana-module', '/node_modules/banana-module' ] ``` See how the `banana-module` nested inside `banana` is second & not first. With this change `allDirPaths` is update to this: ``` [ '/other-root/node_modules/banana/node_modules/banana-module', '/other-root/node_modules/node_modules/banana-module', '/other-root/node_modules/banana-module', '/node_modules/banana-module', '/other-root/node_modules/banana-module' ] ``` We correctly attempt to resolve the transitive `banana-module` dependency first. **Test plan** Added a unit test Pull Request resolved: #738 Reviewed By: motiz88 Differential Revision: D32310356 Pulled By: GijsWeterings fbshipit-source-id: 158e401cb47cc4a4bcc11687ef7e34caa8ce3dde
- Loading branch information