Open
Description
Describe the bug
When building TypeScript/JavaScript with aws-lambda-nodejs
, the parameter (Charset.UTF8) that does not escape non-ASCII characters does not work.
Regression Issue
- Select this option if this issue appears to be a regression.
Last Known Working CDK Version
v2.85.0
Expected Behavior
If UTF8 is specified for charset, --charset=utf8
is passed to esbuild so that characters are output without escaping.
example expected output
// package/example.ts
var handler = async () => {
console.log("Japanese:日本語");
};
export {
handler
};
Current Behavior
Even if UTF8 parameters are passed, escaped strings are always output.
example current output
// package/example.ts
var handler = async () => {
console.log("Japanese:\u65E5\u672C\u8A9E");
};
export {
handler
};
Reproduction Steps
Restores the process of setting the deleted charset.
...this.props.banner ? [`--banner:js=${JSON.stringify(this.props.banner)}`] : [],
...this.props.footer ? [`--footer:js=${JSON.stringify(this.props.footer)}`] : [],
+ ...this.props.charset ? [`--charset=${this.props.charset}`] : [],
...this.props.mainFields ? [`--main-fields=${this.props.mainFields.join(',')}`] : [],
Possible Solution
No response
Additional Information/Context
The following commit confirms that it has been removed.
3f1f974
file: packages/aws-cdk-lib/aws-lambda-nodejs/lib/bundling.ts
CDK CLI Version
2.173.2
Framework Version
No response
Node.js Version
v22.11.0
OS
macOS
Language
TypeScript
Language Version
No response
Other information
Example stack code
export class TestStack extends cdk.Stack {
constructor(scope: Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
new NodejsFunction(this, "Test", {
entry: "example.ts",
handler: "index.handler",
runtime: Runtime.NODEJS_22_X,
bundling: {
format: OutputFormat.ESM,
charset: Charset.UTF8, // <-- This property is not work
},
});
}
}