facebook / facebook/flow

If a `name_mapper` points to a non-existent file, it should tell user that the mapped path doesn't exist (instead of the original path)

Open
#7,427 5 comments 0 reactions 0 assignees View on GitHub
enhancement error messages good first issue module resolution
Dominant language
Rust
Stars
22.3k
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Description

```
module.name_mapper='.*\.css$' -> '/css-modules-stub.js.flow'
```

```
import foo from `foo.css`
```

Flow version: 0.91.

## Expected behavior

Error should say:

```
Cannot find module 'foo.css' (after it was remapped to '/css-modules-stub.js.flow', check your .flowconfig mapper paths exist)
```

## Actual behavior

```
Cannot find module 'foo.css'
```

Related: https://github.com/facebook/flow/issues/3889

---

Another example:

```
module.name_mapper='debug' -> 'empty/object'
```

If `empty/object` doesn't exist, there is no message to say that is the cause of `Cannot resolve module 'debug'` error.

---

There are many cases where name_mapper breaks things by the user wouldn't know. Try this to show the errors that are generated:

```
module.name_mapper='.*' -> '/some-empty-stub.js'
```

Then you get errors like this:

```
Cannot import Component because there is no Component export in react. Did you mean import Component from "..."?
```

But the cause is that the name_mapper has mapped to a file that doesn't export anything.

# Related

- https://github.com/facebook/flow/issues/1068
- [DUPE] https://github.com/facebook/flow/issues/1090

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.