-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
Offer a way to import files relative to src/
#581
Comments
We already allow this if you explicitly set We won't diverge from Node resolution mechanism by default because there are very confusing corner cases. Like having a directory with the same name as a dependency. People have been burned hard over this in the past. You have two other options too. You can publish these helpers as a (private) module. Or you can create I hope this helps! |
Think it's a bit heavy to publish a module but I get the problem with conflicting names. It wouldn't be an issue if we would only catch names that start with No clear solution for this then :( |
Is setting NODE_PATH or setting up a global in setupTests.js not working for you? |
It's working for tests but not for re-usable modules/helpers. The directory structure of a project can become quite deep, let's say a file |
I don't understand. Setting NODE_PATH will give you precisely that. Have you tried it? |
|
Indeed, that works, thanks! I just didn't like adding |
Yeah. If you have suggestions on how to make this better while preserving the opt-in nature, please file an issue with your proposal. Maybe we could have a top-level directory called |
@gaearon on windows |
I quite like the idea how Vue solved it in How about adopting that idea to |
using |
Not really sure about this, but I find it quite annoying to have imports that look like:
Relative paths are good for resources that will always live next to the calling file but when referring to shared helpers/modules I find them quite counter-productive.
It would be possible to configure webpack so we could import files from
src/
just likeimport 'testUtils/myMock
or maybesrc/testUtils/myMock
by addingsrc
to the resolve root.Would it make sense ? Maybe relative paths are not that bad and I'm missing something ?
The text was updated successfully, but these errors were encountered: