google / google/closure-compiler
Support using goog.require to import an ES6 module
- Dominant language
- JavaScript
- Stars
- 7.7k
- Forks
- 1.2k
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 6
Description
It would be helpful – and likely even necessary – to be able to use `goog.require` to import ES6 modules in order to migrate a large codebase to the ES6 module system.
The wiki mentions interop and demonstrates doing a CommmonJS `require` of an ES6 module, but doesn't mention using `goog.require`: https://github.com/google/closure-compiler/wiki/JS-Modules#module-interoperation
In basic experiments, importing a module by its transformed path (e.g. `goog.require('module$path$to$module$file')`) compiles correctly. This doesn't seem like a stable or supported way of importing a module though.
I put together some experiments at https://gist.github.com/rictic/f042c2adf30101597fa5bd34a23d992d (buildable internal link: https://goto.google.com/js-module-interop-experiment) demonstrating different combinations of `goog.module`, `goog.provide` and ES6 modules as best as I understand the situation today.
Related bug: https://github.com/google/closure-compiler/issues/1877
Contributor guide
Assessment
This issue has not been assessed yet.