babel-plugin-module-resolver icon indicating copy to clipboard operation
babel-plugin-module-resolver copied to clipboard

allow for optional relative resolve for non-standard extensions

Open sterlingwes opened this issue 4 years ago • 0 comments

This looks to resolve https://github.com/tleunen/babel-plugin-module-resolver/issues/201 which is a continuation of a couple open PRs: https://github.com/tleunen/babel-plugin-module-resolver/pull/259 and https://github.com/tleunen/babel-plugin-module-resolver/pull/317.

The feedback I see in those PRs seems to be that this is for a "non-standard" use case and the effect of putting relative path resolution in the "standard path" could be detrimental to the vast majority of use cases.

For this PR I've opted to make the relative resolution strategy an opt-in. Therefore, if you were looking to replicate the react-native extension behaviour, you'd have the following config:

{
  resolveRelativePaths: true,
  extensions: ['.ios.js', '.android.js', '.js'],
  stripExtensions: [],
}

or some variation. I'd note that this behaviour is becoming standard with the .web.js and .native.js extensions that are proliferating in react-land. I needed this for react-redux for example, which uses this to select the right batch method.

sterlingwes avatar Aug 29 '21 15:08 sterlingwes