facebook / facebook/flow

module.name_mapper doesn't work when pointing to a file within flow-typed

Open
#4,481 3 comments 1 reaction 0 assignees View on GitHub
declarations module resolution
Dominant language
Rust
Stars
22.3k
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Description

In my case, I was using `module.name_mapper.extension`, but `module.name_mapper` seemed to work the same.

If I have a `.flowconfig` like this:

```
[options]
module.name_mapper.extension='mp3' -> '/flow-typed/mp3-stub.js'
```

Flow will still error with "Required module not found" when importing an MP3 file. I have [a reduced case of this](https://github.com/bjohn465/flow-name_mapper-test/tree/3c17d1a4b9963412787b0c9e3a0ffaf51e471fb4).

When I move `mp3-stub.js` to a different directory, such as `flow-stubs`, the "Required module not found" error goes away, as seen [in this commit of the reduced case](https://github.com/bjohn465/flow-name_mapper-test/tree/335456fac80dd452469645930535861a91c3c4c7).

If this is intended behavior, it may be worth updating the [documentation](https://flow.org/en/docs/config/options/#toc-module-name-mapper-regex-string) to mention this restriction. I'd be willing to help with updating the documentation, if needed.

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.