Getting closure-compiler and Node.js to play nice

Posted by bukzor on Stack Overflow See other posts from Stack Overflow or by bukzor
Published on 2011-11-27T17:47:14Z Indexed on 2011/11/27 17:50 UTC
Read the original article Hit count: 247

Filed under:
|
|

Are there any projects that used node.js and closure-compiler (CC for short) together?

The official CC recommendation is to compile all code for an application together, but when I compile some simple node.js code which contains a require("./MyLib.js"), that line is put directly into the output, but it doesn't make any sense in that context.

I see a few options:

  1. Code the entire application as a single file. This solves the problem by avoiding it, but is bad for maintenance.
  2. Assume that all files will be concatenated before execution. Again this avoids the problem, but makes it harder to implement a un-compiled debug mode.
  3. I'd like to get CC to "understand" the node.js require() function, but that probably can't be done without editing the compiler itself, can it?

© Stack Overflow or respective owner

Related posts about node.js

Related posts about require