I've created a project using expo typescript template. Running on iOS and Android. No web.
I then set up path alias in tsconfig.json
as follows:
"paths": {
"@models/*": ["./src/models/*"],
"@navigation/*": ["./src/navigation/*"],
"@services/*": ["./src/services/*"],
"@components/*": ["./tsx/components/*"],
"@screens/*": ["./tsx/screens/*"],
"@assets/*": ["./assets/*"]
}
Correspondingly, I configured babel.config.js
as follows:
plugins: [
[
'module-resolver',
{
root: ['./'],
alias: {
'@models': path.resolve(path.dirname('.'), 'src/models'),
'@navigation': path.resolve(path.dirname('.'), 'src/navigation'),
'@services': path.resolve(path.dirname('.'), 'src/services'),
'@screens': path.resolve(path.dirname('.'), 'tsx/screens'),
'@components': path.resolve(path.dirname('.'), 'tsx/components'),
'@assets': path.resolve(path.dirname('.'), 'assets'),
}
}
]
]
The above configuration works. App is bundled and runs fine. However the following non-critical errors are emitted during bundle:
transform[stderr]: Could not resolve "/Users/jblues/mobbiz/LOSMobileApp/src/navigation/AppNavigator" in file /Users/jblues/LOSMobileApp/tsx/App.tsx.
transform[stderr]: Could not resolve "/Users/jblues/LOSMobileApp/tsx/components/BottomTabNavigator" in file /Users/jblues/LOSMobileApp/src/navigation/AppNavigator.ts.
transform[stderr]: Could not resolve "/Users/jblues/mobbiz/LOSMobileApp/tsx/screens/Login" in file /Users/jblues/LOSMobileApp/src/navigation/AppNavigator.ts.
. . and so on. Is there something that I can add to my config to prevent these errors?