google / google/closure-compiler

Warnings are excessively long with ES6 modules

Open
#3,129 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
7.7k
Forks
1.2k
Avg merge
2d 12h
Merged PRs (30d)
6

Description

Compiler internally rewrites ES6 module exports into variables containing full file path, evidently to avoid collisions. When printing out warnings it still uses those rewritten names which results in really long output which is hard to read through. CommonJS modules might suffer from the same issue, but I didn't check that.

Here's an example of an actual warning from an actual project that was encountered during development:

```
[WARN] /Users/kirilldronkin/Projects/projectname/src/application.js:5: WARNING - property home on abstract class AbstractApplication$$module$Users$kirilldronkin$Projects$projectname$node_modules$zombiebox$zb$abstract_application is not implemented by type Application$$module$Users$kirilldronkin$Projects$projectname$src$application
export default class Application extends BaseApplication {
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```

Full file system path of the project (` /Users/kirilldronkin/Projects/projectname/src`) is encountered three times here in one line. Warning message is 267 character long.

It can't fit GitHub comment window (use scrollbar to see it completely) and in terminal it breaks into several lines making it completely incomprehensible.

When those pile up it becomes a real nuisance.

A more concise variation of that warning could look like this:

```
[WARN] /Users/kirilldronkin/Projects/projectname/src/application.js:5:
WARNING - property home on abstract class AbstractApplication is not implemented by type Application
export default class Application extends BaseApplication {
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```

Perhaps the compiler could map the names back to originals before printing out its output since current names are uninformative, expose unnecessary inner implementation details and clog up the output.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.