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

aws-lambda-nodejs: charset props not work #32649

Open
1 task done
intptr-t opened this issue Dec 23, 2024 · 1 comment
Open
1 task done

aws-lambda-nodejs: charset props not work #32649

intptr-t opened this issue Dec 23, 2024 · 1 comment
Labels
@aws-cdk/aws-lambda-nodejs bug This issue is a bug. effort/medium Medium work item – several days of effort p1 potential-regression Marking this issue as a potential regression to be checked by team member

Comments

@intptr-t
Copy link

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(',')}`] : [],

https://github.com/aws/aws-cdk/blob/v2.173.2/packages/aws-cdk-lib/aws-lambda-nodejs/lib/bundling.ts#L260-L262

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
      },
    });
  }
}
@intptr-t intptr-t added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Dec 23, 2024
@github-actions github-actions bot added potential-regression Marking this issue as a potential regression to be checked by team member @aws-cdk/aws-lambda-nodejs labels Dec 23, 2024
@kellertk kellertk added p1 and removed needs-triage This issue or PR still needs to be triaged. labels Dec 23, 2024
@ashishdhingra
Copy link
Contributor

ashishdhingra commented Dec 23, 2024

@intptr-t Good afternoon. Thanks for opening the issue. You confirmed that the option for was removed it commit 3f1f974 via PR #25859. We are unsure if the ...this.props.charset ? [--charset=${this.props.charset}] : [] was meant to be removed in that PR via commit 3f1f974 (the charset option was added way back in 2021 via 56033a2). Marking this is p1 since it's been whole year. I have communicated this issue to the team.

Thanks,
Ashish

@ashishdhingra ashishdhingra added the effort/medium Medium work item – several days of effort label Dec 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-lambda-nodejs bug This issue is a bug. effort/medium Medium work item – several days of effort p1 potential-regression Marking this issue as a potential regression to be checked by team member
Projects
None yet
Development

No branches or pull requests

3 participants