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): pnpm esbuild localCommand fails #15164

Closed
hugdru opened this issue Jun 16, 2021 · 3 comments · Fixed by #15410
Closed

(aws-lambda-nodejs): pnpm esbuild localCommand fails #15164

hugdru opened this issue Jun 16, 2021 · 3 comments · Fixed by #15410
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

@hugdru
Copy link
Contributor

hugdru commented Jun 16, 2021

The created localCommand for pnpm is failing because of an -- after esbuild:

[
  "pnpm exec esbuild --",
  "--bundle",
  "\"/home/me/repo/cdk/lib/lambda/quickSightGetUrl/lambdaCode/index.ts\"",
  "--target=node14.0.0",
  "--platform=node",
  "--outfile=\"/tmp/me/cdk.outKYr4UP/bundling-temp-be2edeadca3c5bca8951944d3db169f0f4c6f0dfbde8b9fcc9ee1bae265871f9/index.js\"",
  "--minify",
  "--external:aws-sdk"
]

Returns:

> error: Invalid build flag: "--"

The command works if I run it without the "--".

Reproduction Steps

npm install -g pnpm
mkdir test && cd test && pnpx cdk init app --language typescript
pnpm add @aws-cdk/aws-lambda-nodejs && pnpm add esbuild -D


cat << 'EOF' > "lib/test-stack.ts"
import * as cdk from '@aws-cdk/core';
import * as nodeLambda from '@aws-cdk/aws-lambda-nodejs';

export class TestStack extends cdk.Stack {
    constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
        super(scope, id, props);

        new nodeLambda.NodejsFunction(this, 'index', {})
    }
}
EOF

touch "lib/test-stack.index.ts"

pnpm install && pnpm cdk synth

What did you expect to happen?

A successful bundling when using pnpm

What actually happened?

The esbuild command failed with > error: Invalid build flag: "--"

Environment

  • CDK CLI Version : 1.108.1 (build ae24d8a)
  • Framework Version: 1.108.1
  • Node.js Version: v14.16.1
  • OS : Ubuntu 21.04
  • Language (Version): TypeScript (4.3.2)
  • pnpm: 6.7.6
  • esbuild: 0.12.9

Other

I had a look at https://github.com/pnpm/pnpm/blob/76136751958ceac0ee77e9a0466b96d4a093a094/packages/plugin-commands-script-runners/src/exec.ts#L73 and -- seems to be needed for backward compatibility as a first argument for exec.


This is 🐛 Bug Report

@hugdru hugdru added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jun 16, 2021
@hugdru hugdru changed the title (aws-cdk/aws-lambda-nodejs): pnpm esbuild localCommand fails (aws-lambda-nodejs): pnpm esbuild localCommand fails Jun 16, 2021
@jogold
Copy link
Contributor

jogold commented Jun 17, 2021

@relm923 any idea?

@hugdru
Copy link
Contributor Author

hugdru commented Jul 5, 2021

@jogold I think #15410 fixes the issue

@mergify mergify bot closed this as completed in #15410 Jul 8, 2021
mergify bot pushed a commit that referenced this issue Jul 8, 2021
Fixes the local bundling command when using the pnpm package manager. The args separator is now before the command as described in https://github.com/pnpm/pnpm/blob/76136751958ceac0ee77e9a0466b96d4a093a094/packages/plugin-commands-script-runners/src/exec.ts#L73.

fixes #15164

----

*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

github-actions bot commented Jul 8, 2021

⚠️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.

hollanddd pushed a commit to hollanddd/aws-cdk that referenced this issue Aug 26, 2021
Fixes the local bundling command when using the pnpm package manager. The args separator is now before the command as described in https://github.com/pnpm/pnpm/blob/76136751958ceac0ee77e9a0466b96d4a093a094/packages/plugin-commands-script-runners/src/exec.ts#L73.

fixes aws#15164

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
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.

3 participants