Resolve local file instead of from node_modules
"babel-plugin-module-resolver": "^3.1.1"
.babelrc
{
"presets": [
"react-native"
],
"plugins": [
[
"module-resolver",
{
"root": [
"./src"
]
}
],
"relay"
]
}
Project file structure
src
app
components
Button
Modal
...
when I do import like this import {Modal} from 'react-native'; somehow I import Modal from my project instead of from 'react-native'. Why??
How to prevent babel-plugin-module-resolver to go in deep? I want only to resolve app and nothing else, so resolver should care only about import starting from app like import ... from 'app/...';
Have you got any solution yet ! ?
I ended up with removing key root and added alias like:
"alias": {
"app": "./src/app",
"config": "./src/config",
....
}
so now imports work as I expected:
import Modal from 'app/components/Modal';
or
import {Modal} from 'react-native'; - now plugin resolved files as it should.
Looks like root key is not mandatory and it creates issue with correct file resolving.
@ViktorAksionov Out of curiosity, would you have a small repro project with the issue? This is the first time I hear that the root configuration is making a deep resolution...