-
-
Notifications
You must be signed in to change notification settings - Fork 535
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 #1004: resolve config relative to realpath of entrypoint #1009
Conversation
768c401
to
f7a9d62
Compare
f7a9d62
to
5f28488
Compare
@@ -251,7 +252,21 @@ function getCwd (dir?: string, scriptMode?: boolean, scriptPath?: string) { | |||
throw new TypeError('Script mode cannot be combined with `--dir`') | |||
} | |||
|
|||
return dirname(scriptPath) |
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.
I think I’d be more comfortable noting that we only support symlinked directories instead of doing this, but up to you. If we only support directories it would become easy. Alternatively we can implement the resolver in a loop ourselves instead of messing with require.
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.
We might not even have TSX, JSX support extensions added either, so it’s another difference here. You could expose the function that creates a list of extensions, then just loop over that list and resolve like node.js does since we don’t need the extra require logic.
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.
Do we need to support loading a directory containing an index.*
file, or a directory containing a package.json
with a main
field pointing to another file? E.g. require('./directory-containing-package-json')
?
The chicken-and-egg problem with file extensions is a real bummer. I'll try to come up with some realistic examples of this causing problems in real life.
The only reason I was hoping to support symlinked scripts is so they can be put on the PATH
. npm
and yarn
do this a lot, and I can see it coming up in monorepo situations. (lerna, yarn2)
Here is my analysis for if Things we don't know that make it ambiguous
When resolution might match 2x different files, we may follow the wrong one, which may lead us to discover the wrong config. Ways ambiguity can happens
Contrived examples
Real-world examplesNone I can't think of a real-world situation where the contrived examples will occur. Mitigation strategiesBased on the above, I don't think ambiguity is a real problem. But if we want to avoid issues, here are a few strategies:
|
Fixes #1004.