facebook / facebook/flow

module.name_mapper not working

Open
#1,068 34 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Rust
Stars
22.3k
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Description

I can't get module.name_mapper to work on the example in the documentation:
http://flowtype.org/docs/advanced-configuration.html#options

Flow version: 0.18.1

Folder structure:

```
.
├── interfaces/
│ └── ImageStub.js
├── .flowconfig
├── app.js
└── foo.jpg
```

Contents of `.flowconfig`:

```
[libs]
.*/interfaces/*

[options]
module.name_mapper='^image![a-zA-Z0-9$_]+$'->'ImageStub'
```

Contents of `ImageStub.js`:

```
declare module ImageStub {
declare var exports: { [key: string]: string };
}
```

Contents of `app.js`:

```
/* @flow */

require('image!foo.jpg');
```

Here is the output when doing `flow check`:

```
app.js:3
3: require('image!foo.jpg');
^^^^^^^^^^^^^^^^^^^^^^^^ image!foo.jpg. Required module not found

Found 1 error
```

To make sure that the regex pattern wasn't the problem I tried to dumb it down and just do the following:

Contents of `.flowconfig`:

```
[libs]
.*/interfaces/*

[options]
module.name_mapper='image'->'ImageStub'
```

Contents of `ImageStub.js`:

```
declare module ImageStub {
declare var exports: { [key: string]: string };
}
```

Contents of `app.js`:

```
/* @flow */

require('image');
```

and again, this is the output of `flow check`:

```
app.js:3
3: require('image');
^^^^^^^^^^^^^^^^ image. Required module not found

Found 1 error
```

Any ideas?

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.