Help resolving absolute imports in Expo 33

Sure you can use babel.config.js the two are mostly interchangeable see: Configure Babel · Babel.

I think you are close try checking where you place files and give the full extension eg: src/styles/RawTheme.js, then add extensions to your module_resolver config. here is my full babel.config.js (you probably dont need to set root: ['src']) like I do

const path = require('path')

const paths = {
  assets: path.resolve(__dirname, 'assets'),
  src: path.resolve(__dirname, 'src'),
}

module.exports = function(api) {
  api.cache(true)
  return {
    presets: ['babel-preset-expo'],
    plugins: [
      [
        'module-resolver',
        {
          extensions: [
            '.js',
            '.jsx',
            '.android.js',
            '.ios.js',
            '.web.js'
          ],
          root: ['./src'],
          alias: paths,
        }
      ]
    ]
  }
}
1 Like