serverless-plugin-optimize icon indicating copy to clipboard operation
serverless-plugin-optimize copied to clipboard

Unable to deploy single functions

Open davidfells opened this issue 5 years ago • 2 comments

See example below. Full deployments run fine, but individual functions fail - aalways with the same error.

` ➜ pricr git:(serverless) ✗ sls deploy function --function pricingInsert Serverless: Optimize: starting engines Serverless: Optimize: pricr-development-pricingInsert

Syntax Error -------------------------------------------

SyntaxError: Assigning to rvalue (1:33522) while parsing /Users/davidfells/Projects/pricr/serverless_sdk/index.js while parsing file: /Users/davidfells/Projects/pricr/serverless_sdk/index.js `

davidfells avatar Apr 18 '20 20:04 davidfells

This package lacks essential settings while defaulting to a somewhat aggressive strategy.

I ended up replacing serverless-plugin-typescript and this one with serverless-webpack in my 12 projects. You need 15 min of hard crunching on the docs for your first webpack.config.js to make sense, but it will surely pays off.

vicary avatar May 24 '20 15:05 vicary

I ended up finding a workaround for this when porting all feature branches to serverless-webpack from this.

The problem is caused by babelify and @babel/core, they don't like the pre-bundled, already minified .build/serverless_sdk/index.js.

Current workaround is to add the following lines in your serverless.yml,

custom:
  optimize:
    ignore:
      - .build/serverless_sdk

IMO this package, being a serverless plugin, is responsible to take care of it by itself.

vicary avatar Jun 11 '20 11:06 vicary