Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

faizhasim
Copy link

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
Copy link
Author

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

@jamiechong
Copy link

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

@faizhasim
Copy link
Author

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.

@bjfletcher
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants