Deploy single function ends in runtime errors but deploying whole service is fine, feels like a web pack or babel issue


#1

Hey Team,

I’ve got another stack moving towards production and as such we are working a lot on our live dev environments. I’ve just discovered a strange problem that feels to be related to web pack or babel loading. (for the record we are on web pack 3 and the appropriate other plugins).

If we deploy a service completely all is well, doesn’t matter if its a fresh deploy or updating the entire stack. If however I deploy a function the deployment process ends successfully but we get (randomly) one of the following errors:

  1. the function borks at import {}… OR states that a function (that is a function working wonderfully if we do a clean deploy) does not exist.

So it feels like this is webpack-serverless issue but Im stumped on it.

Anyone got this?


#2

That second error (function only works after full deploy) sounds suspiciously like you’re making a change that requires cloud formation to be updated. Remember that deploying a function only updates the code, not the entire cloud formation.

It would help if you can provide the exact error messages you’re getting.


#3

nah just working inside the app code, haven’t modified the environment in days.

To replicate all I need to do is add a comment to any function and deploy that function and get this.


Syntax error in module ‘handler’: SyntaxError
import { cwbRESify } from ‘./lib/representors/RESifier.representor.library’;
^^^^^^
SyntaxError: Unexpected token import
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:542:28)
at Object.Module._extensions…js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)

so its saying no bueno on the import that works if i deploy the whole thing.


#4

That error definitely looks like it’s uploading the source instead of compiling it.


#5

For what its worth, moved to 2.2.2 for serverless-webpack and add

package
individually: true

to serverless.yml