Skip to content

Alias with array of paths #443

@JacobDel

Description

@JacobDel

In #261 it was discussed there could be two paths defined for one alias (if one path fails, there other could be used).
Is it possible that this implementation is broken? #376

used versions:

"babel-plugin-module-resolver": "^5.0.0",
"react-native": "0.70.6",

This does not work for me (babel.config.js):

module.exports = {
  presets: ['module:metro-react-native-babel-preset', '@babel/preset-react'],
  env: {
    production: {
      plugins: ['react-native-paper/babel'],
    },
  },
  plugins: [
    [
      'module-resolver',
      {
        root: [
          './src',
        ],
        alias: {
          //'@brand': './src/Apps/brands/default',
          '@brand': ['./src/Apps/brands/example','./src/Apps/brands/default'],
        },
        extentions: ['.js', '.jsx', '.ts', '.tsx'],
      },
    ],
  ],
};

This does work (difference is the path after '@brand' alias):

module.exports = {
  presets: ['module:metro-react-native-babel-preset', '@babel/preset-react'],
  env: {
    production: {
      plugins: ['react-native-paper/babel'],
    },
  },
  plugins: [
    [
      'module-resolver',
      {
        root: [
          './src',
        ],
        alias: {
          '@brand': './src/Apps/brands/default',
          //'@brand': ['./src/Apps/brands/example','./src/Apps/brands/default'],
        },
        extentions: ['.js', '.jsx', '.ts', '.tsx'],
      },
    ],
  ],
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions