Skip to content
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

Proposal: use symlink to whole node_modules folder in workspaces #5332

Open
alexeyraspopov opened this issue Feb 7, 2018 · 3 comments
Open
Assignees
Labels

Comments

@alexeyraspopov
Copy link

Do you want to request a feature or report a bug?

Improvement for existing feature

What is the current behavior?

When using workspaces, all node modules are located in a single node_modules folder in the root of a project. Nested packages are able to reference to installed dependencies due to the way how Node.js resolves imports, basically looking at parent folders for node_modules. When a nested package (workspace) depends on a tool with CLI, Yarn creates symlinks to .bin folder files from the root modules folder.

What is the expected behavior?

Several tools (i.e. facebook/create-react-app#3031, facebook/flow#5107) need additional work to be done to support workspaces which breaks user experience when they trying to adopt workspaces in their projects. I can imagine even more tools have possible issues with workspaces, either not discovered or not reported yet.

Current proposal is to make symlink to whole node_modules folder in workspaces, instead of just symlinking CLIs. In this way, zero tools would need to make additional changes only in favor of supporting workspaces. It immediately allows the use of Flow and CRA (current versions) with workspaces.

Please mention your node.js, yarn and operating system version.

I use Yarn 1.3.2 with Node.js 8.9 on macOS 10.12.

@ghost ghost assigned rally25rs Feb 7, 2018
@ghost ghost added the triaged label Feb 7, 2018
@madhusudhand
Copy link

madhusudhand commented Feb 19, 2018

I am facing the following issue. I guess its related.

Lets say I have my directory structure as follows

- project
   - lib (a common library package)
       - package.json
   - workspace-1
       - package.json (has workspace dependency: "lib": "./lib")

With Yarn install its doing two things.

  1. Creates symlinks in node_modules under main project directory. [ EXPECTED ]
  2. Copies lib directory inside workspace-1/node_modules (not symlink) [ NOT EXPECTED ]

And so any change I do in lib isn't reflected in workspace-1.
I have to delete the workspace level packages for it to work as expected.

Expectation:
I guess it isn't required to place the workspace dependencies under sub directory node_modules.
Even if it is the case for some reason they should be symlinked.

@artaommahe
Copy link

@madhusudhand #5379 (comment)

@connectdotz
Copy link
Contributor

yarn 1.5.1 just released the new feature nohoist, which should be able to make react and react-native experience much simpler. Feel free to give it a try. examples available here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants