davidguttman / cssify

Simple middleware for Browserify to add css styles to the browser.
122 stars 19 forks source link

modules: Cannot read property 'debug' of undefined #43

Closed ahdinosaur closed 8 years ago

ahdinosaur commented 8 years ago

after enabling css modules with

{
  "browserify": {
    "transform": [
      ["cssify", { "modules": true } ]
    ]
  }
}

i got this error caused by this line

TypeError: Cannot read property 'debug' of undefined
    at processCss (/.../node_modules/cssify/lib/process-css.js:54:51)
    at DestroyableTransform._flush (/.../node_modules/cssify/lib/index.js:23:7)
    at DestroyableTransform.<anonymous> (/.../node_modules/readable-stream/lib/_stream_transform.js:123:12)
    at DestroyableTransform.g (events.js:260:16)
    at emitNone (events.js:67:13)
    at DestroyableTransform.emit (events.js:166:7)
    at prefinish (/.../node_modules/readable-stream/lib/_stream_writable.js:499:12)
    at finishMaybe (/.../node_modules/readable-stream/lib/_stream_writable.js:507:7)
    at endWritable (/.../node_modules/readable-stream/lib/_stream_writable.js:519:3)
    at DestroyableTransform.Writable.end (/.../node_modules/readable-stream/lib/_stream_writable.js:484:5)

a temporary hotfix is

{
  "browserify": {
    "transform": [
      ["cssify", { "modules": true, "_flags": { "debug": true } } ]
    ]
  }
}
faergeek commented 8 years ago

Which version of browserify do you have?

ahdinosaur commented 8 years ago

as far as i can tell, was using browserify@12.0.1 and watchify@3.6.1.

faergeek commented 8 years ago

Please test with PR I just submitted

ahdinosaur commented 8 years ago

yep, fixes the bug, thanks.

just wondering, is it supposed to set this debug to true when i call browserify . -d -o bundle.js? i can't tell reading browserify or module-deps source, but seems nothing additional is passed in if i console.log(options) in cssify.

faergeek commented 8 years ago

It's strange, but if you pass all options from CLI it works (_flags are there), if you use package.json it doesn't.

ahdinosaur commented 8 years ago

hmm, true. and from the last line of the browserify transform docs:

Options sent to the browserify constructor are also provided under opts._flags. These browserify options are sometimes required if your transform needs to do something different when browserify is run in debug mode, for example.

so maybe this is a bug.

ahdinosaur commented 8 years ago

submitted an issue upstream

faergeek commented 8 years ago

Thanks, I wasn't sure that it is a documented behavior :+1: