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

fix(lambda-nodejs): pnpm exec command #14954

Merged
merged 3 commits into from
Jun 3, 2021
Merged

Conversation

relm923
Copy link
Contributor

@relm923 relm923 commented Jun 2, 2021

Fix #14757

Expands on #14772

Currently get the following error when bundling with pnpm-lock.yaml

ERROR   ERROR  Unknown options: 'bundle', 'target', 'platform', 'outfile', 'external:aws-sdk'

Switch from pnpm run esbuild to pnpm exec esbuild -- to properly enable esbuild with pnpm

pnpm run only supports running commands defined in the package's manifest file - docs

pnpm exec supports executing a shell command in scope of a project - docs


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@gitpod-io
Copy link

gitpod-io bot commented Jun 2, 2021

@@ -60,6 +60,7 @@ export class PackageManager {
os.platform() === 'win32' ? `${runCommand}.cmd` : runCommand,
...runArgs,
bin,
...(this.lockFile === PackageManager.PNPM.lockFile ? ['--'] : []),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Required to pass parameters to bin command

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's introduce argsSeparator?: string in PackageManager.

Copy link
Contributor

@jogold jogold left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch @relm923! Thanks.

See my comments.

@@ -26,7 +26,7 @@ export class PackageManager {
public static PNPM = new PackageManager({
lockFile: 'pnpm-lock.yaml',
installCommand: ['pnpm', 'install'],
runCommand: ['pnpm', 'run'],
runCommand: ['pnpm', 'exec'],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Getting The "pnpm exec" command currently only works with the "-r" option with only exec.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you try:

pnpm --version

cd aws-cdk/packages/@aws-cdk/aws-lambda-nodejs

pnpm exec esbuild -- --bundle test/integ-handlers/ts-handler.ts

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK it's working. For some reason not in the Docker image...

@@ -60,6 +60,7 @@ export class PackageManager {
os.platform() === 'win32' ? `${runCommand}.cmd` : runCommand,
...runArgs,
bin,
...(this.lockFile === PackageManager.PNPM.lockFile ? ['--'] : []),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's introduce argsSeparator?: string in PackageManager.

Copy link
Contributor

@jogold jogold left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eladb LGTM

@mergify
Copy link
Contributor

mergify bot commented Jun 3, 2021

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject89A8053A-LhjRyN9kxr8o
  • Commit ID: fd73b75
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot merged commit df16d40 into aws:master Jun 3, 2021
@mergify
Copy link
Contributor

mergify bot commented Jun 3, 2021

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@relm923 relm923 deleted the relm/pnpm_fix branch June 3, 2021 13:05
hollanddd pushed a commit to hollanddd/aws-cdk that referenced this pull request Aug 26, 2021
Fix aws#14757

Expands on aws#14772

Currently get the following error when bundling with `pnpm-lock.yaml`
```
ERROR   ERROR  Unknown options: 'bundle', 'target', 'platform', 'outfile', 'external:aws-sdk'
```

----


Switch from `pnpm run esbuild` to `pnpm exec esbuild --` to properly enable esbuild with `pnpm`

`pnpm run` only supports running commands defined in the package's manifest file - [docs](https://pnpm.io/cli/run)

`pnpm exec` supports executing a shell command in scope of a project - [docs](https://pnpm.io/cli/exec)



----

*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
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(aws-lambda-nodejs): support pnpm
4 participants