diff --git a/README.md b/README.md index 5beedc0..8400ace 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 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` 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 +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. 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,