-
Notifications
You must be signed in to change notification settings - Fork 204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Relative paths not working with Expo. #167
Comments
After a while trying to get this working. I could resolve the problem with de following {
"presets": ["babel-preset-expo"],
"env": {
"development": {
"plugins": ["transform-react-jsx-source"]
}
},
"plugins": [
["module-resolver", {
"root": ["./app"],
"alias": {
"@components": "./app/components",
"@config": "./app/config",
"@helpers": "./app/helpers",
"@navigators": "./app/navigators",
"@reducers": "./app/reducers",
"@screens": "./app/screens",
}
}]
]
} Seemingly after removing the "module-resolver" from |
I just hope it will al be even easier with the Glad you made it work :) |
After a while the problem started again. I'm getting the same error. {
"presets": ["babel-preset-expo"],
"env": {
"development": {
"plugins": ["transform-react-jsx-source"]
}
},
"plugins": [
["module-resolver", {
"src": [
"./node_modules"
],
"alias": {
"$components": "./app/components",
"$config": "./app/config",
"$helpers": "./app/helpers",
"$navigators": "./app/navigators",
"$reducers": "./app/reducers",
"$screens": "./app/screens",
"$images": "./assets/images",
"$fonts": "./assets/fonts",
"$icons": "./assets/icons",
"$videos": "./assets/videos",
"react-native-vector-icons": "@expo/vector-icons",
"@expo/vector-icons/lib/create-icon-set": "react-native-vector-icons/lib/create-icon-set",
"@expo/vector-icons/lib/icon-button": "react-native-vector-icons/lib/icon-button",
"@expo/vector-icons/lib/create-icon-set-from-fontello": "react-native-vector-icons/lib/create-icon-set-from-fontello",
"@expo/vector-icons/lib/create-icon-set-from-icomoon": "react-native-vector-icons/lib/create-icon-set-from-icomoon",
"@expo/vector-icons/lib/icon-button": "react-native-vector-icons/lib/icon-button",
"@expo/vector-icons/glyphmaps": "react-native-vector-icons/glyphmaps",
},
"cwd": "packagejson",
}]
]
} Any help? |
Could you please make a small repo and link to it here? It's very hard to debug based on the |
Here's the link: https://github.com/eduardoleal/module-resolver-test Thanks, for your help!!! |
Thanks! I'll try to work on this today or otherwise give a heads up. On the first look it seems that the versions of Just one more question: what is your OS? I'm working on Windows 10, could probably test on Ubuntu 16 too, but not on OS X. |
I'm using OS X 10.12.4. |
Ok, I managed to set the project up and have the same error. Will continue debugging tomorrow! |
Here's what I found out is happening:
This looks like a correct behavior to me, not a problem with the module-resolver plugin. I think the problem lies in the config of babel-preset-expo; there are circular aliases there, which means that the output may be different depending on the number of times the plugin was applied. In fact, after removing the @eduardoleal I suggest you raise this issue in the appropriate expo repo. I'd be happy to help expo maintainers with preparing a good configuration, but first I'd need to now the intent behind the current one, which I don't. Thanks a lot for preparing the repo, it helped a great deal with debugging :) |
@eduardoleal If you want a quick fix, copy the config of babel-preset-expo into yours (while removing it from the presets) and drop the |
I did copy the config of Here's my current config:
I will report this at |
Hi there! Here's the justification for the config there:
First, we want to alias
|
Edit: fixed after mucking around enough with the settings in this thread. (Had to get exponent to actually reload the code.) @brentvatne Any idea if this might conflict with Relay? I'm using @dev babel plugin build, and have been working on this a couple hours, unable to get past the error Unable to resolve module '@expo/vector-icons/glyphmaps/Entypo.json'
|
If it's possible to build @expo/vector-icons separately with this part
being applied there, then I'd definitely recommend this. Then it would be ok to keep only
Another way to go around this would be to use absolute paths
The problem is when the config is constructed in such a way that when applied two or more times to the same may yield different results. Sometimes this may unexpectedly happen because of the reasons outside of the control of the tool and hence the strange errors. I think that in the future there will be a warning for this, it seems like a common cause of unexpected problems with the plugin. |
@eduardoleal @brentvatne My {
"presets": ["react-native"],
"env": {
"development": {
"plugins": ["transform-react-jsx-source"]
}
},
"plugins": [
[
"module-resolver",
{
"alias": {
"react-native-vector-icons": "@expo/vector-icons"
}
}
],
"transform-decorators-legacy",
"transform-exponentiation-operator",
"transform-export-extensions"
]
} It's essentially |
I found that Expo is already using
babel-plugin-module-resolver
... So I've changed my .babelrc to create some aliases:but I got the following error:
How can I adjust
babel-plugin-module-resolver
and Expo to work together?The text was updated successfully, but these errors were encountered: