Skip to content
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

Always use resolved file to figure out subModule name in package id #31541

Merged
merged 3 commits into from May 23, 2019

Conversation

sheetalkamat
Copy link
Member

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 be lib\option.d.ts file or lib\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

Copy link
Member

@sandersn sandersn left a 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") {
Copy link
Member

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

Copy link
Member

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)?

Copy link
Member Author

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

Copy link
Member

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.",
Copy link
Member

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?

Copy link
Member Author

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

Copy link
Member Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

project references out of memory crash
2 participants