1

What's a good way to bundle a Common.JS project, and then minimize and obfuscate the bundled script? (The library is intended to be used in a browser.)

I'm experienced with the Google Closure Compiler, however I think I might like Common.JS better.

There will also be some Coffeescript files in the project, but I figure I can take care of them with a separate step by compiling them to Javascript.

Geoff
  • 9,470
  • 13
  • 52
  • 67
  • [related](http://stackoverflow.com/questions/5655975/how-can-i-convert-a-multi-file-node-js-app-to-a-single-file/5656037#5656037). If you want a program that bundles your code correctly with all the `require` calls then I don't think such a bundler exists yet. – Raynos Apr 17 '11 at 22:08
  • The Closure Compiler and CommonJS are different things. One does not preclude the use of another. The Closure Compiler is a fabulous piece of software. However, the CommonJS modules must be written to some tight restrictions in order to use Advanced Mode. Otherwise, you can only use Simple Mode, which doesn't give any obfuscation benefits at all, only minification. – Stephen Chung Apr 18 '11 at 07:50

1 Answers1

1

I wrote a small script to bundle/minify CommonJS modules a while back, it should do what you want (and it takes care of your coffeescript without an additional step)

Adrien
  • 9,551
  • 3
  • 26
  • 27
  • Looks interesting. I'll give it a try. If no one else has any thoughts I'll mark this as answered soon enough. Thanks. – Geoff Apr 21 '11 at 04:56