What to use: goog.module vs ES6 module

116 views
Skip to first unread message

Rob Figueiredo

unread,
Jun 26, 2019, 10:54:09 PM6/26/19
to Closure Compiler Discuss
The Google JS Style guide says not to use ES6 modules because they are not finalized:
https://google.github.io/styleguide/jsguide.html#file-es6-modules

My understanding is that they were finalized in 2015, and the sense I get from reading the Closure Compiler wiki is that they are well supported by the tooling at this point. 

Can someone confirm that you would recommend ES6 modules instead of goog.module for all new code? 

Thank you!

Ben Lickly

unread,
Jun 27, 2019, 7:24:57 PM6/27/19
to Closure Compiler Discuss
If your only concern is Closure Compiler support or standardization, then you shouldn't hold back from moving to ES6 modules.

I think that some folks have concerns about things like bundling uncompiled code, which isn't possible with ES6 modules without rewriting them to some other module system first.

Steve Hicks

unread,
Jun 28, 2019, 8:42:49 PM6/28/19
to closure-comp...@googlegroups.com
We don't recommend them internally for various reasons.  Primarily, the interop story between goog.provide, goog.module, and ES modules ended up adding more complexity to our codebase than we were willing to accept (and it's not feasible to migrate everybody).

Externally, they're fine, especially if you're always compiling, or are able to use *only* ES modules throughout the entire compilation unit so that you have a good debug-loading story.  Personally, I use them together with Closure for my external projects and have had no difficulties from it (aside from import.meta not being implemented yet).

--

---
You received this message because you are subscribed to the Google Groups "Closure Compiler Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to closure-compiler-d...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/closure-compiler-discuss/361bf98b-d1d4-4982-acd1-7f647642eec1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages