ampproject / ampproject/rollup-plugin-closure-compiler
`import.meta` syntax error message needs work
- Dominant language
- TypeScript
- Stars
- 293
- Forks
- 28
- PR merge metrics
- No merged PRs in 30d
Description
## What's the issue?
The syntax error message for `import.meta` is worse than `google-closure-compiler` — provides misleading line number and does not specify exactly what went wrong.
Take the following code sample and attempt to compile it.
```js
import { createRequire } from 'module';
const require = createRequire(import.meta.url);
export default require;
```
`rollup-plugin-closure-compiler` outputs the following error, which is misleading.
```console
[!] (plugin closure-compiler) SyntaxError: Unexpected token (3:36)
undefined (3:36)
SyntaxError: Unexpected token (3:36)
at Parser.pp$4.raise [...]
```
- 💭 What token was unexpected?
- 💭 The "syntax error" occurred on line 2, yet it reports line 3?
`google-closure-compiler` outputs the following error, which is crystal-clear.
```console
ERROR - [JSC_CANNOT_CONVERT] This code cannot be converted from ES6. import.meta
const require = createRequire(import.meta.url);
^^^^^^^^^^^
1 error(s), 0 warning(s)
```
## How do we reproduce the issue?
Surely some of this is superfluous, but here's my configuration.
```js
plugins: [
compiler({
compilation_level: 'ADVANCED_OPTIMIZATIONS',
warning_level: 'VERBOSE',
checks_only: true,
jscomp_error: 'strictCheckTypes',
jscomp_off: [
'moduleLoad',
'undefinedVars',
],
language_in: 'ES_NEXT',
language_out: 'ECMASCRIPT_NEXT',
module_resolution: 'node',
process_common_js_modules: true,
extra_annotation_name: ['flag'],
}),
],
```
Thanks in advance for any effort towards correcting this!
Contributor guide
Assessment
This issue has not been assessed yet.