Skip to content

Commit

Permalink
Merge pull request #1023 from serverless-heaven/1012-configuration-in…
Browse files Browse the repository at this point in the history
…clude-modules-no-install

bug: Prevent `includeModules` and `noInstall` at the same time.
  • Loading branch information
j0k3r authored Dec 10, 2021
2 parents 5a40e18 + 6e5025b commit ed117a7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ module.exports = {

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

if (this.webpackConfig.includeModules && this.webpackConfig.packagerOptions.noInstall) {
throw new this.serverless.classes.Error(
'"includeModules" requires an installation, and cannot be used with "packagerOptions.noInstall".'
);
}

// Expose entries - must be done before requiring the webpack configuration
const entries = {};

Expand Down
9 changes: 9 additions & 0 deletions tests/validate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,15 @@ describe('validate', () => {
return module.validate().then(() => expect(module.webpackConfig.context).to.equal(testServicePath));
});

it('should fail when `includeModules` and `packagerOptions.noInstall` are set', () => {
const testConfig = {
includeModules: true,
packagerOptions: { noInstall: true }
};
_.set(module.serverless.service, 'custom.webpack.config', testConfig);
expect(() => module.validate()).throws();
});

describe('default target', () => {
it('should set a default `webpackConfig.target` if not present', () => {
const testConfig = {
Expand Down

0 comments on commit ed117a7

Please sign in to comment.