monokrome / jaded-brunch

Jade for brunch, supporting both dynamic and static loading jade.
MIT License
23 stars 10 forks source link

Plugin includes jade runtime.js which assumes 'exports' is present #14

Closed hwuethrich closed 9 years ago

hwuethrich commented 9 years ago

I'm using this plugin to generate static html files (not javascript templates). After upgrading this plugin to the latest version (1.7.11), I noticed the following error in the browser console:

Uncaught ReferenceError: exports is not defined

The error is caused by the included node_modules/jade/lib/runtime.js, which assumes a global exports object.

Versions prior to commit 1ad5891ba56e979d62b29ce0f0443f0346d9f6fc (<1.7.8) were including the file node_modules/jade/runtime.js, which uses a wrapper that defines exports if not present.

The underlying problem results from different versions of jade and using require.resolve('jade') to calculate the path of runtime.js:

I don't know if this change was intentional. I was able to workaround this problem by ignoring this file in the brunch config (which is not needed in my case):

exports.config =
  ...
  conventions:
    ignored: [
      'node_modules/jaded-brunch/node_modules/jade/lib/runtime.js'
    ]

Hope this helps! :)

monokrome commented 9 years ago

Hi, @hwuethrich. The runtime.js would only be used in cases where jade templates are being rendered client-side. I wonder if there is a way to get the plugin to not include runtime.js when no client-side / JS templates are being used.

The fact that it causes an error isn't very good, though. I wonder if that is an issue in jade itself. I will look into it a bit more later. Thank you so much for letting me know about this issue!

monokrome commented 9 years ago

@hwuethrich I've posted an issue on jade about this and am waiting a follow-up from them. Will keep this thread updated.

monokrome commented 9 years ago

@hwuethrich @teddybradford I've pushed a solution to this, so feel free to open the issue again if version 1.7.13 doesn't solve the problem.

hwuethrich commented 9 years ago

@monokrome Thanks for the quick fix! It's working now. :+1:

monokrome commented 9 years ago

Hooray! :D