sst: pnpm not supported
The function getTsBinPathfail if we install packages with pnpm
> matches
[
'/Users/foo/Documents/Code/backend-test/node_modules/.pnpm/typescript@4.4.3/node_modules/typescript/lib/typescript.js',
'/Users/foo/Documents/Code/backend-test/node_modules/.pnpm/typescript@4.4.3/node_modules',
index: 0,
input: '/Users/foo/Documents/Code/backend-test/node_modules/.pnpm/typescript@4.4.3/node_modules/typescript/lib/typescript.js',
groups: undefined
]
> path.join(matches[1], ".bin", "tsc")
'/Users/foo/Documents/Code/backend-test/node_modules/.pnpm/typescript@4.4.3/node_modules/.bin/tsc'
It just miss the typescript folder before .bin/tscbut i think adding it would break installation with other package manager.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 5
- Comments: 18 (8 by maintainers)
pnpm finally supported in v2!
We’ll be releasing a public beta of the new CLI soon. With pnpm support.
Yeah so it’s an AWS CDK issue but we are working on a new CLI that’ll fix this.
I don’t see how can that be a CDK issue where, in fact, I’ve worked on many monorepo projects that use AWS CDK + PNPM just fine, but attempting to configure a brand new basic monorepo with SST + PNPM leads to all sorts of errors like:
On the surface, it looks like SST is just relying too much on node_modules being a “local” folder, rather than being hoisted to the top of the monorepo. Because if we install the dependencies locally, SST magically starts working.
Not trying to point a finger at SST, just want to make sure the issue is addressed at the right place rather than waiting for a magical upstream bugfix to come down from AWS CDK, that will never happen.
EDIT: To better illustrate what I mean.
Leads to synthesis errors.
Whereas:
Works fine.
In a different project that uses AWS CDK as the framework for “Infrastructure as code”, both approaches work fine:
I can prepare a minimally reproducable repo of course, but I think this is enough information as a starting point to further analysis.
I need to do another deep dive into pnpm now that CDK v2 is out, some of what I say below may be outdated.
Next-gen bundlers like yarn2 + pnpm enforce certain constraints that some projects took advantage of. For example, in CDK if they’re including an asset that gets sent up with your cloudformation, they would resolve it using
__dirname. In yarn2 the filesystem for dependencies is “virtual” and you need to be using module resolution to find things. This leads to some things not working correctly.If it works for you then I’d probably continue to use it until you hit something that isn’t compatible. I’ll do another pass to see if I can test more thoroughly with cdkv2
@thdxr would be great to have a little more context on this - we have been successfully using CDK + pnpm + rush for the last year or so. We have a demo projects also deployed successfully with sst but we aren’t using all of sst’s features (e.g. add-cdk, we have typeCheck and lint disabled since we do those separately). Do you know what exactly isn’t supported? Or is it just that there are no guarantees?
Hey @riccardogiorato unfortunately we cannot support PNPM at this time due to CDK not supporting PNPM. We decided to wait for them to prioritize fixing their incompatibilities before we fix ours
Moving to pnpm with a Rush.js monorepo setup broke my SST app.
I have a lot of microservices and want to use pnpm to ensure consistency between services with module versions and to reduce downloads/build time
I think the solution here is not not assume the location of
tscin relation to thenode_modulesbut to do afs.statand check.https://github.com/serverless-stack/serverless-stack/blob/ce288401dde6fb237e504513b259cefba6fdb639/packages/cli/scripts/util/cdkHelpers.js#L69