![]() ![]() If you have 200 projects in your workspace, you will see 200 lines specifying projects' roots. The add-nx-to-monorepo script generates the following per project:Įnter fullscreen mode Exit fullscreen mode Misconception: Nx is configuration over conventionĪs you saw in the video, the amount of the generated configuration is small. Many larger organizations using Nx publish a subset of their libraries to their registry. It has 2 applications and a few dozen libraries. Misconception: Nx is for apps, Lerna is for libs.Īlthough it's true to say that the Nx core doesn't care whether you publish your packages or not, there are Nx plugins (e.g., that help you bundle and package your modules.įor instance, the Nx repo itself is built with Nx. It's simply something that Nx can enable you to do at scale. But it's important to stress that this isn't required by Nx. What often happens though is when folks adopt Nx, they have better affordances for implementing a single-version policy (why this is a good idea is beyond the scope of this post, but you can read more about why Google does here). If you want to use Lerna to dedup node_modules in your Nx workspace, you can do it. Nx doesn't care whether your repo has multiple node_modules folders or not, and whether you choose to dedup them or not. Nx isn't a package manager (it's not a JS-only tool), so deduping node_modules isn't in that list. Automatic upgrade to latest versions of all frameworks and toolsĪs you can see, there is basically no overlap.Consistent dev experience for any framework.High-quality editor plugins & GitHub apps.Distributed task execution & computation caching.I can run one command to publish packages to NPM. If I want to test all the projects, I can use a single command to do it. If I use the same version of say Next.js in all the projects, the package is installed once. Lerna, Yarn workspaces, pnpm workspaces offer the following affordances for developing multiple projects in the same repo: Misconception: You have to choose between Nx and Lerna. Basically, any time I say "Lerna" you can substitute it for Yarn or PNPM. Although the video uses Lerna, everything said applies to Yarn or PNPM. The video walks you through the steps of adding Nx to a Lerna repo and showing many affordances Nx offers. So when anyone installs this published library package, it will be broken because it imports modules from packages (dependencies) not listed in library/package.json.ĭo I really need to write a custom publishing shell script that merges the root package.json's dependencies into library/package.In this video I'll compare monorepo tools such as Lerna/Yarn workspaces/PNPM workspaces with Nx. The problem is that yarn doesn't merge-in the dependencies from the monorepo's root package.json, and the published package's package.json only contains library local dependencies, from library/package.json. What I expect to happen is that the published package will work exactly the same way it works for my monorepo local apps. So what I want to do, is to cd library and yarn publish. app2/package.json (contains app local dependencies, and depends on library).app1/package.json (contains app local dependencies, and depends on library).library/package.json (contains library specific dependencies).library/ (this is the one I want to publish, for consumption outside of this monorepo, the published package.json should contain the root dependencies as well as library local).single version of React to be used by all workspaces) package.json (contains shared dependencies, eg.I'm trying to publish one (yarn) workspace from a monorepo to npm repository, and include root project's dependencies in the published package. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |