Enigmatic-Smile / serverless-plugin-optimize

⛔️ DEPRECATED ⛔️ Bundle with Browserify, transpile and minify with Babel automatically to your NodeJS runtime compatible JavaScript

Home Page:https://www.npmjs.com/package/serverless-plugin-optimize

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to deploy single functions

davidfells opened this issue · 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
`

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.

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.