Skip to content

Commit

Permalink
fix(lambda-nodejs): banner and footer values not escaped (#14743)
Browse files Browse the repository at this point in the history
Escape values and use the new CLI options.

Closes #13576 

BREAKING CHANGE: using `banner` and `footer` now requires `esbuild` >= 0.9.0


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
jogold authored May 18, 2021
1 parent c7469cf commit 81aa612
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
5 changes: 2 additions & 3 deletions packages/@aws-cdk/aws-lambda-nodejs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ new lambda.NodejsFunction(this, 'my-handler', {
keepNames: true, // defaults to false
tsconfig: 'custom-tsconfig.json', // use custom-tsconfig.json instead of default,
metafile: true, // include meta file, defaults to false
banner : '/* comments */', // by default no comments are passed
footer : '/* comments */', // by default no comments are passed
banner : '/* comments */', // requires esbuild >= 0.9.0, defaults to none
footer : '/* comments */', // requires esbuild >= 0.9.0, defaults to none
},
});
```
Expand All @@ -166,7 +166,6 @@ new lambda.NodejsFunction(this, 'my-handler-with-commands', {
}
// ...
}

});
```

Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-lambda-nodejs/lib/bundling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ export class Bundling implements cdk.BundlingOptions {
...this.props.keepNames ? ['--keep-names'] : [],
...this.relativeTsconfigPath ? [`--tsconfig=${pathJoin(inputDir, this.relativeTsconfigPath)}`] : [],
...this.props.metafile ? [`--metafile=${pathJoin(outputDir, 'index.meta.json')}`] : [],
...this.props.banner ? [`--banner='${this.props.banner}'`] : [],
...this.props.footer ? [`--footer='${this.props.footer}'`] : [],
...this.props.banner ? [`--banner:js=${JSON.stringify(this.props.banner)}`] : [],
...this.props.footer ? [`--footer:js=${JSON.stringify(this.props.footer)}`] : [],
].join(' ');

let depsCommand = '';
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-lambda-nodejs/test/bundling.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ test('esbuild bundling with esbuild options', () => {
'--minify --sourcemap --external:aws-sdk --loader:.png=dataurl',
defineInstructions,
'--log-level=silent --keep-names --tsconfig=/asset-input/lib/custom-tsconfig.ts',
'--metafile=/asset-output/index.meta.json --banner=\'/* comments */\' --footer=\'/* comments */\'',
'--metafile=/asset-output/index.meta.json --banner:js="/* comments */" --footer:js="/* comments */"',
].join(' '),
],
}),
Expand Down

0 comments on commit 81aa612

Please sign in to comment.