CommonJS support?

193 views
Skip to first unread message

Ben McCann

unread,
Jan 19, 2012, 8:47:50 PM1/19/12
to closure-lib...@googlegroups.com
Hi,

I recently started using a few projects such as the FireFox SDK and Play 2 Framework, which expect your JS to adhere to CommonJS.  This means that it uses require() instead of goog.requires().  E.g. here's the FireFox page on CommonJS.  I'd like to be able to use Closure library in my other JS projects, but it's a bit more difficult since it doesn't adhere directly to the standard.  Are there any plans to support CommonJS or any tips you can give me?

Thanks,
Ben

Chris Henry

unread,
Jan 20, 2012, 2:43:47 AM1/20/12
to closure-lib...@googlegroups.com
Afaik, there's no plan to support CommonJS. However, there are third-party implementations[1] to allow usage of Closure in node.js, which adheres to CommonJS. I don't know how easy it is to reuse any of the implementations directly in Firefox add-on, but hopefully they may be able to point you to the right direction.

Nick Santos

unread,
Jan 20, 2012, 12:17:58 PM1/20/12
to closure-lib...@googlegroups.com
I think Malte was working on a compiler pass to convert CommonJS
modules to closure-style files. See:
http://www.nonblocking.io/2011/12/experimental-support-for-common-js-and.html

It might be possible to go in the other direction?

Ben McCann

unread,
Jan 23, 2012, 2:51:32 PM1/23/12
to closure-lib...@googlegroups.com
Cool, thanks Nick.  I'll look more into what FireFox and Play require.  I'm not sure that I'll even need to go in the opposite direction.  I simply want to be able to integrate the FireFox SDK and Closure Library.  I'm not sure it matters which direction I go in, but I'll investigate more.

Thanks,
Ben

Reply all
Reply to author
Forward
0 new messages