Skip to content
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

chore(lambda-nodejs): unescaped whitespace in props.bundling.inject breaks esbuild #29561

Merged
merged 8 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ class TestStack extends Stack {
runtime: STANDARD_NODEJS_RUNTIME,
});

new lambda.NodejsFunction(this, 'js-handler-bundling-path', {
entry: path.join(__dirname, 'integ-handlers/js-handler.js'),
bundling: {
inject: [path.join(__dirname, 'whitespace path/shim.js')],
},
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bombguy Did this not result in a snapshot change?


new lambda.NodejsFunction(this, 'ts-handler-vpc', {
entry: path.join(__dirname, 'integ-handlers/ts-handler.ts'),
runtime: STANDARD_NODEJS_RUNTIME,
Expand Down
2 changes: 1 addition & 1 deletion packages/aws-cdk-lib/aws-lambda-nodejs/lib/bundling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ export class Bundling implements cdk.BundlingOptions {
...this.props.banner ? [`--banner:js=${JSON.stringify(this.props.banner)}`] : [],
...this.props.footer ? [`--footer:js=${JSON.stringify(this.props.footer)}`] : [],
...this.props.mainFields ? [`--main-fields=${this.props.mainFields.join(',')}`] : [],
...this.props.inject ? this.props.inject.map(i => `--inject:${i}`) : [],
...this.props.inject ? this.props.inject.map(i => `--inject:"${i}"`) : [],
...this.props.esbuildArgs ? [toCliArgs(this.props.esbuildArgs)] : [],
];

Expand Down
4 changes: 2 additions & 2 deletions packages/aws-cdk-lib/aws-lambda-nodejs/test/bundling.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ test('esbuild bundling with esbuild options', () => {
'process.env.STRING': JSON.stringify('this is a "test"'),
},
format: OutputFormat.ESM,
inject: ['./my-shim.js'],
inject: ['./my-shim.js', './path with space/second-shim.js'],
esbuildArgs: {
'--log-limit': '0',
'--resolve-extensions': '.ts,.js',
Expand All @@ -264,7 +264,7 @@ test('esbuild bundling with esbuild options', () => {
defineInstructions,
'--log-level=silent --keep-names --tsconfig=/asset-input/lib/custom-tsconfig.ts',
'--metafile=/asset-output/index.meta.json --banner:js="/* comments */" --footer:js="/* comments */"',
'--main-fields=module,main --inject:./my-shim.js',
'--main-fields=module,main --inject:"./my-shim.js" --inject:"./path with space/second-shim.js"',
'--log-limit="0" --resolve-extensions=".ts,.js" --splitting --keep-names --out-extension:".js=.mjs"',
].join(' '),
],
Expand Down