Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with jest when import from "." instead of "./index" #373

Open
ahadyekta opened this issue Nov 15, 2019 · 4 comments
Open

Problem with jest when import from "." instead of "./index" #373

ahadyekta opened this issue Nov 15, 2019 · 4 comments

Comments

@ahadyekta
Copy link

ahadyekta commented Nov 15, 2019

I`m using version 3.2.0 of this module. when I import a file like this in the code

import { something } from '.';

the app itself works but if I run the unit tests (jest) it will fail because it cannot import the file. If I change the "." to "./index" , tests work fine.
I used another package called babel-plugin-root-import which is similar to this package and it does not have this issue.

@ahadyekta
Copy link
Author

Update: this issue only happens if your config is like:

    ["module-resolver", {
      "root": ["./src"]
    }]

I changed it to :

    ["module-resolver", {
      "root": ["."],
      "alias": {
        "^~\/(.+)": "./src/\\1"
      }
    }]

and it fixed!
So if we have some prefix it works well.

@relign
Copy link

relign commented Sep 15, 2020

Why not consider this a Bug ?
There are many projects that use import xxx from '.' example
I think babel-plugin-module-resolver should support import xxx from '.'
@fatfisz

@fatfisz
Copy link
Contributor

fatfisz commented Sep 15, 2020

You're most welcome to create a PR with a fix 😊

@relign
Copy link

relign commented Sep 15, 2020

You're most welcome to create a PR with a fix 😊

#409 😊 😊 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants