-
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
@aws-cdk/aws-lambda-nodejs: esbuildArgs alias must use : instead of = #25385
@aws-cdk/aws-lambda-nodejs: esbuildArgs alias must use : instead of = #25385
Comments
Using this argument instead will solve the issue: esbuildArgs: {
'--alias:@layer': 'my/new/path',
}, It will generate the proper In my case : externalModules: ['@aws-sdk/*', 'aws-lambda', '@layer/*', '/opt/nodejs/node_modules/*'],
esbuildArgs: {
'--alias:@layer': '/opt/nodejs/node_modules',
}, |
You're right, we don't have any logic for handling this. The code that currently handles this is found here aws-cdk/packages/aws-cdk-lib/aws-lambda-nodejs/lib/bundling.ts Lines 396 to 408 in 5bdb012
Looking at the documentation, it doesn't appear your workaround would work for all use cases, is that right? |
It's just a workaround and won't work for empty value but besides that seems like an OK'ish effortless solution. to fix it though we would need to go through all of them. but by default we could keep the '=' sign :
Something like that and fill the repeatableArgs with all the correct keys. Or get it from the types https://github.com/evanw/esbuild/blob/main/lib/shared/types.ts it seems that any types with Record or string[] would be with ':' ? |
…d keys (#29167) ### 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 - [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*
|
Describe the bug
I want to reference libs in my layers with
import { somefunc } from '@layer/somelib';
.When setting the alias build argument for esbuild, it throws an error :
It will generate a bundling step like this:
By replacing the
=
with:
it solves the issueExpected Behavior
esbuildArgs key/value needs
:
when it can be re-specified.Current Behavior
esbuildArgs['--alias'] is using
=
which leads to a bundle error.Full stack:
Reproduction Steps
CDK:
Lambda
Layer
Possible Solution
esbuildArgs key/value needs
:
when it can be re-specified; from documentation:Additional Information/Context
No response
CDK CLI Version
2.76.0 (build 78c411b)
Framework Version
No response
Node.js Version
Node.js v19.8.1
OS
WSL2 Ubuntu
Language
Typescript
Language Version
Typescript (5.0.4)
Other information
No response
The text was updated successfully, but these errors were encountered: