Hi there everyone. I’m working on publishing a se...
# typescript
a
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
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
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
No, I don't know what either of those are. I've never needed anything more than npm or yarn.
d
A few weeks late on this, but we use tsup in our monorepo without any issues for libraries (and esbuild for our lambdas)