Skip to content

Commit

Permalink
Drop unnecessary prefix for includeModules setting
Browse files Browse the repository at this point in the history
  • Loading branch information
Frank Schmid committed Mar 7, 2018
1 parent 2f1787d commit d7c5f8a
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 26 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ See the sections below for detailed descriptions of the settings. The defaults a
custom:
webpack:
webpackConfig: 'webpack.config.js' # Name of webpack configuration file
webpackIncludeModules: false # Node modules configuration for packaging
includeModules: false # Node modules configuration for packaging
packager: 'npm' # Reserved for future use. Any other values will not work right now.
packExternalModulesMaxBuffer: 200 * 1024 # Size of stdio buffers for spawned child processes
```
Expand Down Expand Up @@ -208,7 +208,7 @@ builtin package (ie: `aws-sdk`) and handling webpack-incompatible modules.

In this case you might add external modules in
[Webpack's `externals` configuration][link-webpack-externals].
Those modules can be included in the Serverless bundle with the `webpackIncludeModules`
Those modules can be included in the Serverless bundle with the `custom: webpack: includeModules`
option in `serverless.yml`:

```js
Expand All @@ -226,7 +226,7 @@ module.exports = {
# serverless.yml
custom:
webpack:
webpackIncludeModules: true # enable auto-packing of external modules
includeModules: true # enable auto-packing of external modules
```


Expand All @@ -241,7 +241,7 @@ use a different package file, set `packagePath` to your custom `package.json`:
# serverless.yml
custom:
webpack:
webpackIncludeModules:
includeModules:
packagePath: '../package.json' # relative path to custom package.json file.
```
> Note that only relative path is supported at the moment.
Expand All @@ -265,7 +265,7 @@ your service's production dependencies in `package.json`.
# serverless.yml
custom:
webpack:
webpackIncludeModules:
includeModules:
forceInclude:
- module1
- module2
Expand All @@ -282,7 +282,7 @@ Just add them to the `forceExclude` array property and they will not be packaged
# serverless.yml
custom:
webpack:
webpackIncludeModules:
includeModules:
forceExclude:
- module1
- module2
Expand Down
8 changes: 4 additions & 4 deletions lib/Configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const _ = require('lodash');
*/
const DefaultConfig = {
webpackConfig: 'webpack.config.js',
webpackIncludeModules: false,
includeModules: false,
packager: 'npm',
packExternalModulesMaxBuffer: 200 * 1024,
config: null
Expand All @@ -27,7 +27,7 @@ class Configuration {
// old configuration to keep backwards compatibility.
if (custom) {
if (custom.webpackIncludeModules) {
this._config.webpackIncludeModules = custom.webpackIncludeModules;
this._config.includeModules = custom.webpackIncludeModules;
this._hasLegacyConfig = true;
}
if (custom.packExternalModulesMaxBuffer) {
Expand All @@ -50,8 +50,8 @@ class Configuration {
return this._config.webpackConfig;
}

get webpackIncludeModules() {
return this._config.webpackIncludeModules;
get includeModules() {
return this._config.includeModules;
}

get packExternalModulesMaxBuffer() {
Expand Down
16 changes: 8 additions & 8 deletions lib/Configuration.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('Configuration', () => {
before(() => {
expectedDefaults = {
webpackConfig: 'webpack.config.js',
webpackIncludeModules: false,
includeModules: false,
packager: 'npm',
packExternalModulesMaxBuffer: 200 * 1024,
config: null
Expand All @@ -39,7 +39,7 @@ describe('Configuration', () => {
it('should use custom.webpackIncludeModules', () => {
const testCustom = { webpackIncludeModules: { forceInclude: ['mod1'] } };
const config = new Configuration(testCustom);
expect(config).to.have.a.property('webpackIncludeModules').that.deep.equals(testCustom.webpackIncludeModules);
expect(config).to.have.a.property('includeModules').that.deep.equals(testCustom.webpackIncludeModules);
});

it('should use custom.packExternalModulesMaxBuffer', () => {
Expand All @@ -66,10 +66,10 @@ describe('Configuration', () => {
webpack: 'myWebpackFile.js'
};
const config = new Configuration(testCustom);
expect(config).to.have.a.property('webpackIncludeModules').that.deep.equals(testCustom.webpackIncludeModules);
expect(config).to.have.a.property('includeModules').that.deep.equals(testCustom.webpackIncludeModules);
expect(config._config).to.deep.equal({
webpackConfig: 'myWebpackFile.js',
webpackIncludeModules: { forceInclude: ['mod1'] },
includeModules: { forceInclude: ['mod1'] },
packager: 'npm',
packExternalModulesMaxBuffer: 200 * 1024,
config: null
Expand All @@ -81,14 +81,14 @@ describe('Configuration', () => {
it('should use it and add any defaults', () => {
const testCustom = {
webpack: {
webpackIncludeModules: { forceInclude: ['mod1'] },
includeModules: { forceInclude: ['mod1'] },
webpackConfig: 'myWebpackFile.js'
}
};
const config = new Configuration(testCustom);
expect(config._config).to.deep.equal({
webpackConfig: 'myWebpackFile.js',
webpackIncludeModules: { forceInclude: ['mod1'] },
includeModules: { forceInclude: ['mod1'] },
packager: 'npm',
packExternalModulesMaxBuffer: 200 * 1024,
config: null
Expand All @@ -99,14 +99,14 @@ describe('Configuration', () => {
const testCustom = {
webpackIncludeModules: { forceExclude: ['mod2'] },
webpack: {
webpackIncludeModules: { forceInclude: ['mod1'] },
includeModules: { forceInclude: ['mod1'] },
webpackConfig: 'myWebpackFile.js'
}
};
const config = new Configuration(testCustom);
expect(config._config).to.deep.equal({
webpackConfig: 'myWebpackFile.js',
webpackIncludeModules: { forceInclude: ['mod1'] },
includeModules: { forceInclude: ['mod1'] },
packager: 'npm',
packExternalModulesMaxBuffer: 200 * 1024,
config: null
Expand Down
2 changes: 1 addition & 1 deletion lib/packExternalModules.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ module.exports = {

const stats = this.compileStats;

const includes = this.configuration.webpackIncludeModules;
const includes = this.configuration.includeModules;

if (!includes) {
return BbPromise.resolve();
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "serverless-webpack",
"version": "5.0.0-rc.3",
"version": "5.0.0-rc.4",
"description": "Serverless plugin to bundle your javascript with Webpack",
"main": "index.js",
"author": "Nicola Peduzzi <[email protected]> (http://elastic-coders.com)",
Expand Down
10 changes: 5 additions & 5 deletions tests/packExternalModules.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ describe('packExternalModules', () => {
},
configuration: new Configuration({
webpack: {
webpackIncludeModules: true
includeModules: true
}
})
}, baseModule);
Expand Down Expand Up @@ -327,7 +327,7 @@ describe('packExternalModules', () => {

module.configuration = new Configuration({
webpack: {
webpackIncludeModules: {
includeModules: {
packagePath: path.join('locals', 'package.json')
}
}
Expand Down Expand Up @@ -508,7 +508,7 @@ describe('packExternalModules', () => {
};
module.configuration = new Configuration({
webpack: {
webpackIncludeModules: {
includeModules: {
forceInclude: ['pg']
}
}
Expand Down Expand Up @@ -558,7 +558,7 @@ describe('packExternalModules', () => {
};
module.configuration = new Configuration({
webpack: {
webpackIncludeModules: {
includeModules: {
forceInclude: ['not-in-prod-deps']
}
}
Expand Down Expand Up @@ -606,7 +606,7 @@ describe('packExternalModules', () => {
};
module.configuration = new Configuration({
webpack: {
webpackIncludeModules: {
includeModules: {
forceInclude: ['pg'],
forceExclude: ['uuid']
}
Expand Down

0 comments on commit d7c5f8a

Please sign in to comment.