From 0786f9014b5733d8826ae0f1caa1f0d758467b35 Mon Sep 17 00:00:00 2001 From: Frank Schmid Date: Tue, 15 May 2018 15:44:21 +0200 Subject: [PATCH 1/2] Updated docs for aws-sdk warning --- README.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/README.md b/README.md index 5beedc0..44bc1d7 100644 --- a/README.md +++ b/README.md @@ -247,6 +247,31 @@ custom: ``` > Note that only relative path is supported at the moment. +#### Runtime dependencies + +If a runtime dependency is detected that is found in the `devDependencies` section and +so would not be packages, the plugin will error until you explicitly exclude it (see `forceExclude` below) +or move it to the `dependencies` section. + +#### AWS-SDK + +An exception for the runtime dependency error is the AWS-SDK. All projects using the AWS-SDK normally +have it listed in `devDependencies` but Webpack will determine it as runtime dependency. In this case +only a warning is emitted instead of an error (and the aws-sdk is silently omitted from the package). + +The main reason for the warning is, that silently ignoring anything contradicts the declarative nature +of Serverless' service definition. So the correct way to define the handling for the aws-sdk is, as +you would do for all other excluded modules (see `forceExclude` below). + +```yaml +# serverless.yml +custom: + webpack: + includeModules: + forceExclude: + - aws-sdk +``` + #### Packagers You can select the packager that will be used to package your external modules. From 356bddaeb708862ee0247a85bf8d5496624ac006 Mon Sep 17 00:00:00 2001 From: Frank Schmid Date: Wed, 16 May 2018 10:09:22 +0200 Subject: [PATCH 2/2] Doc fixes. Use info message in verbose mode. --- README.md | 6 +++--- lib/packExternalModules.js | 2 +- tests/packExternalModules.test.js | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 44bc1d7..8400ace 100644 --- a/README.md +++ b/README.md @@ -250,14 +250,14 @@ custom: #### Runtime dependencies If a runtime dependency is detected that is found in the `devDependencies` section and -so would not be packages, the plugin will error until you explicitly exclude it (see `forceExclude` below) +so would not be packaged, the plugin will error until you explicitly exclude it (see `forceExclude` below) or move it to the `dependencies` section. #### AWS-SDK An exception for the runtime dependency error is the AWS-SDK. All projects using the AWS-SDK normally -have it listed in `devDependencies` but Webpack will determine it as runtime dependency. In this case -only a warning is emitted instead of an error (and the aws-sdk is silently omitted from the package). +have it listed in `devDependencies` because AWS provides it already in their Lambda environment. In this case +the aws-sdk is automatically excluded and only an informational message is printed (in `--verbose` mode). The main reason for the warning is, that silently ignoring anything contradicts the declarative nature of Serverless' service definition. So the correct way to define the handling for the aws-sdk is, as diff --git a/lib/packExternalModules.js b/lib/packExternalModules.js index 35487c4..6b1fc9e 100644 --- a/lib/packExternalModules.js +++ b/lib/packExternalModules.js @@ -115,7 +115,7 @@ function getProdModules(externalModules, packagePath, dependencyGraph, forceExcl throw new this.serverless.classes.Error(`Serverless-webpack dependency error: ${module.external}.`); } - this.serverless.cli.log(`WARNING: Runtime dependency '${module.external}' found in devDependencies. You should use forceExclude to explicitly exclude it.`); + this.options.verbose && this.serverless.cli.log(`INFO: Runtime dependency '${module.external}' found in devDependencies. It has been excluded automatically.`); } } }); diff --git a/tests/packExternalModules.test.js b/tests/packExternalModules.test.js index c872514..7eebd55 100644 --- a/tests/packExternalModules.test.js +++ b/tests/packExternalModules.test.js @@ -878,7 +878,7 @@ describe('packExternalModules', () => { mockery.registerMock(path.join(process.cwd(), 'ignoreDevDeps', 'package.json'), packageIgnoredDevDepsMock); return expect(module.packExternalModules()).to.be.fulfilled .then(() => BbPromise.all([ - expect(module.serverless.cli.log).to.have.been.calledWith(sinon.match(/WARNING: Runtime dependency 'aws-sdk' found in devDependencies/)), + expect(module.serverless.cli.log).to.have.been.calledWith(sinon.match(/INFO: Runtime dependency 'aws-sdk' found in devDependencies/)), // npm ls and npm install should have been called expect(packagerMock.getProdDependencies).to.have.been.calledOnce, expect(packagerMock.install).to.have.been.calledOnce,