Skip to content

Commit ed117a7

Browse files
authored
Merge pull request #1023 from serverless-heaven/1012-configuration-include-modules-no-install
bug: Prevent `includeModules` and `noInstall` at the same time.
2 parents 5a40e18 + 6e5025b commit ed117a7

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

lib/validate.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,12 @@ module.exports = {
109109

110110
this.webpackConfig = this.configuration.config || this.configuration.webpackConfig;
111111

112+
if (this.webpackConfig.includeModules && this.webpackConfig.packagerOptions.noInstall) {
113+
throw new this.serverless.classes.Error(
114+
'"includeModules" requires an installation, and cannot be used with "packagerOptions.noInstall".'
115+
);
116+
}
117+
112118
// Expose entries - must be done before requiring the webpack configuration
113119
const entries = {};
114120

tests/validate.test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,15 @@ describe('validate', () => {
137137
return module.validate().then(() => expect(module.webpackConfig.context).to.equal(testServicePath));
138138
});
139139

140+
it('should fail when `includeModules` and `packagerOptions.noInstall` are set', () => {
141+
const testConfig = {
142+
includeModules: true,
143+
packagerOptions: { noInstall: true }
144+
};
145+
_.set(module.serverless.service, 'custom.webpack.config', testConfig);
146+
expect(() => module.validate()).throws();
147+
});
148+
140149
describe('default target', () => {
141150
it('should set a default `webpackConfig.target` if not present', () => {
142151
const testConfig = {

0 commit comments

Comments
 (0)