-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Always use resolved file to figure out subModule name in package id #31541
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
Conversation
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.
Given the amount of test churn, this might be a big change but I can't tell. Can you go over the baseline changes with me in person so I can learn to read them? I have questions about a couple of the change patterns.
let packageId: PackageId | undefined; | ||
if (r && packageInfo) { | ||
const packageJsonContent = packageInfo.packageJsonContent as PackageJson; | ||
if (typeof packageJsonContent.name === "string" && typeof packageJsonContent.version === "string") { |
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.
name
and version
have type string | undefined
, right? It seems a lot clearer to write packageJsonContent.name !== undefined
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 name or version aren't defined, then you get no packageId now. Before this change, was it possible to get a packageId in situations where name or version would be undefined? What happens now in that case (if it exists)?
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.
it was exact same condition for package id to be present .. just copied it here instead. Given that the value is coming from Json I think checking string type is better but check can be updated to isString() instead for better readability
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, I think typeof x==='string'
is just as readable as isString
.
@@ -2,11 +2,8 @@ | |||
"======== Resolving module 'normalize.css' from '/a.ts'. ========", | |||
"Module resolution kind is not specified, using 'NodeJs'.", | |||
"Loading module 'normalize.css' from 'node_modules' folder, target file type 'TypeScript'.", | |||
"'package.json' does not have a 'typings' field.", | |||
"'package.json' does not have a 'types' field.", |
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.
why do these lines go away?
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.
Because we don’t look at the field to calculate sub module names
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.
Previously when sub module name was empty string these fields were read to get better name
Previously we calculated PackageId ( that is module name and submodule name) before resolving module and hence we didn't know when resolving
lib/option
whether it is going to belib\option.d.ts
file orlib\option\index.d.ts
which resulted in us assuming first path when resolved using relative path and when resolved using non relative path respectively. So we could refer to same file but derive different package id, resulting in us assuming those as distinct path (esp if one happens to resolve in project directory and other in shared directory).Now the submodule name is always calculated using resolved file name so as to be consistent irrespective of module name being relative or non relative.
Fixes #30429