Package Exports
- yalc
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (yalc) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Yalc
Better workflow than npm | yarn link for package authors.
Why
When developing and authoring multiple packages (private or public) you often find yourself in a need of using the latest/WIP versions in other projects that you are working on in your local environment without publishing those packages to remote registry. Npm/yarn adress this issue with standard symlinked packages aproach (npm/yarn link). Though this may work in many cases, it often brings nasty constrains and problems with dependencies resolution, symlinks interoperability between file systems, ect.
What
Yalcacts as very simple local repository for your localy developed packages that you want to share across your local environment.- When you you do
yalc publishin the package directory it grabs only files that should be published to NPM and puts them to special global store (located for example in~/.yalc). - When you do
yalc add my-packagein yourprojectit pulls package content to.yalcin current folder and injectsfile:dependency inpackage.json. Alternatively you may useyalc link my-pakagewhich will create symlink to package content innode_modulesand will not touchpackage.json(likenpm/yarn linkdoes). Yalccreates specialyalc.lockfile in your project (nearyarn.lockandpackage.json) that be used to ensure consistentcy while performingyalc'sroutines.Yalccan be used with projects whereyarnornpmpackage managers are used for managingpackage.jsondependencies.
Install
npm i yalc -gWork in progress. It is a pre-release.
Usage
Publish
Run
yalc publishin your dependency packagemy-package.It will copy all the files that should be published in remote NPM registry, but will not include standard non-code files like
README,LICENCEetc.It will run
preyalcorprepublishscripts before, andpostyalcorpostpublishafter. Use--forceto publish without running scripts.NB! Windows users should ensure
LFnew line symbol is used in published sources, it may be needed for package to work correctly (for example it is must forbinscripts).Yalcwon't convert line endings for you (becausenpmandyarnwon't too).While copying package content
yalccalculates hash signature of all files and by default adds this signature to package manifestversion. You can disable this by using--no-sigoption.
Add
- Run
yalc add my-packagein your dependant project, it will copy current version frome store to your project's.yalcfolder and injectfile:.yalc/my-packagedependency in package.json. - You may add particular versoin
yalc add my-package@version, this version will be fixed inyalc.lockfile and while updates it will not update to newly published versions.
Link
- Alternatively to
addyou may uselinkoperation which should work for you the same way asnpm/yarn linkdoes, the only difference is that source for symllink will be not the global link directory but local.yalcfolder of your project. - After
yalccopies package content to.yalcfolder it will create symlink:project/.yalc/my-package ==> project/node_modules/my-package. It will not touchpackage.jsonin this case.
Update
- Run
yalc update my-packageto update the latest version from store. - Run
yalc updateto update all the packages found inyalc.lock.
Remove
- Run
yalc remove my-package, it will remove package info frompackage.jsonandyalc.lock - Run
yalc remove --allto remove all packages from project.
NB! Currenlty yalc copies (or links) added/updated package content to node_modules folder, but it doesn't execute yarn/npm install/update comands after this, so have dependencies updated have to do it manually.
Advanced usage
Pushing updates automaticaly to all installations
- When do
yalc add/link/update, project's locations where packages added are tracked and saved, thusyalctries to know where each package from store is being used in your local environment. yalc publish --pushwill publish package to store and propagate all changes to existingyalc'spackage installations (will actually doupdateoperation on the location).yalc push- is a use shortcut command for push operation (which will likely become your primarily used command for publication):- it supports
--knitoption forceoptions istrueby default, so it won't runpre/postscripts (may change this with--no-forceflag).
- it supports
Try to use knitting (really experimental)
You want try to
--knitoption. Instead of just copying files from original package location to store it will create symlinks for each individual file in the package.Thus changes to the files will "be propagated" immidiately to all locations as you make updates to linked files.
It is still symlinks. Modules will be resolving their dependencies relative to their original location. Until you use available workarounds for loaders/resolvers.
Excluded folders from publications like
node_modulesstay isolated to the area of use.When add new files you still need may need to push updated version to
yalcstore (to create symlinks to new files).
Keep it out of git
- If you are using
yalc'edmodules temporary while development, first add.yalcandyalc.lockto.gitignore. - Use
yalc link, that won't touchpackages.json - If you use
yalc addit will changepackage.json, and adsfile:dependencies, if you may want to useyalc checkin the precommit hook which will check package.json foryalc'eddependencies and exits with error, if you forgot to remove them.
Keep it in git
- You may want to keep shared
yalc'edstuff within the projects you are working on and treat it as a part of the project's codebase. This may really simplify management and usage of shared work in progress packages within your projects and help to make things consistent. So, then just do it, keep.yalcfolder andyalc.lockin git. - Replace it with published versions from remote repository when ready.
Publish/push sub-projects
- Useful for monorepos (projects with multiple sub-projects/packages):
yalc publish packagewill perform publish operation in nestedpackagefolder of current working dir.
Related links
- yarn probably shouldn't cache packages resolved with a file path
- "yarn knit": a better "yarn link"
- npm-link-shared
- yarn link does not install package dependencies
- [npm] RFC: file: specifier changes
Licence
WTF.