google / google/closure-compiler

Absolute imports do not auto resolve to index.js files in node resolution mode

Open
#3,698 3 comments 1 reaction 1 assignee Claimed by @ChadKillingsworth View on GitHub
help wanted
Dominant language
JavaScript
Stars
7.7k
Forks
1.2k
Avg merge
2d 12h
Merged PRs (30d)
6

Description

Affects:

```
Version: v20200927.0.0
Built on: 2020-09-29 11:30
```

Inputs:

```javascript
// main.js
import { A } from 'foo';
console.log(A);

// foo/index.js
export const A = 'B';
```

Command:

```
java -jar compiler.jar -O ADVANCED --language_out ECMASCRIPT_2017 --module_resolution NODE --js main.js --js foo/index.js
```

Errors:

```
main.js:1:0: ERROR - [JSC_JS_MODULE_LOAD_WARNING] Failed to load module "foo"
1| import { A } from 'foo';
^
```

Expected output: No error

Notes: Relative imports (`import { A } from './foo'`) works as expected, outputs:

```javascript
'use strict';console.log("B");
```

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.