-
Notifications
You must be signed in to change notification settings - Fork 71
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
Fix module resolution for preval.require #38
Conversation
@@ -121,7 +119,7 @@ function prevalPlugin({types: t, template, transformFromAst}) { | |||
} | |||
return result.value | |||
}) | |||
const absolutePath = p.join(p.dirname(filename), source.node.value) | |||
const absolutePath = p.resolve(p.dirname(filename), source.node.value) |
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.
This is actual change, rest of the stuff is formatted by prettier I believe
Codecov Report
@@ Coverage Diff @@
## master #38 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 4 4
Lines 98 98
Branches 20 20
=====================================
Hits 98 98
Continue to review full report at Codecov.
|
Thanks! Could you add a test to verify that the bug you found has been fixed and make sure it doesn't come back? 👍 |
@kentcdodds will do 🙌 Meanwhile, can you suggest most suitable structure for that kind of test? Can't think of anything but creating nested directory in tests. |
You could do it in fixtures 👍 |
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.
Super! Thanks!
That was quick! 👍 |
What:
path.join
->path.resolve
Why:
preval.require
won't resolve non-top level pathsHow: by updating code which resolves absolute path to module
This PR fixes an issue then using
preval.require('../../foo');
for non-top level modules. This results in resolution from incorrect base parent directory and throwsModule not found
with actually correct (from project root perspective) path, which is super confusing.