-
Notifications
You must be signed in to change notification settings - Fork 4k
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): esbuild detection with Yarn 2 in PnP mode #14739
Conversation
Refactor how `esbuild` is detected and run: check for a local version first and fallback to a global installation. For local bundling, if a local version is detected, run `esbuild` using the right package manager. In Docker, always run the globally installed version. Support for PNPM could now easily be added in another PR. Closes aws#13179
…cdk into lambda-nodejs-detect-esbuild
this.packageManager = PackageManager.fromLockFile(props.depsLockFilePath); | ||
|
||
Bundling.esbuildInstallation = Bundling.esbuildInstallation ?? EsbuildInstallation.detect(); | ||
const mustRunInDocker = !Bundling.esbuildInstallation?.version.startsWith(ESBUILD_VERSION); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const mustRunInDocker = !Bundling.esbuildInstallation?.version.startsWith(ESBUILD_VERSION); | |
const mustRunInDocker = !Bundling.esbuildInstallation?.version.startsWith(`${ESBUILD_MAJOR_VERSION}.`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am wondering if perhaps we should just emit an error if the major version doesn't match, otherwise users will not understand why we fallback to docker.
import { BundlingOptions } from './types'; | ||
import { exec, extractDependencies, findUp, getEsBuildVersion, LockFile } from './util'; | ||
import { exec, extractDependencies, findUp } from './util'; | ||
|
||
const ESBUILD_VERSION = '0'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const ESBUILD_VERSION = '0'; | |
const ESBUILD_MAJOR_VERSION = '0'; |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
…e with a NodejsFunction In aws#14739 changed how `esbuild` is run. It now uses the package manager. When consuming a node module with a `NodejsFunction` we need to run `esbuild` from the directory containing the lock file. This is where we have `node_modules\.bin`. If we run it from the directory containing the entry file the package manager doesn't "see" `node_modules\.bin`.
…e with a NodejsFunction (#14914) #14739 changed how `esbuild` is run. It now uses the package manager. When consuming a node module with a `NodejsFunction` we need to run `esbuild` from the directory containing the lock file. This is where we have `node_modules\.bin`. If we run it from the directory containing the entry file the package manager doesn't "see" `node_modules\.bin`. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
…e with a NodejsFunction (aws#14914) aws#14739 changed how `esbuild` is run. It now uses the package manager. When consuming a node module with a `NodejsFunction` we need to run `esbuild` from the directory containing the lock file. This is where we have `node_modules\.bin`. If we run it from the directory containing the entry file the package manager doesn't "see" `node_modules\.bin`. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Original PR #13257.
Refactor how
esbuild
is detected and run: check for a local versionfirst and fallback to a global installation.
For local bundling, if a local version is detected, run
esbuild
usingthe right package manager.
In Docker, always run the globally installed version.
Support for PNPM could now easily be added in another PR.
Closes #13179
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license