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

[RRFC] improving the workspaces symlinking experience #556

Closed
bnb opened this issue Mar 16, 2022 · 5 comments
Closed

[RRFC] improving the workspaces symlinking experience #556

bnb opened this issue Mar 16, 2022 · 5 comments

Comments

@bnb
Copy link

bnb commented Mar 16, 2022

Motivation ("The Why")

Personally as I began working with workspaces, one of the most confusing concepts was how to actually access one module from another. I've also heard this from other folks - extremely skilled engineers - I've talked to who were trying to pick up workspaces, prior to me using them. Upon reaching out to folks that I think most others wouldn't have available to them, I was able to understand that the modules were symlinked from node_modules. Great!

The one pain point with that is that it's not entirely obvious what the "correct" way to do this is. Sometimes it works magically, but other times it doesn't. This seems to be because this symlinking feature is hidden behind npm install, either at the root or in the new workspace you want to add (npm install -w myspace).

I'd like to request that this be improved in some way. Here are the ways I've thought of:

  • triggering symlinking more often: when i npm i -w lol, symlink lol. I assume this has to do with Arborist, so I'm not sure what the simplest way to do this is but ideally taking whatever path has the least perf impact would be ideal.
  • manually triggering symlinking: I can think of cases where a manual trigger outside of npm install might be useful (people who want to manually do everything, external tooling that does it but not the linking). npm ws link or something like that.

Example

How

Current Behaviour

npm init -w myspace
npm install # it's unexpected that I have to do this!

Desired Behaviour

npm i -w myspace # automatically links on init!
npm ws link # links all workspaces!
npm ws link myspace # just links myspace!

References

  • n/a
@ljharb
Copy link
Contributor

ljharb commented Mar 16, 2022

"linking myspace" is a very old-fashioned phrase

I think npm ws link [foo] makes a ton of sense.

@ruyadorno
Copy link
Contributor

@bnb did you mean npm init -w myspace instead of npm i -w myspace in the current/desired examples?

@bnb
Copy link
Author

bnb commented Mar 16, 2022

@bnb did you mean npm init -w myspace instead of npm i -w myspace in the current/desired examples?

yes fixed :)

@ruyadorno
Copy link
Contributor

@bnb I'm also finding a very similar issue in npm version -w myspace <version> in which users expect the references to that workspace to be updated across dependents.

I believe that there's a very good DX argument here to start running reify at the end of these commands that (when run in the context of workspaces) will cause differences in the installed tree.

ruyadorno added a commit to ruyadorno/cli that referenced this issue Mar 17, 2022
Adds a minimalistic reify step that updates the installed tree after a
version change within one of the configured workspaces when using any
of the workspaces config options.

It's also possible to use the `--save` config option in order to
auto update semver ranges of dependencies declarations accross dependent
`package.json` files.

Fixes: npm#3403
Relates to: npm/rfcs#556
Relates to: npm#3757
Relates to: npm#4193
ruyadorno added a commit to ruyadorno/cli that referenced this issue Mar 17, 2022
Adds a minimalistic reify step that updates the installed tree after a
version change within one of the configured workspaces when using any
of the workspaces config options.

It's also possible to use the `--save` config option in order to
auto update semver ranges of dependencies declarations accross dependent
`package.json` files.

Fixes: npm#3403
Relates to: npm/rfcs#556
Relates to: npm#3757
Relates to: npm#4193
ruyadorno added a commit to ruyadorno/cli that referenced this issue Mar 21, 2022
Adds a minimalistic reify step that updates the installed tree after a
version change within one of the configured workspaces when using any
of the workspaces config options.

It's also possible to use the `--save` config option in order to
auto update semver ranges of dependencies declarations accross dependent
`package.json` files.

Fixes: npm#3403
Relates to: npm/rfcs#556
Relates to: npm#3757
Relates to: npm#4193
fritzy pushed a commit to npm/cli that referenced this issue Mar 24, 2022
Adds a minimalistic reify step that updates the installed tree after a
version change within one of the configured workspaces when using any
of the workspaces config options.

It's also possible to use the `--save` config option in order to
auto update semver ranges of dependencies declarations accross dependent
`package.json` files.

Fixes: #3403
Relates to: npm/rfcs#556
Relates to: #3757
Relates to: #4193
@darcyclarke darcyclarke added the Agenda will be discussed at the Open RFC call label Mar 31, 2022
@darcyclarke darcyclarke removed the Agenda will be discussed at the Open RFC call label Apr 6, 2022
@bnb
Copy link
Author

bnb commented Apr 18, 2022

going to close this since it's been implemented :)

@bnb bnb closed this as completed Apr 18, 2022
ruyadorno added a commit to ruyadorno/cli that referenced this issue May 12, 2022
Adds a minimalistic reify step that updates the installed tree after
initializing a new workspace.

Moved the shared update logic from `lib/commands/version.js` to a
`lib/workspaces/update-workspaces.js` module that is reused between
both `npm version` and `npm init`.

Relates to: npm/rfcs#556
Relates to: npm#4588
ruyadorno added a commit to ruyadorno/cli that referenced this issue May 12, 2022
Adds a minimalistic reify step that updates the installed tree after
initializing a new workspace.

Moved the shared update logic from `lib/commands/version.js` to a
`lib/workspaces/update-workspaces.js` module that is reused between
both `npm version` and `npm init`.

Relates to: npm/rfcs#556
Relates to: npm#4588
ruyadorno added a commit to ruyadorno/cli that referenced this issue May 19, 2022
Adds a minimalistic reify step that updates the installed tree after
initializing a new workspace.

Moved the shared update logic from `lib/commands/version.js` to a
`lib/workspaces/update-workspaces.js` module that is reused between
both `npm version` and `npm init`.

Relates to: npm/rfcs#556
Relates to: npm#4588
ruyadorno added a commit to npm/cli that referenced this issue Jun 1, 2022
Adds a minimalistic reify step that updates the installed tree after
initializing a new workspace.

Moved the shared update logic from `lib/commands/version.js` to a
`lib/workspaces/update-workspaces.js` module that is reused between
both `npm version` and `npm init`.

Relates to: npm/rfcs#556
Relates to: #4588
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants