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

I think Jest converter needs <rootDir>/ prefix? #5

Open
moltar opened this issue Feb 4, 2022 · 5 comments
Open

I think Jest converter needs <rootDir>/ prefix? #5

moltar opened this issue Feb 4, 2022 · 5 comments

Comments

@moltar
Copy link

moltar commented Feb 4, 2022

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 🚫
@kettanaito
Copy link
Member

kettanaito commented Feb 5, 2022

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 ./:

const prepentRootDir = given(startsWith('./'), (modulePath) =>
path.join('<rootDir>', modulePath)
)

Do you experience an issue because of this logic? Could you please share your entire .alias config file?

@moltar
Copy link
Author

moltar commented Feb 5, 2022

I was calling the fn programmatically. So I guess it's an undocumented use case 😀

@kettanaito
Copy link
Member

kettanaito commented Feb 5, 2022

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.

@moltar
Copy link
Author

moltar commented Feb 7, 2022

import { toJestConfig } from 'dotalias/lib/converters/toJestConfig'

const paths: Record<string, string> = {
  bar: './../bar/src'
}

toJestConfig(paths).moduleNameMapper

@moltar
Copy link
Author

moltar commented Feb 7, 2022

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

2 participants