google / google/closure-compiler
CommonJS module rewriting incorrectly rewrites goog.modules
Open
ES6
triage-done
- Dominant language
- JavaScript
- Stars
- 7.7k
- Forks
- 1.2k
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 6
Description
I can't repro this in the debugger (can't guess what I need to configure to match my build), but here's what I'm seeing (names altered for brevity):
``` javascript
goog.module("a");
const f = v => {
if (v instanceof Array) v.forEach(e => f(e));
else console.log(v);
};
exports = {
f
}
```
```
... ERROR - variable f$$module$a is undeclared ...
```
Debugging the compiler, the variable in scope is actually named:
`module$contents$a_f`
I'm experimenting with commonjs modules, if it's related.
The workaround is to use
``` javascript
exports = {
f: f
}
```
Contributor guide
Assessment
This issue has not been assessed yet.