You've already forked serverless-webpack
mirror of
https://github.com/encounter/serverless-webpack.git
synced 2026-03-30 11:37:58 -07:00
Merge pull request #395 from serverless-heaven/added-doc-for-new-dep-warning
Updated docs and message for aws-sdk dependency exclusion
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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.`);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user