-
Notifications
You must be signed in to change notification settings - Fork 205
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
Module extensions not working? #201
Comments
Hmm.. Afaik, the Would you have a test repo by any chance? |
After poking through the code, there seems to be two problems in v3. In the examples cited I am using these options for module resolver: {
root: ['.'],
extensions: ['.web.js', '.js', '.json', ''],
} and I am trying to resolve a file at
|
I created PR #247 to address those two issues. I set stripExtensions by default to the extensions param to preserve the old behavior of stripping extensions specified. |
Because the extensions are not needed for node find the file. But it seems that in your case, you'd like to keep @fatfisz This is funny, I have the feeling this is a good use case of a custom |
Yep, that's correct that I need to keep the Thanks for explaining, makes more sense now as why it works the way it does. While it might be nice to resolve the extensions based on platform, I still think it would be good to give the user explicit control as there will always be other scenarios which we can't detect by platform. e.g. my use of |
@tleunen I stumbled upon the same issue, I wrote my own plugin real quick but what's the reason for not allowing relative paths? |
@wardpeet There wasn't any real reason to be honest. My first implementation didn't use any custom extension (that was done later on in the development process), so it wasn't needed and was not done to make the plugin faster. But now with the custom extension, it makes sense to read all paths, I agree. And I'd like to merge this PR which will resolve your issue as well #259 |
Awesome! Keep up the good work! |
alias is working but extensions is not working for me! ` test("test", () => { Cannot find module '../src/libs/logger' from 'logger.test.js' |
@wardpeet |
I'm trying to use this plugin to handle module resolution in my Jest unit tests for a Webpack project and it works pretty well, but I can't seem to get module extensions to work. My .babelrc looks like this:
Then I created the file
test/fixtures/foo.json
and inside oftest/class/Test_spec.js
I do this:import foo from 'fixtures/foo'
which throws this error:
If I add the extension:
import foo from 'fixtures/foo.json'
Everything works as expected. Any suggestions would be appreciated!
Relevant versions:
The text was updated successfully, but these errors were encountered: