1.1.0 • Published 10 months ago

link-workspaces v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

link-workspaces

Yarn does not respect publishConfig.directory when linking packages in a mono repo. Meaning, when one of your packages isn't being published from the package root - but for example from inside ./dist - your dev environment will not be able to find the package.

This package deals with that limitation by fixing the links during post install.

See relevant issue: yarn#7644. This package should be deprecated once that issue is resolved.

Install

yarn add -D -W link-workspaces

Usage

Add link-workspaces to your postinstall:

{
	"scripts": {
		"postinstall": "link-workspaces"
	}
}

Now run yarn install or yarn postinstall and you should be good to go.

Options

--silent

link-workspaces will print information about created links to stdout. You can silence this by passing the --silent or -s flag.

{
	"scripts": {
		"postinstall": "link-workspaces --silent"
	}
}

--no-source

By default, when the publishConfig.directory is defined, we create a link to the folder mentioned in your source field. If no source field exists, we use the publishConfig.directory. This makes it so that your development environment works with source fields, rather than with dist files.

Provide the --no-source flag to opt out of this behavior.

{
  "scripts": {
    "postinstall": "link-workspaces --no-source"
  }
}

Credits

I've used the following packages/files as inspiration when creating link-workspaces. You might see similarities in the code if you were to compare the files. All source code used and linked below is licensed under the MIT license.

Much kudos to the authors of the original source: