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

abundant-fall-26464

09/02/2023, 8:34 AM
Hi there everyone. I’m working on publishing a set of Pulumi component packages to be reused across teams. I have a TS monorepo that has multiple packages for different components (RDS, S3 Buckets, etc). Currently, I’m facing some issues compiling the packages to ESM and consuming them in other Pulumi projects. I see there are a few issues on Github about ESM support with Pulumi still being in the works, or requiring some additional workarounds. Are there any general recommendation for compiling such packages, that are out-of-the-box compatible with default Pulumi typescript projects? Should I only focus on CJS output to cover most scenarios? TIA
l

little-cartoon-10569

09/03/2023, 11:07 PM
So long as you're happy to put this in all your Pulumi.yaml files, you should be ok:
Copy code
runtime:
  name: nodejs
  options:
    nodeargs: "--loader ts-node/esm --no-warnings"
The vanilla TS implementation doesn't use the ESM loader. You need to add this to wire it in.
a

abundant-fall-26464

09/04/2023, 11:35 AM
Ah, got it. I’ll probably stick to CJS builds then. Less configuration for other teams, as they can begin with the normal starter templates. (guess that’s another thing I’d have to look into as well, templates to bake in the ESM loader 😅 ) Thanks for the info! Do you have any recommendations for build tools for this usecase? Like tsup vs. parcel.
l

little-cartoon-10569

09/04/2023, 8:10 PM
No, I don't know what either of those are. I've never needed anything more than npm or yarn.
d

dry-pilot-49577

09/19/2023, 12:37 AM
A few weeks late on this, but we use tsup in our monorepo without any issues for libraries (and esbuild for our lambdas)
2 Views