-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
workspaces: first phase: install node_modules aggregated from all workspaces #3229
Conversation
src/cli/commands/install.js
Outdated
if (root[type] && root[type][key] && root[type][key] !== workspaceJson[type][key]) { | ||
this.reporter.warn( | ||
this.reporter.lang('incompatibleDependenciesInWorkspace', key, workspaceCwd, rootCwd), | ||
); |
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.
Maybe two extra modes could be interesting:
- Merge dependency requirements (so that the range would become
~1.0.0 ~1.0.3
, for example) - When conflict arise, prevent hoisting the conflicting modules (so that they end up being installed into their respective node_modules folders)
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.
When conflict arise, prevent hoisting the conflicting modules (so that they end up being installed into their respective node_modules folders)
Problem being that in such a case, we would have to run yarn install
recursively into the workspace directories
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.
Yeah, we'll do it in a later phase.
…l do a smart resolution/linking
ping @arcanis for tests |
This PR will be merged at the same time with #3365 and then we'll ship the feature to for testing behind the flag. Next step would be package hoisting logic at the workspaces level similar to node_modules hoisting Yarn does. |
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.
Shouldn't this code also check if the cwd is inside a project and, if it is, run the install from the project root instead of the workspace (or at least prevent the install)? Otherwise, if people run yarn install
from one of their workspace, they will create a node_modules that will shortcut the one created in the project root.
throw new MessageError(this.reporter.lang('workspacesRequirePrivateProjects')); | ||
} | ||
for (const workspace of projectManifestJson.workspaces) { | ||
for (const workspaceLoc of await fs.glob(path.join(rootCwd, workspace, filename))) { |
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.
I've added a few utility methods to the Config
class to support workspaces (for example https://github.com/yarnpkg/yarn/pull/3365/files#diff-9d9a6cd82f41984872a66a3ab0d440c4R555), it would make sense to update the code to use them once we've merged this PR, what do you think?
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.
does it support glob?
I think we can discuss that in the following PR
Yeah, it makes sense. |
👍 Good to merge, then? |
Thanks |
Workspaces phase 1: aggregated node_modules according to RFC yarnpkg/rfcs#60.
This change aggregates dependencies from sub projects
For example, if the structure of the source code is following
Top level package.json is like
babel-jest
babel-preset-jest
If workspaces is enabled and yarn install is run at the root level of jest Yarn would install dependencies as if the package.json contained all the dependencies of all the package.json files combined, i.e.
A single yarn.lock will be created at the root level and no node_modules and yarn.lock files will be generated for any of the workspaces.
Note: If there are different versions of the same package between workspaces or a workspace and the root then install will fail with error
Dependency $0 has different versions in $1 and $2
.In a next phase conflicts will be resolved similar to package-hoister that works when node_modules folder is being built.
To set up.
Set project's private filed to true (so that people would not accidentally publish projects with non standard
workspaces
field)Run