aws-cdk icon indicating copy to clipboard operation
aws-cdk copied to clipboard

(aws-lambda-nodejs): Support `bun` lockfiles for NodejsFunction bundling

Open blimmer opened this issue 1 year ago • 4 comments

Describe the feature

Today, NodejsFunction supports lockfiles from the following ecosystems:

  • NPM
  • Yarn
  • PNPM

bun is gaining in popularity and has its own lockfile, bun.lockb. It would be great if NodejsFunction supported using this lockfile.

Use Case

We've been migrating our apps to use bun since it's so much faster than node. However, when creating a new NodejsFunction with a bun lockfile, we get this error:

Error: Cannot find a package lock file (pnpm-lock.yaml, yarn.lock or package-lock.json). Please specify it with depsLockFilePath.

For now, we'll probably move over to a supported package manager, but we'd love to see native support for bun.lockb.

Proposed Solution

Update the bundling logic to include bun and support bun install-ing.

Other Information

No response

Acknowledgements

  • [x] I may be able to implement this feature request
  • [ ] This feature might incur a breaking change

CDK version used

2.162.1

Environment details (OS name and version, etc.)

MacOS

blimmer avatar Oct 14 '24 21:10 blimmer

Thanks @blimmer for submitting the feature request.

khushail avatar Oct 14 '24 22:10 khushail

Thanks @khushail - I've got a PR ready for review here: https://github.com/aws/aws-cdk/pull/31770

blimmer avatar Oct 15 '24 23:10 blimmer

I don't recommend developing using Bun and deploying to a Node platform. While I'm sure you'd be fine in the vast majority of cases, it could lead to some particularly annoying bugs.

Maybe I'm missing something, but it seems like this could only lead to confusion if users expect lock file support to imply Bun engine use.

Edit: After thinking on it a bit more, I think you'd likely be okay. The issues I've seen were related to moving Node projects to Bun, rather than the other way around.

epoctic avatar Oct 16 '24 19:10 epoctic

This logic just allows installing dependencies from package.json when you have a bun lockfile. Since bun uses the standard node_modules resolution of packages, I think we'd be OK in the vast majority of cases.

blimmer avatar Oct 16 '24 20:10 blimmer

Something really weird happened with the PR. The commit ended up on main (https://github.com/aws/aws-cdk/commit/aed8ad10c3d86497be34b2889466f770910d36ef), but the PR didn't get marked as merged. So, this is fixed and should out soon :+1:

blimmer avatar Dec 05 '24 22:12 blimmer

Comments on closed issues and PRs are hard for our team to see. If you need help, please open a new issue that references this one.

github-actions[bot] avatar Dec 05 '24 22:12 github-actions[bot]