Skip to content

Commit

Permalink
Merge pull request #663 from jgrantr/master
Browse files Browse the repository at this point in the history
Don't package non-node functions (fix for #644)
  • Loading branch information
j0k3r authored Feb 3, 2021
2 parents c43bbc2 + b2cf9ac commit b9fa44a
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 12 deletions.
32 changes: 21 additions & 11 deletions lib/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,10 @@ module.exports = {
if (_.has(this.serverless, 'service.package') && this.serverless.service.package.individually) {
this.multiCompile = true;
this.serializedCompile = this.configuration.serializedCompile;
this.options.verbose && this.serverless.cli.log(`Using ${this.serializedCompile ? 'serialized' : 'multi'}-compile (individual packaging)`);
this.options.verbose &&
this.serverless.cli.log(
`Using ${this.serializedCompile ? 'serialized' : 'multi'}-compile (individual packaging)`
);

if (this.webpackConfig.entry && !_.isEqual(this.webpackConfig.entry, entries)) {
return BbPromise.reject(
Expand All @@ -203,16 +206,23 @@ module.exports = {
}

// Lookup associated Serverless functions
const allEntryFunctions = _.map(this.serverless.service.getAllFunctions(), funcName => {
const func = this.serverless.service.getFunction(funcName);
const handler = func.handler;
const handlerFile = path.relative('.', getHandlerFile(handler));
return {
handlerFile,
funcName,
func
};
});
const allEntryFunctions = _.map(
_.filter(this.serverless.service.getAllFunctions(), funcName => {
const func = this.serverless.service.getFunction(funcName);
const runtime = func.runtime || this.serverless.service.provider.runtime || 'nodejs';
return runtime.match(/node/);
}),
funcName => {
const func = this.serverless.service.getFunction(funcName);
const handler = func.handler;
const handlerFile = path.relative('.', getHandlerFile(handler));
return {
handlerFile,
funcName,
func
};
}
);

this.entryFunctions = _.flatMap(entries, (value, key) => {
const entry = path.relative('.', value);
Expand Down
14 changes: 13 additions & 1 deletion tests/validate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,18 @@ describe('validate', () => {
}
],
runtime: 'java8'
},
rustfunc: {
handler: 'my-rust-func',
runtime: 'rust',
events: [
{
http: {
method: 'POST',
path: 'rustfuncpath'
}
}
]
}
};

Expand Down Expand Up @@ -960,7 +972,7 @@ describe('validate', () => {
});

describe('with skipped builds', () => {
it('should set `skipComile` to true if `options.build` is false', () => {
it('should set `skipCompile` to true if `options.build` is false', () => {
const testConfig = {
entry: 'test',
output: {}
Expand Down

0 comments on commit b9fa44a

Please sign in to comment.