-
Notifications
You must be signed in to change notification settings - Fork 24.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Symlink support for packager #9009
Conversation
By analyzing the blame information on this pull request, we identified @philikon and @christopherdro to be potential reviewers. |
Cc @matryoshcow, our new Packager man in RN team |
FYI, big changes will be coming to packager, so all changes to current one need to be considered |
@Kureev, this is pretty neat! A couple of thoughts:
bonus nitpick: one-letter variable names are the reason why we can't have nice things :) |
Hi @matryoshcow! About your notes:
|
@matryoshcow If I have no symlinks in node_modules, this feature is disabled. This way the feature is only enabled for people who want to use it. It might happen that people have symlinks in node_modules without knowing about it though, which could be confusing. Printing info about the found symlinks on packager startup could help. Making this optional with a packager argument would work too, but people would have to learn about the extra argument (Google -> StackOverflow etc., figuring out if info is up to date which is extra work everyone has to do), and what if people launch the packager using Xcode? There are several different ways people launch the packager which makes it more work to make the feature super easy to use. |
I'll request changes just for adding some debugging output so people know they're using this feature. Agree with @matryoshcow's nit that some variable names could be made a little bit clearer, for example:
|
In short I agree with @Kureev that making this "just work" is a nice developer experience, compared to having to figure out how to enable the feature. |
A concern that an extra walk through the node_modules folder slows down On Wed, Jul 27, 2016 at 1:05 PM, Martin Konicek [email protected]
|
@@ -74,6 +75,9 @@ function _server(argv, config, resolve, reject) { | |||
? argToArray(args.projectRoots) | |||
: config.getProjectRoots(); | |||
|
|||
args.projectRoots = args.projectRoots | |||
.concat(findSymlinksPaths(path.resolve(process.cwd(), 'node_modules'))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This means 750 sync lstat operations during packager start.
@mkonicek hmm... agreed - making this "just work" is a good idea, as long as it doesn't slow down the startup time. Since we're only talking about node_modules here the overhead may be negligible even for us, but let's confirm this before we commit to patching it in. |
@Kureev let's add this under a flag to begin with and perhaps log the symlink resolution time; we can enable it by default once we've observed it for a bit. |
Right, EDIT: Oh wait, internally at fb there are a lot of folders in node_modules (when starting the packager from the RN folder). Good point @bestander about this being 750 sync checks. With npm 2 I only have two folders in my app's node_modules: |
Summary: In response to [this comment](#9009 (comment)). I could be wrong here, but I think Watchman can't handle symlinks, so we need to make sure symlinks-to-symlinks are handled up front. Closes #9792 Differential Revision: D3858349 Pulled By: bestander fbshipit-source-id: f3a34dae90ed9a7004a03158288db5e1932bfc69
What's the current status of this? I found that via using npm link, watchman broke because it referenced a symlink to a symlink. Code: module.exports = function findSymlinksPaths(lookupFolder) {
const timeStart = Date.now();
const folders = fs.readdirSync(lookupFolder);
const resolvedSymlinks = folders.map(folder => path.resolve(lookupFolder, folder))
.filter(folderPath => fs.lstatSync(folderPath).isSymbolicLink())
.map(symlink => fs.realpathSync(path.resolve(lookupFolder, fs.readlinkSync(symlink))));
const timeEnd = Date.now();
console.log(`Scanning ${folders.length} folders for symlinks in ${lookupFolder} (${timeEnd - timeStart}ms)`);
return resolvedSymlinks;
}; |
@ryanlinnane Check out #9792 and let me know if you still have issues. |
I agree we should figure out a path forward to support this both in RNP and in Jest. Give us some time to get our house in order please, as @bestander pointed out we are planning some pretty significant changes. |
Summary: Support symlinks under `node_modules` for all local-cli commands. PR #9009 only adds symlink support to the packager. But other cli commands like `react-native bundle` creates its own instance of packager that doesn't have symlinks as part of its project roots, which results in the bundler breaking since it cannot find modules that you have symlinked. This change ensures all `local-cli` commands add symlinks to its project roots. Test plan (required) 1. Create a symlink in node_modules (for instance use npm/yarn link) 2. Run `react-native bundle`. Closes #11810 Differential Revision: D4487741 fbshipit-source-id: 87fe44194134d086dca4eaca99ee5742d6eadb69
Summary: Support symlinks under `node_modules` for all local-cli commands. PR facebook#9009 only adds symlink support to the packager. But other cli commands like `react-native bundle` creates its own instance of packager that doesn't have symlinks as part of its project roots, which results in the bundler breaking since it cannot find modules that you have symlinked. This change ensures all `local-cli` commands add symlinks to its project roots. Test plan (required) 1. Create a symlink in node_modules (for instance use npm/yarn link) 2. Run `react-native bundle`. Closes facebook#11810 Differential Revision: D4487741 fbshipit-source-id: 87fe44194134d086dca4eaca99ee5742d6eadb69
Summary: Support symlinks under `node_modules` for all local-cli commands. PR facebook#9009 only adds symlink support to the packager. But other cli commands like `react-native bundle` creates its own instance of packager that doesn't have symlinks as part of its project roots, which results in the bundler breaking since it cannot find modules that you have symlinked. This change ensures all `local-cli` commands add symlinks to its project roots. Test plan (required) 1. Create a symlink in node_modules (for instance use npm/yarn link) 2. Run `react-native bundle`. Closes facebook#11810 Differential Revision: D4487741 fbshipit-source-id: 87fe44194134d086dca4eaca99ee5742d6eadb69
Summary: Support symlinks under `node_modules` for all local-cli commands. PR facebook#9009 only adds symlink support to the packager. But other cli commands like `react-native bundle` creates its own instance of packager that doesn't have symlinks as part of its project roots, which results in the bundler breaking since it cannot find modules that you have symlinked. This change ensures all `local-cli` commands add symlinks to its project roots. Test plan (required) 1. Create a symlink in node_modules (for instance use npm/yarn link) 2. Run `react-native bundle`. Closes facebook#11810 Differential Revision: D4487741 fbshipit-source-id: 87fe44194134d086dca4eaca99ee5742d6eadb69
Summary: Support symlinks under `node_modules` for all local-cli commands. PR facebook#9009 only adds symlink support to the packager. But other cli commands like `react-native bundle` creates its own instance of packager that doesn't have symlinks as part of its project roots, which results in the bundler breaking since it cannot find modules that you have symlinked. This change ensures all `local-cli` commands add symlinks to its project roots. Test plan (required) 1. Create a symlink in node_modules (for instance use npm/yarn link) 2. Run `react-native bundle`. Closes facebook#11810 Differential Revision: D4487741 fbshipit-source-id: 87fe44194134d086dca4eaca99ee5742d6eadb69
Summary: Support symlinks under `node_modules` for all local-cli commands. PR facebook#9009 only adds symlink support to the packager. But other cli commands like `react-native bundle` creates its own instance of packager that doesn't have symlinks as part of its project roots, which results in the bundler breaking since it cannot find modules that you have symlinked. This change ensures all `local-cli` commands add symlinks to its project roots. Test plan (required) 1. Create a symlink in node_modules (for instance use npm/yarn link) 2. Run `react-native bundle`. Closes facebook#11810 Differential Revision: D4487741 fbshipit-source-id: 87fe44194134d086dca4eaca99ee5742d6eadb69
Summary: Support symlinks under `node_modules` for all local-cli commands. PR facebook#9009 only adds symlink support to the packager. But other cli commands like `react-native bundle` creates its own instance of packager that doesn't have symlinks as part of its project roots, which results in the bundler breaking since it cannot find modules that you have symlinked. This change ensures all `local-cli` commands add symlinks to its project roots. Test plan (required) 1. Create a symlink in node_modules (for instance use npm/yarn link) 2. Run `react-native bundle`. Closes facebook#11810 Differential Revision: D4487741 fbshipit-source-id: 87fe44194134d086dca4eaca99ee5742d6eadb69
Summary: Support symlinks under `node_modules` for all local-cli commands. PR facebook#9009 only adds symlink support to the packager. But other cli commands like `react-native bundle` creates its own instance of packager that doesn't have symlinks as part of its project roots, which results in the bundler breaking since it cannot find modules that you have symlinked. This change ensures all `local-cli` commands add symlinks to its project roots. Test plan (required) 1. Create a symlink in node_modules (for instance use npm/yarn link) 2. Run `react-native bundle`. Closes facebook#11810 Differential Revision: D4487741 fbshipit-source-id: 87fe44194134d086dca4eaca99ee5742d6eadb69
Summary: Support symlinks under `node_modules` for all local-cli commands. PR facebook#9009 only adds symlink support to the packager. But other cli commands like `react-native bundle` creates its own instance of packager that doesn't have symlinks as part of its project roots, which results in the bundler breaking since it cannot find modules that you have symlinked. This change ensures all `local-cli` commands add symlinks to its project roots. Test plan (required) 1. Create a symlink in node_modules (for instance use npm/yarn link) 2. Run `react-native bundle`. Closes facebook#11810 Differential Revision: D4487741 fbshipit-source-id: 87fe44194134d086dca4eaca99ee5742d6eadb69
Summary: Support symlinks under `node_modules` for all local-cli commands. PR facebook#9009 only adds symlink support to the packager. But other cli commands like `react-native bundle` creates its own instance of packager that doesn't have symlinks as part of its project roots, which results in the bundler breaking since it cannot find modules that you have symlinked. This change ensures all `local-cli` commands add symlinks to its project roots. Test plan (required) 1. Create a symlink in node_modules (for instance use npm/yarn link) 2. Run `react-native bundle`. Closes facebook#11810 Differential Revision: D4487741 fbshipit-source-id: 87fe44194134d086dca4eaca99ee5742d6eadb69
Summary: Support symlinks under `node_modules` for all local-cli commands. PR facebook#9009 only adds symlink support to the packager. But other cli commands like `react-native bundle` creates its own instance of packager that doesn't have symlinks as part of its project roots, which results in the bundler breaking since it cannot find modules that you have symlinked. This change ensures all `local-cli` commands add symlinks to its project roots. Test plan (required) 1. Create a symlink in node_modules (for instance use npm/yarn link) 2. Run `react-native bundle`. Closes facebook#11810 Differential Revision: D4487741 fbshipit-source-id: 87fe44194134d086dca4eaca99ee5742d6eadb69
Summary: Support symlinks under `node_modules` for all local-cli commands. PR facebook#9009 only adds symlink support to the packager. But other cli commands like `react-native bundle` creates its own instance of packager that doesn't have symlinks as part of its project roots, which results in the bundler breaking since it cannot find modules that you have symlinked. This change ensures all `local-cli` commands add symlinks to its project roots. Test plan (required) 1. Create a symlink in node_modules (for instance use npm/yarn link) 2. Run `react-native bundle`. Closes facebook#11810 Differential Revision: D4487741 fbshipit-source-id: 87fe44194134d086dca4eaca99ee5742d6eadb69
Summary: Support symlinks under `node_modules` for all local-cli commands. PR facebook#9009 only adds symlink support to the packager. But other cli commands like `react-native bundle` creates its own instance of packager that doesn't have symlinks as part of its project roots, which results in the bundler breaking since it cannot find modules that you have symlinked. This change ensures all `local-cli` commands add symlinks to its project roots. Test plan (required) 1. Create a symlink in node_modules (for instance use npm/yarn link) 2. Run `react-native bundle`. Closes facebook#11810 Differential Revision: D4487741 fbshipit-source-id: 87fe44194134d086dca4eaca99ee5742d6eadb69
Summary: Support symlinks under `node_modules` for all local-cli commands. PR facebook#9009 only adds symlink support to the packager. But other cli commands like `react-native bundle` creates its own instance of packager that doesn't have symlinks as part of its project roots, which results in the bundler breaking since it cannot find modules that you have symlinked. This change ensures all `local-cli` commands add symlinks to its project roots. Test plan (required) 1. Create a symlink in node_modules (for instance use npm/yarn link) 2. Run `react-native bundle`. Closes facebook#11810 Differential Revision: D4487741 fbshipit-source-id: 87fe44194134d086dca4eaca99ee5742d6eadb69
Summary: Support symlinks under `node_modules` for all local-cli commands. PR facebook#9009 only adds symlink support to the packager. But other cli commands like `react-native bundle` creates its own instance of packager that doesn't have symlinks as part of its project roots, which results in the bundler breaking since it cannot find modules that you have symlinked. This change ensures all `local-cli` commands add symlinks to its project roots. Test plan (required) 1. Create a symlink in node_modules (for instance use npm/yarn link) 2. Run `react-native bundle`. Closes facebook#11810 Differential Revision: D4487741 fbshipit-source-id: 87fe44194134d086dca4eaca99ee5742d6eadb69
Summary: Support symlinks under `node_modules` for all local-cli commands. PR facebook#9009 only adds symlink support to the packager. But other cli commands like `react-native bundle` creates its own instance of packager that doesn't have symlinks as part of its project roots, which results in the bundler breaking since it cannot find modules that you have symlinked. This change ensures all `local-cli` commands add symlinks to its project roots. Test plan (required) 1. Create a symlink in node_modules (for instance use npm/yarn link) 2. Run `react-native bundle`. Closes facebook#11810 Differential Revision: D4487741 fbshipit-source-id: 87fe44194134d086dca4eaca99ee5742d6eadb69
Summary: Support symlinks under `node_modules` for all local-cli commands. PR facebook#9009 only adds symlink support to the packager. But other cli commands like `react-native bundle` creates its own instance of packager that doesn't have symlinks as part of its project roots, which results in the bundler breaking since it cannot find modules that you have symlinked. This change ensures all `local-cli` commands add symlinks to its project roots. Test plan (required) 1. Create a symlink in node_modules (for instance use npm/yarn link) 2. Run `react-native bundle`. Closes facebook#11810 Differential Revision: D4487741 fbshipit-source-id: 87fe44194134d086dca4eaca99ee5742d6eadb69
Summary: Support symlinks under `node_modules` for all local-cli commands. PR facebook#9009 only adds symlink support to the packager. But other cli commands like `react-native bundle` creates its own instance of packager that doesn't have symlinks as part of its project roots, which results in the bundler breaking since it cannot find modules that you have symlinked. This change ensures all `local-cli` commands add symlinks to its project roots. Test plan (required) 1. Create a symlink in node_modules (for instance use npm/yarn link) 2. Run `react-native bundle`. Closes facebook#11810 Differential Revision: D4487741 fbshipit-source-id: 87fe44194134d086dca4eaca99ee5742d6eadb69
Summary: I saw we have quite a few user requests for symlink support... **Test plan (required)** 1. Create a symlink in `node_modules` (for instance use `npm link`) 2. Run `npm start` 3. Profit! **Code formatting** Look around. Match the style of the rest of the codebase. See also the simple [style guide](https://github.com/facebook/react-native/blob/master/CONTRIBUTING.md#style-guide). For more info, see the ["Pull Requests" section of our "Contributing" guidelines](https://github.com/facebook/react-native/blob/master/CONTRIBUTING.md#pull-requests). Closes facebook/react-native#9009 Differential Revision: D3648828 Pulled By: matryoshcow fbshipit-source-id: 99cf313bfa70324ca904fa6919ef112180974e9e
Summary: In response to [this comment](facebook/react-native#9009 (comment)). I could be wrong here, but I think Watchman can't handle symlinks, so we need to make sure symlinks-to-symlinks are handled up front. Closes facebook/react-native#9792 Differential Revision: D3858349 Pulled By: bestander fbshipit-source-id: f3a34dae90ed9a7004a03158288db5e1932bfc69
Summary: Support symlinks under `node_modules` for all local-cli commands. PR facebook/react-native#9009 only adds symlink support to the packager. But other cli commands like `react-native bundle` creates its own instance of packager that doesn't have symlinks as part of its project roots, which results in the bundler breaking since it cannot find modules that you have symlinked. This change ensures all `local-cli` commands add symlinks to its project roots. Test plan (required) 1. Create a symlink in node_modules (for instance use npm/yarn link) 2. Run `react-native bundle`. Closes facebook/react-native#11810 Differential Revision: D4487741 fbshipit-source-id: 87fe44194134d086dca4eaca99ee5742d6eadb69
I saw we have quite a few user requests for symlink support...
Test plan (required)
node_modules
(for instance usenpm link
)npm start
Code formatting
Look around. Match the style of the rest of the codebase. See also the simple style guide.
For more info, see the "Pull Requests" section of our "Contributing" guidelines.