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

"yarn knit" -- a command to test libraries while working on them #41

Merged
merged 1 commit into from
Jan 18, 2017

Conversation

ide
Copy link
Contributor

@ide ide commented Jan 13, 2017

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.)

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.
Copy link

@timdorr timdorr Jan 13, 2017

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.

Copy link
Contributor Author

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:

  1. Add a second yarn.local.lock file that is .gitignored and contains knitted dependencies and is overlaid on top of yarn.lock.
  2. Commit knitted tarballs to Git. Yarn already supports offline installations.
  3. Ignore it

@joshduck
Copy link

joshduck commented Jan 14, 2017

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.

@ide
Copy link
Contributor Author

ide commented Jan 15, 2017

@joshduck Node has a flag called --preserve-symlinks which turns off link resolution. And the React packager and Webpack could consider a different resolution policy.

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.

@bestander
Copy link
Member

Sounds like a good idea

@bestander bestander self-assigned this Jan 17, 2017
@bestander
Copy link
Member

bestander commented Jan 18, 2017

Considering that it is a brand new API, we might want to get feedback after we have the first implementation.
Any idea how we can implement it behind a flag maybe for a couple of releases?

@ide
Copy link
Contributor Author

ide commented Jan 18, 2017

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.

@bestander bestander merged commit 54963d4 into yarnpkg:master Jan 18, 2017
@bestander
Copy link
Member

Agree, great idea!

@louisgv
Copy link

louisgv commented Feb 12, 2017

Is this out yet?

@KyleAMathews
Copy link

I'd love to start developing Gatsby with this. It'd lower complexity getting started a lot with contributing to our Lerna monorepo setup.

@kristojorg
Copy link

Agreed, would love to see this happen

@bestander
Copy link
Member

I would hold on implementing knit as described here, I think Yarn workspaces could cover all the usecases described here.

@bestander
Copy link
Member

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.

@sejoker
Copy link

sejoker commented May 21, 2017

After reading both RFCs on yarn knit and workspaces linking I tend to think they have different purpose and don't substitute one another. yarn knit is yarn link on steroids with a focus on the development experience. Workspaces on the other hand focus on the API while working in monorepo. I don't see how Workspaces address the main features of yarn knit:

All in all, I find current RFC a good addition on top of yarn link even with rolled out Workspaces feature.

@saulshanabrook
Copy link

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.

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

Successfully merging this pull request may close these issues.

9 participants