babel-plugin-module-resolver
babel-plugin-module-resolver copied to clipboard
Problem with jest when import from "." instead of "./index"
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.
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.
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
You're most welcome to create a PR with a fix 😊
You're most welcome to create a PR with a fix 😊
https://github.com/tleunen/babel-plugin-module-resolver/pull/409 😊 😊 😊