From a24315af88fbe9a8412f3e391f7c64d522e4231f Mon Sep 17 00:00:00 2001 From: Tamas Date: Sat, 18 Apr 2020 22:19:18 +0200 Subject: [PATCH 1/3] Check for node runtimes first webpack should not try to load handlers of different runtime than node. --- lib/validate.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/validate.js b/lib/validate.js index b26bce3d7..21fcafb93 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -96,8 +96,12 @@ module.exports = { _.merge(entries, entry); } else { _.forEach(functions, (func, index) => { - const entry = getEntryForFunction.call(this, functions[index], this.serverless.service.getFunction(func)); - _.merge(entries, entry); + const loadedFunc = this.serverless.service.getFunction(func); + const runtime = loadedFunc.runtime || this.serverless.service.provider.runtime; + if (runtime.match(/^node/)) { + const entry = getEntryForFunction.call(this, functions[index], loadedFunc); + _.merge(entries, entry); + } }); } From 3e4c246a80b10a108a578d6a8d1cfd9190f01573 Mon Sep 17 00:00:00 2001 From: "Miguel A. Calles MBA" <44813512+miguel-a-calles-mba@users.noreply.github.com> Date: Fri, 12 Jun 2020 18:12:34 -0700 Subject: [PATCH 2/3] Update validate.test.js --- tests/validate.test.js | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/validate.test.js b/tests/validate.test.js index df62757e1..466631eeb 100644 --- a/tests/validate.test.js +++ b/tests/validate.test.js @@ -879,3 +879,4 @@ describe('validate', () => { }); }); }); + From ecd215490535b09c933983fe6caa78d803b02a8a Mon Sep 17 00:00:00 2001 From: "Miguel A. Calles MBA" <44813512+miguel-a-calles-mba@users.noreply.github.com> Date: Fri, 12 Jun 2020 18:14:02 -0700 Subject: [PATCH 3/3] Updated unit tests From: Add support for multiple runtimes in service #530 --- tests/validate.test.js | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/tests/validate.test.js b/tests/validate.test.js index 466631eeb..1ff9901f2 100644 --- a/tests/validate.test.js +++ b/tests/validate.test.js @@ -407,7 +407,8 @@ describe('validate', () => { path: 'func1path' } } - ] + ], + runtime: 'node10.x' }, func2: { handler: 'module2.func2handler', @@ -422,7 +423,8 @@ describe('validate', () => { { nonhttp: 'non-http' } - ] + ], + runtime: 'node10.x' }, func3: { handler: 'handlers/func3/module2.func3handler', @@ -431,7 +433,8 @@ describe('validate', () => { { nonhttp: 'non-http' } - ] + ], + runtime: 'node10.x' }, func4: { handler: 'handlers/module2/func3/module2.func3handler', @@ -440,7 +443,18 @@ describe('validate', () => { { nonhttp: 'non-http' } - ] + ], + runtime: 'node10.x' + }, + func5: { + handler: 'com.serverless.Handler', + artifact: 'target/hello-dev.jar', + events: [ + { + nonhttp: 'non-http' + } + ], + runtime: 'java8' } }; @@ -454,19 +468,24 @@ describe('validate', () => { path: 'func1path' } } - ] + ], + runtime: 'node10.x' } }; - it('should expose all functions if `options.function` is not defined', () => { + it('should expose all node functions if `options.function` is not defined', () => { const testOutPath = 'test'; const testConfig = { entry: 'test', context: 'testcontext', output: { path: testOutPath + }, + getFunction: func => { + return testFunctionsConfig[func]; } }; + _.set(module.serverless.service, 'custom.webpack.config', testConfig); module.serverless.service.functions = testFunctionsConfig; globSyncStub.callsFake(filename => [_.replace(filename, '*', 'js')]); @@ -879,4 +898,3 @@ describe('validate', () => { }); }); }); -