Anyone have a good reference repository for a mult...
# typescript
Anyone have a good reference repository for a multi-package repo where a package is one or more components and other utility code? I started a repo structured as so: packages/ • foo/ examples/ • foo/ Using npm workspaces
["packages/*", "examples/*"]
. The idea was I could develop my packages by referring to them in the examples/. I have it somewhat working, the main issue is I need to rebuild the packages after every change. Seems like there should be a way around this. I used pulumi-ts about 5 years ago and if I remember correctly I used
yarn link
but there must be a better more modern approach now.
Yarn workspaces handle this fine. Yarn classic and Yarn 2+ both work. You can't use PnP, but putting
nodeLinker: node-modules
in your .yarnrc.yml solves that.
You don't need to use
yarn link
. The hoisted node_modules is used for everything. If you run into problems with hoisting (e.g. you're building AWS lambdas or other "nested" code that runs in a different runtime), you can turn off hoisting and add an explicit dependency to the other workspaces using this package.json notation:
Copy code
"@otherWorspacePackageName": "workspace:^",
Happy to help with any questions on this (I've just been through it again over the last few days, converting a large old project to use it). It doesn't look like our time zones overlap too much though, so the cycle time might be very high 😞
Awesome thanks I'll try this out after work. You say you've just been through this over the last few days, would that project code happen to be public on the internet somewhere?
No, sorry. But there is really only the one thing needed for Pulumi in a Yarn project: the nodeLinker line in your yarnrc.yml. Everything else is straight from the Yarn docs.
I finally had a chance to try this out and was not successful. I have a packages/fabric with a project component and an examples/project which uses it and running
pulumi preview
results in typescript not finding packages/fabric. I'm not sure if it's a yarn issue or typescript.
nm, I seem to have gotten it to work.