I use Pulumi in a Yarn 3 monorepo. Pulumi doesn't ...
# typescript
c
I use Pulumi in a Yarn 3 monorepo. Pulumi doesn't like yarn's package hoisting, so I need to add this to the pulumi program's package.json:
Copy code
"installConfig": {"hoistingLimits": "workspace"}
Not super happy with it as we have dozen of other packages in the monorepo and disabling hoisting make us pay some penalty (mostly longer CI builds and bigger FS usage for node_modules). Yarn 3 has a new feature that replaces node_modules directories completely: https://yarnpkg.com/features/pnp It's amazingly fast! We do not even need to run "yarn install" anymore (cf https://yarnpkg.com/features/zero-installs) To use it, I need to do this before running the Pulumi program:
Copy code
require('./.pnp.cjs').setup();
However, I cannot find a way to do this in a TypeScript program. Guess I should configure TS to allow importing .cjs files and import it using an import statement in the TS file? What about native support for Yarn's PnP in Pulumi? Would you accept such a PR? If so, is this the right place: https://github.com/pulumi/pulumi/blob/master/sdk/nodejs/cmd/run/run.ts#L247 ?
l
@clever-painter-96148 good luck. I tried it once, but failed. The assumption that there is a
node_modules
folder is deep in the implementation of Pulumi core. https://github.com/pulumi/pulumi/pull/4349
c
Oh, you did seriously try it! I'd be happy finding a way for the pulumi program to be able to find the @pulumi/* packages (i am already refactoring inlined lambdas as separate packages).
finding the Pulumi plugins is iterating over the 
node_modules
 folder in Go code to find the plugin binaries.
This is definitely blocking :(
The docs says pulumi can be installed with yarn. This leads people to believe that it works with yarn. And people usually switch from npm to yarn to benefit from hoisting. But as soon as they try to hoist packages (or PnP), it doesn't work. Pulumi only works with the node-modules linker and when disabling hoisting (for the whole monorepo or at least for the package that contains the pulumi program). I'd be happy to provide a PR to help others, but I am not sure when this belongs.
p
we use yarn 3 as well, but use the node_modules fallback option over pnp. That works, never gotten pnp to work