Fix issue where `bundle.js` expect empty array for `include` option, instead of `null`
Problem
If package.include is not defined in the serverless.yml, the following error will be returned:
TypeError: Cannot read property 'length' of undefined
at GlobAll.globNext (/Users/faizhasim/dev/github/serverless-dynamic-dynamodb/node_modules/glob-all/glob-all.js:84:20)
at GlobAll.run (/Users/faizhasim/dev/github/serverless-dynamic-dynamodb/node_modules/glob-all/glob-all.js:78:8)
at Function.globAll.sync (/Users/faizhasim/dev/github/serverless-dynamic-dynamodb/node_modules/glob-all/glob-all.js:192:41)
at BbPromise (/Users/faizhasim/dev/github/serverless-dynamic-dynamodb/node_modules/serverless-plugin-browserify/lib/bundle.js:32:31)
at SlsBrowserify.bundle (/Users/faizhasim/dev/github/serverless-dynamic-dynamodb/node_modules/serverless-plugin-browserify/lib/bundle.js:31:12)
at SlsBrowserify.BbPromise.bind.then.then.then (/Users/faizhasim/dev/github/serverless-dynamic-dynamodb/node_modules/serverless-plugin-browserify/index.js:70:26)
From previous event:
at browserify:validate (/Users/faizhasim/dev/github/serverless-dynamic-dynamodb/node_modules/serverless-plugin-browserify/index.js:70:10)
at BbPromise.reduce (/Users/faizhasim/dev/github/serverless-dynamic-dynamodb/node_modules/serverless/lib/classes/PluginManager.js:160:50)
at runCallback (timers.js:651:20)
at tryOnImmediate (timers.js:624:5)
at processImmediate [as _immediateCallback] (timers.js:596:5)
From previous event:
at PluginManager.run (/Users/faizhasim/dev/github/serverless-dynamic-dynamodb/node_modules/serverless/lib/classes/PluginManager.js:160:22)
at Serverless.run (/Users/faizhasim/dev/github/serverless-dynamic-dynamodb/node_modules/serverless/lib/Serverless.js:91:31)
at serverless.init.then (/Users/faizhasim/dev/github/serverless-dynamic-dynamodb/node_modules/serverless/bin/serverless:23:50)
at process._tickCallback (internal/process/next_tick.js:103:7)
Workaround
Workaround is to define package.include as folowing:
package:
individually: true
include:
- yarn.lock
Fix
This PR is just a simple fix for that.
Btw, we use optimizely plugin during serverless 0.5, then went for webpack plugin when migrating to serverless 1.0-beta. Looking forward to use browserify again with this plugin. ❤️
I ran into the same issue and applied the workaround. What is yarn.lock? Is it just some arbitrary file?
What is yarn.lock? Is it just some arbitrary file?
We are using yarn instead of NPM to manage the dependencies. It spits out yarn.lock, similar to Gem lock or npm shrinkwrap. In this context, it's just some arbitrary files.
@faizhasim hero! This PR fixes the exactly same problem I'm having here. Thanks v much :)