google / google/closure-compiler

import/export directives ignored when not at the start of line

Open
#4,122 2 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

When debugging problems with unresolved import paths, it turned out that parsing import directives is triggered only when the directive actually starts the line:

JsFileRegexParser:347 (in version 20220601)

```
if (line.startsWith("import") || line.startsWith("export")) {
```

If you put whitespace before the import directive, it is just ignored.

Not sure if this is correct and/or intentional, in any case it is rather unexpected.

Contributor guide

Open the contributing guide

Research direction

Start at JsFileRegexParser:347 in the version cited by the issue and inspect how import and export directives are recognized. Check the surrounding parsing behavior for leading whitespace and determine the intended handling from existing tests or conventions. Done means the behavior for indented directives is explicitly covered and matches the project's intended parsing rules.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
compilers
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.