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: spaces in path-name results in error #13210

Closed
simon-dk opened this issue Feb 23, 2021 · 1 comment · Fixed by #13268
Closed

aws-lambda-nodejs: spaces in path-name results in error #13210

simon-dk opened this issue Feb 23, 2021 · 1 comment · Fixed by #13268
Assignees
Labels
@aws-cdk/aws-lambda-nodejs bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.

Comments

@simon-dk
Copy link
Contributor

Spaces in paths can break cdk synth when using @aws-cdk/aws-lambda-nodejs construct together with esbuild.
The resulting error is: "error: Must use "outdir" when there are multiple input files".

Sample repo

https://github.com/Simon-SDK/cdk_bug_report

Steps

Install repo and run "cdk synth".

Description

The error happens because of these two lines:

'--bundle', pathJoin(inputDir, this.relativeEntryPath),

`--outfile=${pathJoin(outputDir, 'index.js')}`,

The output of the esbuildCommand returns un-escaped paths, making esbuild believe there are multiple files, example:

npx esbuild --bundle /.../cdk/lib/lambda function/index.ts --target=node12 --platform=node --outfile=/.../cdk/cdk.out/bundling-temp-d5ad4854b4c5ea5068744c5b1b87fe2b04eec6a7aae0e3bdd2928a97638d2e5f/index.js --external:aws-sdk

If the lambda folder in the sample repo is changed to "lambda_function", "cdk synth" runs fine.

What did you expect to happen?

Cdk synth should build a index.js using esbuild without crashing.

What actually happened?

esbuild crashes because it (wrongly) expects multiple input-files.

Environment

  • CDK CLI Version: 1.87.0
  • **Framework Version:**1.90.1
  • Node.js Version: v12.16.1
  • OS : macOS 10.13.6
  • Language (Version): TypeScript (4.1.5)

Other


This is 🐛 Bug Report

@simon-dk simon-dk added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Feb 23, 2021
jogold added a commit to jogold/aws-cdk that referenced this issue Feb 24, 2021
@mergify mergify bot closed this as completed in #13268 Feb 25, 2021
mergify bot pushed a commit that referenced this issue Feb 25, 2021
…13268)

Closes #13210


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

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. needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants