-
Notifications
You must be signed in to change notification settings - Fork 147
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
"yarn knit" -- a command to test libraries while working on them #41
Conversation
This is a proposal for a new command that is like `yarn link`/`npm link` and addresses several of the problems with `link`. (This is an edited version of yarnpkg/yarn#1213, written as an RFC as requested.)
|
||
# Drawbacks | ||
|
||
One issue with this proposal is that it's not clear what to put in the lockfile after running `yarn link dep` since we don't have an npm URL for the dep yet -- it hasn't been published to npm. |
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.
What if yarn knit
assigned a nonce version string and also spit out something like To install in a local app, run: yarn knit dep@asdf1234
? That could be referenced in the lockfile with a resolved
of knit://dep@asdf1234
.
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 think that could work though one issue is that other team members wouldn't be able to resolve knit://dep@asdf1234
. We could address that in a few ways:
- Add a second yarn.local.lock file that is .gitignored and contains knitted dependencies and is overlaid on top of yarn.lock.
- Commit knitted tarballs to Git. Yarn already supports offline installations.
- Ignore it
Symlinks have issues with peer dependencies. I would love to see that accounted for here. Node resolves the link fully before walking up the path looking for node_modules. So if 'dep' has a peer depenency on React, it will not know that 'react' is actually app/node_modules/react. |
@joshduck Node has a flag called I'm not sure it's possible without symlinks to let people make changes in their library's directory and have the same changes automatically applied to their app's node_modules. There is a program called wml that watches for changes and copies files over but it relies on Watchman and doesn't work in some scenarios where symlinks would. |
Sounds like a good idea |
Considering that it is a brand new API, we might want to get feedback after we have the first implementation. |
We could name the command "knit-EXPERIMENTAL" which has a similar effect as a flag without adding much complexity. As for getting people to test it out, Exponent is already using a copy of Yarn from upstream directly so it's relatively straightforward for us to use an unreleased version of Yarn. |
Agree, great idea! |
Is this out yet? |
I'd love to start developing Gatsby with this. It'd lower complexity getting started a lot with contributing to our Lerna monorepo setup. |
Agreed, would love to see this happen |
I would hold on implementing knit as described here, I think Yarn workspaces could cover all the usecases described here. |
Workspaces should become a good end to end solution for monorepos, in Workspaces phase 3 RFC we discuss linking between modules and it might be good enough to cover use cases raised here. Thanks, @ide, for writing down this RFC, I got some ideas from it. |
After reading both RFCs on All in all, I find current RFC a good addition on top of |
We had to write a custom linking mechanism in JupyterLab because if we used yarn link we ended up with duplicate packages in the webpack build. Basically we have a webpack build in one directory and then want to let users add their own folder (anywhere on the file system) and have that included in the webpack build and updated when the user updates their folder. We can't use workspaces for this since they are required to be subfolders of the root. And we can't use link, because then we end up with dependencies duplicated. |
This is a proposal for a new command that is like
yarn link
/npm link
and addresses several of the problems withlink
.(This is an edited version of yarnpkg/yarn#1213, written as an RFC as requested.)