monokrome/jaded-brunch

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

Closed this issue · 5 comments

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 1ad5891 (<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:

  • jade 1.0.2 returns .../node_modules/jade/index.js
  • jade 1.9.1 returns .../node_modules/jade/lib/index.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! :)

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!

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

@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.

@monokrome Thanks for the quick fix! It's working now. 👍

Hooray! :D