![]() I've noted meta-updater for later research, I think it's exactly what I'll be looking for to help script away the downsides I ended up on in attempt 3. Note: to get a 'bottoms up' view of why a given package is included in the tree at all, use npm explain. My only concern is the runtime though and in that context I'm hitting the strict-failure, and when I can't clearly read why from the documentation I start dreaming about a world without Typescript □. Description This command will print to stdout all the versions of packages that are installed, as well as their dependencies when -all is specified, in a tree structure. I see all your packages make use of "outDir" and "rootDir" and I think those settings only get used when running tsc -b or equivalent to build to source, which I assume you run before publishing the packages. Am I the only person who was expecting projects to be truly separate? Very interesting to browse the pnpm monorepo, I'm left wondering if pnpm decided on using project references knowing things like "strict" doesn't work across projects, or if it was a case of "good enough" and you don't actually hit that problem…□Īt this point I'm more confused about how Typescript intends their References feature should be used than when I began these articles, I'm not at all sure how tsconfig options get merged, if they do at all. tsconfig.json with the following content.That looks good Zoltan, thanks for the links! This also creates the single node_modules directory needed in the entire monorepo. Add core dependenciesĪ great place to add core dependencies is here. Its possible to directly add/remove/update dependencies of your workspaces using the workspace config. ⚠️Make sure the section “workspaces” is present, npm is dependent on this. package.json with the following content: -fix" ![]() This demo project will be named “SuzieQ”. This guide refers both to remote packages (located on the internet and probably developed by someone else than you) and local packages. It's a side note, but “packages” as used for a developer usually refers to packages downloaded from the internet by npm or yarn. and the tools of course, npm and tsc □ Package? Local packages? I recommend to set up a in the root of the monorepo, and reference that. Each local package has its own configuration, such as package.json, tsconfig.json and src-folder and other (but no node_modules). It copies the files from the monorepo package instead of linking, and it installs its dependencies as well. One folder per local package, located in the packages folder. In addition to running an install with -workspacesfalse, adding the -install-links option to the npm install command causes the packages to be installed correctly. ![]() The monorepo itself (the root folder with it's configuration files, like package.json, node_modules, tsconfig.json and other) Not covered by this guide: Building production builds - this guide is focused on the developer experience :) TL DR - Demo repo? We have a workspace with a root package and sub-packages A and B. from can reference local packages without errors. Running tsc in the monorepo root transpiles all packages in order. There will be just one node_modules folder (in the root of the monorepo).Įach piece (read: local package) of the product will have its own folder with its own package.json, tsconfig.json but use the monorepo's node_modules. LinkedIn logo for sharing a link Twitter logo for sharing a link Reddit logo for sharing a linkĭid you ever want to create one project, but with local packages? To be able to import local packages from other local packages? And the best part, to have a single node modules directory? To have a _single tsc to rebuild changed packages (but keep the others as-is)? And as a nice bonus, decrease both transpile and the time to start the program? The solution is to use a monorepo! This guide shows the step by step to manully setup a monorepo with NPM + TypeScript.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |