-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
base: main
Are you sure you want to change the base?
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.41% 78.42% +0.01%
==========================================
Files 106 106
Lines 7208 7208
Branches 1323 1323
==========================================
+ Hits 5652 5653 +1
+ Misses 1369 1368 -1
Partials 187 187
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.
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
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). |
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