workers-sdk icon indicating copy to clipboard operation
workers-sdk copied to clipboard

Support PNPM?

Open michaelmerrill opened this issue 3 years ago • 3 comments
trafficstars

Any chance wrangler2 can support PNPM? It's much faster and has better support for workspaces which pairs nicely with workers using a micro-service approach. Currently, npx wrangler@beta init fails as it defaults to npm.

michaelmerrill avatar Apr 10 '22 02:04 michaelmerrill

Yeah, I think we can/should do this. Our yarn integration could also use some work. Thanks for filing this, it had slipped my mind!

threepointone avatar Apr 10 '22 11:04 threepointone

I'm interested in working on this. Is this file the only one that needs updating?

One approach could be updating this file to support hasPnpmLock, but I don't think this logic currently supports monorepos as the lock file will often be in a parent directory.

Another approach could be to allow passing in the package manager as a flag and setting npm as the default using yargs. This file could be simplified to do a check to see if the system supports('<package_manager>') and a conditional to use the right package manager object (eg. YarnPackageManager, PnpmPackageManager).

What do you think @threepointone ?

michaelmerrill avatar Apr 13 '22 14:04 michaelmerrill

There's some nuance here we might want to revisit. For example, if you use pnpm dlx wrangler init <name> we want to make sure it sets up a pnpm project. (This is separate from looking for the lockfile, which won't exist when the above command is called.). yarn doesn't have a direct executor like npx and pnpm dlx, so maybe that's ok.

I don't think we should add any new flags, we should be able to detect what's executing the command and take a call from there.

threepointone avatar Apr 13 '22 16:04 threepointone

Closing this as completed due to #1427, which closed #1202

caass avatar Oct 11 '22 13:10 caass