The workspaces field is an array containing the paths to each workspace. They will never try to support the high-level feature that Lerna offers, but by implementing the core logic of the resolution and linking steps inside Yarn itself we hope to enable new usages and improve performance. Yarn’s workspaces are the low-level primitives that tools like Lerna can (and do!) use. node_modules/pkg-a -> /workspace-a and you will be able to import code from /workspace-a with const pkgA = require("pkg-a") (or maybe import pkgA from "pkg-a" ). This means that if the /workspace-a/package.json name field was "pkg-a", the alias will be the following: You also need to know that the /workspace-a/package.json#name field is used and not the folder name. That’s the trick that allows you to require the package as if it was a normal one! Please note the fact that /workspace-a is aliased as /node_modules/workspace-a via a symlink. It won’t be there unless some other package use it as a dependency.Īnd that’s it! Requiring workspace-a from a file located in workspace-b will now use the exact code currently located inside your project rather than what is published on npm, and the cross-env package has been correctly deduped and put at the root of your project to be used by both workspace-a and workspace-b. Note: don’t look for /node_modules/workspace-b. node_modules/workspace-a -> /workspace-a
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |