-
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
fix(lambda-nodejs): fixing esbuildArgs to take in account re-specified keys #29167
Conversation
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.
@@ -245,6 +245,7 @@ test('esbuild bundling with esbuild options', () => { | |||
'--resolve-extensions': '.ts,.js', | |||
'--splitting': true, | |||
'--keep-names': '', | |||
'--out-extension': '.js=.mjs', |
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.
why do we need this?
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 is a list of esbuildArgs that uses ':' to assign the flags. Here is the list with all of them. I have added this line to check if the code is working fine. out-extension
is one of the fields that uses :
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.
so why didn't we add the others here?
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 reason I chose --out-extension
to test the code is because it was the one among the list that could be set without modifying much of the test code or without breaking any existing functionality.
2394c07
to
5527941
Compare
✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.
Great job on fixing the integration test. However it seems you need to rebase your changes on the latest changes in the main branch. Also can you change the title to: This should be clear to the reviewers what problems you are trying to fix. |
--foo:bar
@@ -418,10 +418,13 @@ function toTarget(runtime: Runtime): string { | |||
|
|||
function toCliArgs(esbuildArgs: { [key: string]: string | boolean }): string { | |||
const args = new Array<string>(); | |||
const ls = ['--alias', '--drop', '--pure', '--log-override', '--out-extension']; |
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.
what does ls
stand for here? Should this variable have a better/clearer name?
Also, does it make sense maybe to have this as a top level constant instead of just being a local variable here?
(I'm not sure about this because I'm not familiar with other functionalities or the structure of this file)
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 changed the name to reSpecifiedKeys
, making it more specific to what the list is about. And I have kept the list inside toCliAgs
function as it is being used inside this function only and for other functions too they have their constants declared inside the Function only.
I'm a bit hesitant to approve this PR because I'm not sure if this change will cause a breaking change as technically these new args will come in effect after this PR. And there may be users who used these args in their CDK stack before the PR (and CDK falsely ignore these args, now adding effect to these args cause a behavioural change, although very unlikely). Will get another team member to review this for a second opinion. |
Dismissing my concern, I didn't notice that before the code change, it will cause an error during deployment. Happy to approve. |
@mergify update |
❌ Mergify doesn't have permission to updateFor security reasons, Mergify can't update this pull request. Try updating locally. |
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). |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
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 # (if applicable)
Closes #25385
Reason for this change
This PR fixes a bug in CDK where CDK does not take into account re-specified keys while doing bundling. The CLI supports flags in one of three forms:
--foo
,--foo=bar
, or--foo:bar
. However, the--foo:bar
form was not initially supported.With
--foo:bar
, users can now specify flags that have multiple values and can be re-specified multiple times.Description of changes
The code has a list of keys that can be re-specified multiple times. While assigning the flags it checks whether the key is among the list of re-specified keys, if yes, it specifies the flag with
:
.Description of how you validated changes
The PR includes unit test and integration test both to validate the changes.
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license