Open moltar opened 2 years ago
Hey, @moltar. Thanks for this suggestion.
I've used <rootDir>
in the past but eventually migrated from it. I think the idea was for the relative paths to always be relative to the .alias
configuration file.
You're right, we are prepending the <rootDir>
if the path starts with ./
:
Do you experience an issue because of this logic? Could you please share your entire .alias
config file?
I was calling the fn programmatically. So I guess it's an undocumented use case 😀
Can you share how you're calling it?
Please, the more info and examples you provide, the more fruitful our discussion is going to be. I'm curious to see when the rootDir
may fail.
import { toJestConfig } from 'dotalias/lib/converters/toJestConfig'
const paths: Record<string, string> = {
bar: './../bar/src'
}
toJestConfig(paths).moduleNameMapper
Ok, I do see that there is logic to prepend this, based on the prefix.
If the path is
./
then<rootDir>/
is added.However, this doesn't seem to work in my case:
Given
../bar/src
=>../bar/src
is produced ✅./../bar/src
=>bar/src
is produced 🚫