Permalink
Browse files

Refactor how symlinks are discovered in local-cli, support scoped mod…

…ules

Summary:
This PR refactors the symlink finding logic in local-cli in order to support nested symlinked modules as well as symlinked scoped NPM modules.

Run tests, or try project with `npm link`'ed or `yarn link`'ed dependencies.
Closes #15776

Reviewed By: cpojer

Differential Revision: D5823008

Pulled By: jeanlauliac

fbshipit-source-id: f2daeceef37bed2f8a136a0a5918730f9832884c
  • Loading branch information...
Adam Miskiewicz authored and facebook-github-bot committed Sep 14, 2017
1 parent e846a9f commit 39f83c4a12b8350e331c3a6c575a2cab64950d7a
View
@@ -14,7 +14,7 @@
* found when Flow v0.54 was deployed. To see the error delete this comment and
* run Flow. */
const blacklist = require('metro-bundler/src/blacklist');
const findSymlinksPaths = require('./findSymlinksPaths');
const findSymlinkedModules = require('./findSymlinkedModules');
const fs = require('fs');
const getPolyfills = require('../../rn-get-polyfills');
const invariant = require('fbjs/lib/invariant');
@@ -168,14 +168,15 @@ function getProjectPath() {
return path.resolve(__dirname, '../..');
}
const resolveSymlink = (roots) =>
roots.concat(
findSymlinksPaths(
path.join(getProjectPath(), 'node_modules'),
roots
)
const resolveSymlinksForRoots = roots =>
roots.reduce(
(arr, rootPath) => arr.concat(
findSymlinkedModules(rootPath, roots)
),
[...roots]
);
/**
* Module capable of getting the configuration out of a given file.
*
@@ -195,9 +196,9 @@ const Config = {
getProjectRoots: () => {
const root = process.env.REACT_NATIVE_APP_ROOT;
if (root) {
return resolveSymlink([path.resolve(root)]);
return resolveSymlinksForRoots([path.resolve(root)]);
}
return resolveSymlink([getProjectPath()]);
return resolveSymlinksForRoots([getProjectPath()]);
},
getProvidesModuleNodeModules: () => providesModuleNodeModules.slice(),
getSourceExts: () => [],
Oops, something went wrong.

0 comments on commit 39f83c4

Please sign in to comment.