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

Referencing file with same name as parent directory resolves to an erroneous path

Open kylegillen opened this issue 6 years ago • 0 comments

Hi.

Whenever I import a file in a React / Typescript project with the same name as its parent directory - excluding the extension, as is convention - the resolver converts to the following glob pattern: **/*. Hence the below returns the following (sic): cannot access module at ./app/components/**/*/Button. There seems to be some kind of pattern matching that turns 2 consecutive Paths into a glob. As if I append the extension, it works fine. Is this expected?

Here's my config:

[
  'module-resolver',
  {
    extensions: ['.ts', '.tsx'],
    alias: {
      components: './app/components',
    },
  },
],

Here's the import statement: import Button from 'components/Button/Button'

And the folder structure is:

app
-components
--Button
---Button.tsx

kylegillen avatar Oct 02 '19 22:10 kylegillen