babel-plugin-root-import
babel-plugin-root-import copied to clipboard
unable to find '.../.../.../src'
I have babel.config.js
:
module.exports = function(api) {
api.cache(true)
return {
plugins: [
[
'babel-plugin-root-import',
{
root: __dirname,
rootPathSuffix: 'src',
rootPathPrefix: '~/'
}
]
],
presets: ['module:metro-react-native-babel-preset'],
}
}
but am having issues loading modules with ~
. From src/components/organisms/Categories.js
, I try to import api from '~/services/api'
.
What could I possibly be missing here?
I'm facing the same issue.
Without the metro-react-native preset, I get this as babel output, which looks good:
import api from "../../services/api";
and with it, I get this, which also appears to be correct, as long as @babel/runtime
is available.
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");
var _api=_interopRequireDefault(require("../../services/api"));
Maybe something else happens when actually executed by the react-native build tools, but I'm not very familiar with it. Any more information you can provide, like the full error message?
Any updates on this? I'm getting the same issue as well
same as well
same here ;/
Have you tried the static babel config and seeing the same problem. I am seeing such issues when I try it with babel.config.js and a test package but not when using the static .babelrc configuration. https://babeljs.io/docs/en/config-files#config-function-api You should check whether the the babel.config.js really takes place
I'm using .babelrc
and works ok.