From 1a91fc2b67a6fb3382950f8a14dce8d48ba8d736 Mon Sep 17 00:00:00 2001 From: Jonathan Goldwasser Date: Wed, 18 Nov 2020 10:27:02 +0100 Subject: [PATCH] README and Error --- packages/@aws-cdk/aws-lambda-nodejs/README.md | 19 ++++++++++--------- .../aws-lambda-nodejs/lib/function.ts | 2 +- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/packages/@aws-cdk/aws-lambda-nodejs/README.md b/packages/@aws-cdk/aws-lambda-nodejs/README.md index c57f78e687a56..2797329f7de35 100644 --- a/packages/@aws-cdk/aws-lambda-nodejs/README.md +++ b/packages/@aws-cdk/aws-lambda-nodejs/README.md @@ -79,14 +79,15 @@ Use the [default image provided by `@aws-cdk/aws-lambda-nodejs`](https://github. as a source of inspiration. ### Lock file -The `NodejsFunction` tries to automatically determine your project lock file -(`package-lock.json` or `yarn.lock`). When bundling in a Docker container, the -path containing this lock file is used as the source (`/asset-input`) for the -volume mounted in the container. +The `NodejsFunction` requires a dependencies lock file (`yarn.lock` or +`package-lock.json`). When bundling in a Docker container, the path containing this +lock file is used as the source (`/asset-input`) for the volume mounted in the +container. -Alternatively, you can specify the `depsLockFilePath` prop manually. In this case you -need to ensure that this path includes `entry` and any module/dependencies used -by your function. Otherwise bundling will fail. +By default, it will try to automatically determine your project lock file. +Alternatively, you can specify the `depsLockFilePath` prop manually. In this +case you need to ensure that this path includes `entry` and any module/dependencies +used by your function. Otherwise bundling will fail. ### Configuring esbuild The `NodejsFunction` construct exposes some [esbuild](https://esbuild.github.io/) options via properties: `minify`, `sourceMaps` and `target`. @@ -119,8 +120,8 @@ new lambda.NodejsFunction(this, 'my-handler', { ``` The modules listed in `nodeModules` must be present in the `package.json`'s dependencies. The -same version will be used for installation. If a lock file is detected (`package-lock.json` or -`yarn.lock`) it will be used along with the right installer (`npm` or `yarn`). +same version will be used for installation. The lock file (`yarn.lock` or `package-lock.json`) +will be used along with the right installer (`yarn` or `npm`). ### Local bundling If esbuild is available it will be used to bundle your code in your environment. Otherwise, diff --git a/packages/@aws-cdk/aws-lambda-nodejs/lib/function.ts b/packages/@aws-cdk/aws-lambda-nodejs/lib/function.ts index 9f10ca8628b40..4145757cfcfb4 100644 --- a/packages/@aws-cdk/aws-lambda-nodejs/lib/function.ts +++ b/packages/@aws-cdk/aws-lambda-nodejs/lib/function.ts @@ -83,7 +83,7 @@ export class NodejsFunction extends lambda.Function { } else { const lockFile = findUp(LockFile.YARN) ?? findUp(LockFile.NPM); if (!lockFile) { - throw new Error('Cannot find a lock file. Please specify it with `depsFileLockPath`.'); + throw new Error('Cannot find a package lock file (`yarn.lock` or `package-lock.json`). Please specify it with `depsFileLockPath`.'); } depsLockFilePath = lockFile; }