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

dazzling-sundown-39670

11/28/2023, 2:51 PM
Anyone using pulumi and turborepo? Is it worth the effort? I want to structure my monorepo somehow but I'm not sure what's the best way. I have 2 nodejs apps, I want to share some data between those apps, and everything is deployed with pulumi today
i

incalculable-plastic-17510

11/28/2023, 3:38 PM
I’ve set up our infra in as a package in turbo repo. This means it won’t be built into the apps but also allows it to use turbos features and dependency installation at the root. Unless your apps need have the Pulumi infrastructure as a dependency it was much hassle to set up.
d

dazzling-sundown-39670

11/30/2023, 7:34 AM
Thanks Philip, I understand. Do you recommend porting the rest (my apps, but not pulumi) to turborepo?
g

great-sunset-355

11/30/2023, 10:19 AM
I'd avoid merging pulumi with an application code. There are lots of bugs(read features) in pulumi preventing usage of modern TS/JS features. At best you'll need 2 "mono repos" 1 for pulumi and 1 for apps
that said, unless you plan to building pulumi TS into JS yourself, then you need to add this in
Pulumi.yaml
Copy code
runtime:
  name: nodejs
  options:
     typescript: false
then pulumi will use the
js
version of your code. I am not sure how much fun is it when running locally but I ran into the situation where this solved problems with dependencies while using
pnpm
- because pulumi required several packages hoisted
i

incalculable-plastic-17510

11/30/2023, 3:27 PM
@dazzling-sundown-39670 Jan isn't wrong but I haven't had any issues using Turbo repo. If you only need one set of infra then maybe keeping them separate makes sense (which is what I've done with my orgs common infra) however we have many smaller apps and so it make it easier to put the infra in our turbo repo
packages
. I haven't had issues with TS
d

dazzling-sundown-39670

11/30/2023, 6:22 PM
My pulumi setup is not big, I only have 2 apps and a serverless function deployed. This is my structure now:
Copy code
├── apps
│   ├── cms
│   ├── fn-cron-runner
│   └── nextjs
└── pulumi
Each app + pulumi is just their "own" thing, I don't use workspaces either. Do you think using Turborepo would be beneficial for me at all, other than for sharing code between the apps?
i

incalculable-plastic-17510

11/30/2023, 6:33 PM
If your apps don't need each other as dependencies (or sharing code) then I wouldn't see the need really. The reason we use Trubo is because we have shared types, common functions and integrations between backend and frontend (cms). So Pulumi being part of it wasn't part of that decision. I'd say keep them separate unless you want to utilize packages.
d

dazzling-sundown-39670

11/30/2023, 6:34 PM
Great, thank you very much, then I will wait until I need to have those. Appreciate it
g

great-sunset-355

11/30/2023, 8:58 PM
@incalculable-plastic-17510 this is the first time I was reading about turbo, I am not JS expert but a bit familiar with lerna. Which package manager are you using for your code?
i

incalculable-plastic-17510

11/30/2023, 9:44 PM
So turbo works with
npm
,
yarn
and
pnpm
but I would suggest using pnpm for it. I've had fastest builds and also if pulumi is a package then you can run
pnpm i
in the root and it will manage all dependencies for you. Also allows you to build in your pulumi commands as scripts in the pulumi
package.json
and run them from the root which works really well then with docker compose
2 Views