-
Notifications
You must be signed in to change notification settings - Fork 12.3k
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
Compare package.json paths with correct sensitivity in getLocalModuleSpecifier #57973
Conversation
@typescript-bot pack this |
src/compiler/moduleSpecifiers.ts
Outdated
nearestTargetPackageJson &&= toPath(nearestTargetPackageJson, projectDirectory, getCanonicalFileName); | ||
nearestSourcePackageJson &&= toPath(nearestSourcePackageJson, projectDirectory, getCanonicalFileName); |
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.
Not clear if getNearestAncestorDirectoryWithPackageJson
should just always return Path.
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.
Or if i should just comparePaths
?
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 used elsewhere and a toPath
might have other negative affects at those use sites.
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.
If you mean my Path
comment, it's only used when reading a file so shouldn't actually affect anything, but it sounds like the comparison one may just be better.
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'd say just use comparePaths
. We use it throughout tryGetModuleNameFromExportsOrImports
against a path that comes from getNearestAncestorDirectoryWithPackageJson
as well, so it would be consistent.
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.
Updated to use a helper; slightly different than the one you suggested but I was having trouble understanding what I was reading...
Hey @jakebailey, I've packed this into an installable tgz. You can install it for testing by referencing it in your
and then running There is also a playground for this build and an npm module you can use via |
@typescript-bot test it |
@jakebailey Here they are:
tscComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
Developer Information: |
Hey @jakebailey, the results of running the DT tests are ready. Everything looks the same! |
@typescript-bot cherry-pick this to release-5.4 |
Hey, @jakebailey! I've created #57976 for you. |
@jakebailey Here are the results of running the user tests comparing Everything looks good! |
function packageJsonPathsAreEqual(a: string | undefined, b: string | undefined, ignoreCase?: boolean) { | ||
if (a === b) return true; | ||
if (a === undefined || b === undefined) return false; | ||
return comparePaths(a, b, ignoreCase) === Comparison.EqualTo; |
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.
dont you need to pass current directory for this to work correctly
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.
These paths are already absolute, it seems, so nothing broke...
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.
Checked the other use in this file and they don't pass in the working dir either (also for paths from this host method)
@jakebailey Here are the results of running the top 400 repos comparing Everything looks good! |
Fixes #57802 |
…e-5.4 (#57976) Co-authored-by: Jake Bailey <5341706+jakebailey@users.noreply.github.com>
Fixes #57956
Fixes #57926
Fixes #57802
Closes #57961
Thanks @xlianghang for the test.
See the second commit for the change.