Correctly resolve a `node_module` inside .flowconfig
- Lingua principale
- Rust
- Stelle
- 22.3k
- Fork
- 1.9k
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
I have webpack aliases set up in my webpack config:
```
resolve: {
extensions: ['.js', '.jsx'],
alias: {
components: path.resolve(__dirname, 'src/components/'),
styles: path.resolve(__dirname, 'src/components/styles/'),
utils: path.resolve(__dirname, 'src/utils/')
}
```
I also have [options] set up in my .flowconfig to account for this (so that I don't get Required module not found errors everywhere):
```
[ignore]
.*/node_modules/.*
[include]
[libs]
./libdefs.js
[options]
esproposal.class_static_fields=enable
esproposal.class_instance_fields=enable
esproposal.decorators=ignore
module.name_mapper='^components\(\/?.*\)$' -> '/src/components/\1'
module.name_mapper='^styles\(\/?.*\)$' -> '/src/components/styles/\1'
module.name_mapper='^utils\(\/?.*\)$' -> '/src/utils/\1'
```
I get no flow errors for standard imports from node_modules, like import moment from 'moment'. However, when I try and import from within a node_module like so:
```
import _uniqueId from 'lodash/uniqueId'
import classNames from 'classnames/bind'
```
I get the old error:
```
yarn run v0.20.3
$ "/Users/rorysmith/code/gen/node_modules/.bin/flow"
src/components/Calendar.jsx:4
4: import _times from 'lodash/times'
^^^^^^^^^^^^^^ lodash/times. Required module not found
src/components/Calendar.jsx:5
5: import _uniqueId from 'lodash/uniqueId'
^^^^^^^^^^^^^^^^^ lodash/uniqueId. Required module not found
src/components/Calendar.jsx:7
7: import classNames from 'classnames/bind'
^^^^^^^^^^^^^^^^^ classnames/bind. Required module not found
src/components/Category.jsx:16
16: import _uniqueId from 'lodash/uniqueId'
^^^^^^^^^^^^^^^^^ lodash/uniqueId. Required module not found
```
How can I resolve this so that the error doesn't show?
Guida per i contributori
Apri la guida per i contributori
Valutazione
Questa issue non è ancora stata valutata.