tig
tig

Reputation: 3483

Minifying bootstrap.js with connect-assetmanager causes syntax error. Why?

Using connect-assetmanager in a node.js/Express app.

This works:

  js: {
      dataType: 'javascript',
      path: __dirname + '/../public/javascript/',
      files: [//'jquery-1.7.1.js'
             'bootstrap.min.js'
      ],
      route: /\/static\/javascript\/script\.js/
  }

(Note using the already minimized version of boostrap.js, and commented out the jquery file for testing).

This fails:

  js: {
      dataType: 'javascript',
      path: __dirname + '/../public/javascript/',
      files: [//'jquery-1.7.1.js'
             'bootstrap.js'
      ],
      route: /\/static\/javascript\/script\.js/
  }

Note the non-minimized bootstrap.js.

The failure is in the browser (Chrome). At line 120 in the connect-assetmanager compressed portion of bootstrap.js there's a syntax error:

119 isActive=$parent.hasClass('open')
120 clearMenus()!isActive&&$parent.toggleClass('open')
  Uncaught SyntaxError: Unexpected identifier
121 return false}}

This is my first go at using something like connect-assetmanager to minify/concat static files. Is this kind of thing typical with JS minifiers? What do I do about this?

It's doubtful we will need to really debug into bootstrap.js on the client outside of prod anytime soon, but I don't want to invest in connect-assetmanager if corruption of Javascript is typical.

Upvotes: 1

Views: 726

Answers (2)

slv007
slv007

Reputation: 328

You missed out the whole discussion on the missing semicolon issue with the bootstrap

https://github.com/twitter/bootstrap/issues/3057

Upvotes: 0

Zach
Zach

Reputation: 189

Not sure if this really counts as an answer, but the newer versions of the Bootstrap fix this issue.

Upvotes: 0

Related Questions