-
Notifications
You must be signed in to change notification settings - Fork 135
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
feat(resolve): add fallback path to be able to resolve modules relatively to babel-plugin-macros
#138
Conversation
…vely to `babel-plugin-macros`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting. I'm curious what your use case is.
return resolve.sync(source, {basedir}) | ||
return resolve.sync(source, { | ||
basedir, | ||
paths: [p.resolve(__dirname, '../../')] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we include process.cwd()
in this as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, because it is a fallback only. If it cannot resolve relatively to basedir using node's built in resolve mechanism, then it tries with the provided paths as well (in the fallback case there is no travesing up to the parent, that's why ../../
is necessary).
I was using with process.cwd() included tho, but removing it didn't cause any issues. That case can only happen if plugin is installed outside of cwd and basedir is also not with-in cwd, which is highly unlikely imo. Should I add it just for safety?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My use case is that I have my devtools globally installed, so at project level I basically don't have any node_modules folder. This means babel-plugin-macros also being installed globally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's pretty odd. But as this doesn't break anything I'm fine with it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
@all-contributors please add @wintercounter for code |
I've put up a pull request to add @wintercounter! 🎉 |
Any ETA on the release? |
Sorry, there appears to be a problem with the build/release. Will try to resolve as soon as possible. |
🎉 This PR is included in version 2.8.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
What: #87
Why: In case you have
babel-plugin-macros
loaded outside ofprocess.cwd()
it cannot resolve modules realtively to itself.How: Added the node_modules folder including
babel-plugin-macros
as a fallback path.