google / google/closure-compiler
Unable to mix ES6 module syntax and goog.provide
- Dominant language
- JavaScript
- Stars
- 7.7k
- Forks
- 1.2k
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 6
Description
If you have a file which is has a `goog.provide` at the top, and then attempts to import ES6 module code, the compiler will throw the following exception:
```
[error] something.js:3: variable sum is undeclared
[error] import {sum, pi} from './math/lib';
[error] ^
[error] something.js:3: variable pi is undeclared
[error] import {sum, pi} from './math/lib';
[error] ^
[error] two errors found
```
Removing the `goog.provide` at the top of the file allows this file to compile without errors.
It would be useful to allow existing Closure code to import newer ES6 code.
### Test Files:
`something.js`;
``` js
goog.provide('something');
import {sum, pi} from './math/lib';
console.log(sum(pi, pi));
```
`math/lib.js`;
``` js
export function sum(x, y) {
return x + y;
}
export var pi = 3.14159;
```
Contributor guide
Assessment
This issue has not been assessed yet.