https://pulumi.com logo
#typescript
Title
# typescript
b

billowy-laptop-45963

12/14/2023, 1:07 PM
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.
l

little-cartoon-10569

12/14/2023, 6:43 PM
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 😞
b

billowy-laptop-45963

12/14/2023, 8:09 PM
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?
l

little-cartoon-10569

12/14/2023, 8:13 PM
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.
b

billowy-laptop-45963

12/17/2023, 3:31 AM
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.
3 Views