-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(lambda-nodejs): add bun support #31770
Conversation
a9e0a4e
to
8308ec9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.
A comment requesting an exemption should contain the text Exemption Request
. Additionally, if clarification is needed add Clarification Request
to a comment.
# Ensure all users can write to bun cache | ||
RUN mkdir /tmp/bun-cache && \ | ||
chmod -R 777 /tmp/bun-cache && \ | ||
echo -e "[install.cache]\ndir = \"/tmp/bun-cache\"" >> /home/user/.bunfig.toml |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no bun config set --global
command for this cache location. The best place to set this is in the global user
homedir according to the docs.
Therefore, this cache statement needs to happen after useradd
is called, not above where the other caches are configured. If it's called before, even if I create /home/user
, useradd
overwrites it.
Exemption Request - I'm following the patterns of existing PRs to add package managers, so I don't feel I need to add an integration test. |
@khushail - could I get a review on this? thanks in advance |
@blimmer , thanks for your contribution. I see this PR has label |
Hi @blimmer Great work on picking this up. We are also in need of this. It hasn't been moved for 3 weeks. Do you need any helping hand to proceed with this or it is waiting to find a community member to take a look |
Hey @suds-sky - this is awaiting community review. From my perspective it's good to go! |
Looks like the checks are failing, may be the reason community member is waiting for. There is CDK community Slack, may be we can reach there to get some help 🤔 |
The failing checks are because I didn't add an integration test. None of the other supported package managers add an integration test, so I felt I didn't need to add one for |
Exemption Request - I'm following the patterns of existing PRs to add package managers, so I don't feel I need to add an integration test. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #31770 +/- ##
==========================================
+ Coverage 78.66% 78.67% +0.01%
==========================================
Files 107 107
Lines 7237 7237
Branches 1329 1329
==========================================
+ Hits 5693 5694 +1
+ Misses 1358 1357 -1
Partials 186 186
Flags with carried forward coverage won't be shown. Click here to find out more.
|
@blimmer Thank you for your great work! I really want to use this feature. If you have any problem for that, please feel free to contact me. |
22bcd2a
to
4f3a72c
Compare
Thanks for the nudge. I missed that PNPM actually did have an integration test. I added one for |
✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.
The CodeQL failure is in the generated integration test code, so I think it's a false positive. |
@blimmer Thank you for your update. I'll check it later. Please wait for a while. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have only a question.
// Will be installed, not bundled | ||
// (axios is a package with sub-dependencies, | ||
// will be used to ensure bun bundling works as expected) | ||
nodeModules: ['axios'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please let me know: If axios is not listed in bun.lockb, will specifying it in nodeModules
still ensure it is installed and works correctly?
If that is the case, I think it would be better to run an integration test to ensure that a Lambda function using modules listed only in bun.lockb works correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is what's also done in the PNPM integration test:
Lines 16 to 19 in 81cde0e
// Will be installed, not bundled | |
// (axios is a package with sub-dependencies, | |
// will be used to ensure pnpm bundling works as expected) | |
nodeModules: ['axios'], |
Axios is listed in bun.lockb
, but specifying it in nodeModules
installs it using bun
inside the docker container (docs). I verified that the sub-dependencies (locked by bun.lockb
) were installed properly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I'm sorry for my late response.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love it! Thanks for adding support for bun.
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
### Issue aws#31753 Closes aws#31753. ### Reason for this change `bun` is rapidly gaining popularity because it's extremely performant compared to `node`. `bun` has its own lockfile, `bun.lockb`, which is not currently respected by AWS CDK when bundling `NodejsFunction`s. ### Description of changes This code is very well-structured, so it was simple to add bun support alongside `yarn`, `pnpm` and `npm`. ### Description of how you validated changes I linked this code up to a simple, sample CDK app with a `bun` lockfile. I wasn't able to `bun cdk synth` before my changes. Then, after linking up my local workspace, I was able to bundle with my `bun` lockfile. I also added unit tests similar to those that exist for the other packages managers. ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.
A comment requesting an exemption should contain the text Exemption Request
. Additionally, if clarification is needed add Clarification Request
to a comment.
This pull request has been removed from the queue for the following reason: Pull request #31770 has been dequeued, merge conditions unmatch:
You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it. If you want to requeue this pull request, you need to post a comment with the text: |
The pull request linter fails with the following errors:
PRs must pass status checks before we can provide a meaningful review. If you would like to request an exemption from the status checks or clarification on feedback, please leave a comment on this PR containing ✅ A exemption request has been requested. Please wait for a maintainer's review. |
@GavinZZ - any ideas what happened here? It's show 0 files changed... Seems like |
Oh, bizarre ... it merged but somehow lost being linked up with this PR? aed8ad1 |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Yes.. That's super weird and my first time seeing any issue like this. But it does seem that the original PR was merged. I'll close this PR since the actual content is merged. Feel free to tag me if you have any additional questions. |
Comments on closed issues and PRs are hard for our team to see. |
Issue #31753
Closes #31753.
Reason for this change
bun
is rapidly gaining popularity because it's extremely performant compared tonode
.bun
has its own lockfile,bun.lockb
, which is not currently respected by AWS CDK when bundlingNodejsFunction
s.Description of changes
This code is very well-structured, so it was simple to add bun support alongside
yarn
,pnpm
andnpm
.Description of how you validated changes
I linked this code up to a simple, sample CDK app with a
bun
lockfile. I wasn't able tobun cdk synth
before my changes. Then, after linking up my local workspace, I was able to bundle with mybun
lockfile.I also added unit tests similar to those that exist for the other packages managers.
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license