Serverless-Boilerplate-Express-TypeScript icon indicating copy to clipboard operation
Serverless-Boilerplate-Express-TypeScript copied to clipboard

`pnpm` out of the box?

Open andenacitelli opened this issue 2 years ago • 10 comments

pnpm gives drastically better performance than npm and would improve the developer experience, especially because of the large number of development dependencies this template uses. Thoughts?

Note that it doesn't currently work out of the box if you just try and use pnpm. Getting this error: https://github.com/pnpm/pnpm/issues/3275

Workaround that I'm using:

Make a .czrc file:

{
  "path": "cz-conventional-changelog"
}

Remove relevant section from package.json:

"config": {
    "commitizen": {
      "path": "@commitlint/cz-commitlint"
    }
  },

Also set up a .npmrc like this, unsure if needed:

enable-pre-post-scripts=true
auto-install-peers=true
node-linker=hoisted

andenacitelli avatar Apr 06 '23 18:04 andenacitelli

@aacitelli, Sure, I can give a try by creating a .czrc file and remove the relevant section in package.json.

ixartz avatar Apr 07 '23 00:04 ixartz

If you want to contribute, I'm also open to PR.

ixartz avatar Apr 07 '23 00:04 ixartz

Found another bump in the road - serverless-bundle only supports npm and yarn. Error still seems to happen with npm though, so maybe using pnpm for everything except the bundler during deploy is still possible. Will report back after a bit of debugging.

https://www.npmjs.com/package/serverless-bundle image

EDIT: Error no longer occurs when removing this part of the serverless.yml:

externals:
      - "@prisma/client"
    copyFiles:
      - from: "prisma/schema.prisma"
        to: "./"

EDIT: As somewhat anticipated, Prisma crashes due to commenting out the above.

andenacitelli avatar Apr 07 '23 00:04 andenacitelli

Looks like this is the actual culprit:

    packagerOptions:
      scripts:
        - prisma generate && rimraf node_modules/@prisma/engines/** && rimraf node_modules/prisma/libquery_engine-[^rhel]* && prisma db push

Related info here https://github.com/AnomalyInnovations/serverless-bundle/issues/274

andenacitelli avatar Apr 07 '23 01:04 andenacitelli

@ixartz Deployed with the above packagerOptions commented out and things are fixed all the way through. I'm happy to put together a PR with all of this, just want to check with you what those commands are actually doing, and if removing them is an issue. Prisma in my function is working fine, and I'm successfully making calls, so I'm a bit confused why that's necessary.

andenacitelli avatar Apr 07 '23 01:04 andenacitelli

The above script is used when you deploy on production to migrate the Prisma schema. In local environment, the script is not used.

ixartz avatar Apr 07 '23 02:04 ixartz

This weekend, I'll remove serverless-bundle and it should solve your problem.

ixartz avatar Apr 07 '23 02:04 ixartz

@aacitelli I just migrate the project to serverless-esbuild from serverless-bundle. Hope it should solve your issue.

ixartz avatar Apr 07 '23 23:04 ixartz

@ixartz Will get the chance to pull from upstream and give it a whirl early next week. Appreciate the update!

andenacitelli avatar Apr 08 '23 16:04 andenacitelli

@aacitelli thank you for your help, let me know if you have any question.

ixartz avatar Apr 08 '23 16:04 ixartz