Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

import.meta syntax error message needs work #336

Open
DerekNonGeneric opened this issue Feb 29, 2020 · 0 comments
Open

import.meta syntax error message needs work #336

DerekNonGeneric opened this issue Feb 29, 2020 · 0 comments
Assignees

Comments

@DerekNonGeneric
Copy link

DerekNonGeneric commented Feb 29, 2020

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.

import { createRequire } from 'module';
const require = createRequire(import.meta.url);
export default require;

rollup-plugin-closure-compiler outputs the following error, which is misleading.

[!] (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.

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.

  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!

@kristoferbaxter kristoferbaxter self-assigned this Mar 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants