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

Fix issue where `bundle.js` expect empty array for `include` option, instead of `null`

Open faizhasim opened this issue 8 years ago • 4 comments

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.

faizhasim avatar Feb 27 '17 06:02 faizhasim

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. ❤️

faizhasim avatar Feb 27 '17 07:02 faizhasim

I ran into the same issue and applied the workaround. What is yarn.lock? Is it just some arbitrary file?

jamiechong avatar Mar 05 '17 23:03 jamiechong

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 avatar Mar 06 '17 02:03 faizhasim

@faizhasim hero! This PR fixes the exactly same problem I'm having here. Thanks v much :)

bjfletcher avatar Mar 12 '17 15:03 bjfletcher