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

Compare package.json paths with correct sensitivity in getLocalModuleSpecifier #57973

Merged
merged 3 commits into from
Mar 28, 2024

Conversation

jakebailey
Copy link
Member

@jakebailey jakebailey commented Mar 27, 2024

Fixes #57956
Fixes #57926
Fixes #57802
Closes #57961

Thanks @xlianghang for the test.

See the second commit for the change.

@jakebailey
Copy link
Member Author

@typescript-bot pack this

@typescript-bot
Copy link
Collaborator

typescript-bot commented Mar 27, 2024

Starting jobs; this comment will be updated as builds start and complete.

Command Status Results
pack this ✅ Started ✅ Results

@typescript-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Mar 27, 2024
Comment on lines 553 to 554
nearestTargetPackageJson &&= toPath(nearestTargetPackageJson, projectDirectory, getCanonicalFileName);
nearestSourcePackageJson &&= toPath(nearestSourcePackageJson, projectDirectory, getCanonicalFileName);
Copy link
Member Author

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.

Copy link
Member Author

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?

Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member

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.

Copy link
Member Author

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...

@typescript-bot
Copy link
Collaborator

typescript-bot commented Mar 27, 2024

Hey @jakebailey, I've packed this into an installable tgz. You can install it for testing by referencing it in your package.json like so:

{
    "devDependencies": {
        "typescript": "https://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_apis/build/builds/160790/artifacts?artifactName=tgz&fileId=2ECF6F93582C4D4C0D57F671D7B6546C54FCF3418117B22E972D91463EAC789C02&fileName=/typescript-5.5.0-insiders.20240327.tgz"
    }
}

and then running npm install.


There is also a playground for this build and an npm module you can use via "typescript": "npm:@typescript-deploys/pr-build@5.5.0-pr-57973-2".;

@jakebailey jakebailey changed the title Ensure package.json dir is compared after being toPath'd Compare package.json paths with correct sensitivity Mar 27, 2024
@jakebailey jakebailey changed the title Compare package.json paths with correct sensitivity Compare package.json paths with correct sensitivity in getLocalModuleSpecifier Mar 27, 2024
@jakebailey
Copy link
Member Author

@typescript-bot test it

@typescript-bot
Copy link
Collaborator

typescript-bot commented Mar 27, 2024

Starting jobs; this comment will be updated as builds start and complete.

Command Status Results
test top400 ✅ Started ✅ Results
user test this ✅ Started ✅ Results
run dt ✅ Started ✅ Results
perf test this faster ✅ Started 👀 Results

@typescript-bot
Copy link
Collaborator

@jakebailey
The results of the perf run you requested are in!

Here they are:

tsc

Comparison Report - baseline..pr
Metric baseline pr Delta Best Worst p-value
Angular - node (v18.15.0, x64)
Memory used 295,686k (± 0.01%) 295,686k (± 0.01%) ~ 295,658k 295,714k p=0.936 n=6
Parse Time 2.66s (± 0.31%) 2.66s (± 0.28%) ~ 2.65s 2.67s p=0.306 n=6
Bind Time 0.84s (± 0.97%) 0.84s (± 1.06%) ~ 0.83s 0.85s p=0.550 n=6
Check Time 8.26s (± 0.15%) 8.22s (± 0.20%) -0.04s (- 0.42%) 8.19s 8.24s p=0.003 n=6
Emit Time 7.04s (± 0.18%) 7.05s (± 0.25%) ~ 7.02s 7.07s p=0.565 n=6
Total Time 18.79s (± 0.09%) 18.77s (± 0.05%) -0.02s (- 0.11%) 18.75s 18.78s p=0.046 n=6
Compiler-Unions - node (v18.15.0, x64)
Memory used 194,461k (± 0.95%) 193,352k (± 0.96%) ~ 192,061k 195,773k p=0.936 n=6
Parse Time 1.65s (± 0.77%) 1.66s (± 0.82%) ~ 1.64s 1.68s p=0.615 n=6
Bind Time 0.87s (± 0.59%) 0.88s (± 0.96%) ~ 0.86s 0.88s p=0.533 n=6
Check Time 11.26s (± 0.41%) 11.27s (± 0.35%) ~ 11.22s 11.31s p=0.629 n=6
Emit Time 3.15s (± 0.71%) 3.14s (± 0.79%) ~ 3.11s 3.17s p=0.571 n=6
Total Time 16.93s (± 0.39%) 16.94s (± 0.23%) ~ 16.88s 16.98s p=0.418 n=6
Monaco - node (v18.15.0, x64)
Memory used 347,407k (± 0.01%) 347,418k (± 0.01%) ~ 347,385k 347,480k p=0.689 n=6
Parse Time 3.70s (± 0.97%) 3.69s (± 1.31%) ~ 3.61s 3.76s p=1.000 n=6
Bind Time 1.38s (± 1.86%) 1.38s (± 0.54%) ~ 1.37s 1.39s p=0.548 n=6
Check Time 10.24s (± 0.44%) 10.23s (± 0.41%) ~ 10.17s 10.28s p=0.808 n=6
Emit Time 6.04s (± 0.52%) 6.00s (± 0.25%) -0.04s (- 0.61%) 5.98s 6.02s p=0.035 n=6
Total Time 21.35s (± 0.36%) 21.30s (± 0.10%) ~ 21.28s 21.33s p=0.173 n=6
TFS - node (v18.15.0, x64)
Memory used 302,779k (± 0.01%) 302,780k (± 0.01%) ~ 302,749k 302,810k p=1.000 n=6
Parse Time 2.40s (± 1.34%) 2.42s (± 0.76%) ~ 2.39s 2.44s p=0.169 n=6
Bind Time 1.19s (± 0.86%) 1.22s (± 0.52%) +0.03s (+ 2.23%) 1.21s 1.23s p=0.005 n=6
Check Time 7.51s (± 0.11%) 7.50s (± 0.33%) ~ 7.46s 7.53s p=0.163 n=6
Emit Time 4.26s (± 0.44%) 4.27s (± 0.75%) ~ 4.23s 4.32s p=0.686 n=6
Total Time 15.36s (± 0.13%) 15.40s (± 0.39%) ~ 15.34s 15.50s p=0.295 n=6
material-ui - node (v18.15.0, x64)
Memory used 510,144k (± 0.01%) 510,085k (± 0.01%) ~ 510,038k 510,201k p=0.093 n=6
Parse Time 3.18s (± 0.47%) 3.20s (± 0.55%) ~ 3.17s 3.22s p=0.217 n=6
Bind Time 1.18s (± 1.07%) 1.18s (± 0.44%) ~ 1.18s 1.19s p=0.931 n=6
Check Time 20.56s (± 0.25%) 20.55s (± 0.21%) ~ 20.50s 20.62s p=0.630 n=6
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) ~ 0.00s 0.00s p=1.000 n=6
Total Time 24.92s (± 0.26%) 24.93s (± 0.23%) ~ 24.87s 25.01s p=0.936 n=6
mui-docs - node (v18.15.0, x64)
Memory used 1,744,452k (± 0.00%) 1,744,451k (± 0.00%) ~ 1,744,399k 1,744,519k p=0.936 n=6
Parse Time 9.59s (± 0.60%) 9.63s (± 0.64%) ~ 9.53s 9.69s p=0.376 n=6
Bind Time 3.45s (± 0.91%) 3.46s (± 0.93%) ~ 3.41s 3.51s p=0.626 n=6
Check Time 81.72s (± 0.34%) 81.66s (± 0.52%) ~ 81.05s 82.28s p=0.936 n=6
Emit Time 0.19s (± 2.13%) 0.19s (± 0.00%) ~ 0.19s 0.19s p=0.405 n=6
Total Time 94.96s (± 0.27%) 94.94s (± 0.46%) ~ 94.30s 95.64s p=0.936 n=6
self-build-src - node (v18.15.0, x64)
Memory used 2,396,078k (± 0.03%) 2,395,862k (± 0.02%) ~ 2,395,030k 2,396,842k p=0.689 n=6
Parse Time 6.00s (± 0.91%) 6.00s (± 1.08%) ~ 5.93s 6.09s p=1.000 n=6
Bind Time 2.26s (± 1.23%) 2.29s (± 1.12%) ~ 2.27s 2.34s p=0.127 n=6
Check Time 39.89s (± 0.22%) 39.90s (± 0.31%) ~ 39.76s 40.06s p=0.936 n=6
Emit Time 3.14s (± 1.68%) 3.15s (± 1.19%) ~ 3.11s 3.22s p=0.936 n=6
Total Time 51.31s (± 0.28%) 51.38s (± 0.20%) ~ 51.23s 51.48s p=0.810 n=6
self-compiler - node (v18.15.0, x64)
Memory used 415,839k (± 0.01%) 415,882k (± 0.02%) ~ 415,803k 416,049k p=0.378 n=6
Parse Time 4.10s (± 0.33%) 4.12s (± 0.94%) ~ 4.06s 4.17s p=0.371 n=6
Bind Time 1.59s (± 0.62%) 1.58s (± 1.11%) ~ 1.55s 1.60s p=0.117 n=6
Check Time 22.54s (± 0.16%) 22.53s (± 0.35%) ~ 22.43s 22.61s p=0.872 n=6
Emit Time 1.72s (± 1.80%) 1.69s (± 1.59%) ~ 1.67s 1.74s p=0.107 n=6
Total Time 29.96s (± 0.11%) 29.92s (± 0.37%) ~ 29.80s 30.05s p=0.689 n=6
vscode - node (v18.15.0, x64)
Memory used 2,896,201k (± 0.00%) 2,896,256k (± 0.00%) +56k (+ 0.00%) 2,896,149k 2,896,322k p=0.045 n=6
Parse Time 12.94s (± 0.32%) 13.42s (± 8.52%) ~ 12.89s 15.76s p=0.255 n=6
Bind Time 4.14s (± 0.33%) 4.15s (± 0.10%) ~ 4.14s 4.15s p=0.078 n=6
Check Time 72.03s (± 0.29%) 71.93s (± 0.34%) ~ 71.65s 72.20s p=0.689 n=6
Emit Time 19.37s (± 0.47%) 19.42s (± 0.76%) ~ 19.29s 19.62s p=1.000 n=6
Total Time 108.48s (± 0.16%) 108.92s (± 1.18%) ~ 108.02s 111.48s p=0.873 n=6
webpack - node (v18.15.0, x64)
Memory used 408,874k (± 0.02%) 408,918k (± 0.04%) ~ 408,774k 409,181k p=0.936 n=6
Parse Time 3.89s (± 0.68%) 3.88s (± 0.55%) ~ 3.86s 3.92s p=0.468 n=6
Bind Time 1.69s (± 0.81%) 1.69s (± 1.06%) ~ 1.67s 1.72s p=0.935 n=6
Check Time 16.85s (± 0.18%) 16.88s (± 0.38%) ~ 16.80s 16.96s p=0.575 n=6
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) ~ 0.00s 0.00s p=1.000 n=6
Total Time 22.43s (± 0.10%) 22.45s (± 0.35%) ~ 22.35s 22.55s p=0.627 n=6
xstate - node (v18.15.0, x64)
Memory used 513,400k (± 0.02%) 513,364k (± 0.01%) ~ 513,276k 513,458k p=0.936 n=6
Parse Time 3.28s (± 0.23%) 3.28s (± 0.33%) ~ 3.27s 3.30s p=0.604 n=6
Bind Time 1.57s (± 0.00%) 1.57s (± 0.26%) ~ 1.57s 1.58s p=0.405 n=6
Check Time 2.90s (± 0.56%) 2.90s (± 0.49%) ~ 2.88s 2.92s p=0.745 n=6
Emit Time 0.07s (± 7.03%) 0.07s (± 5.69%) ~ 0.07s 0.08s p=0.595 n=6
Total Time 7.82s (± 0.15%) 7.82s (± 0.21%) ~ 7.80s 7.85s p=0.806 n=6
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • Angular - node (v18.15.0, x64)
  • Compiler-Unions - node (v18.15.0, x64)
  • Monaco - node (v18.15.0, x64)
  • TFS - node (v18.15.0, x64)
  • material-ui - node (v18.15.0, x64)
  • mui-docs - node (v18.15.0, x64)
  • self-build-src - node (v18.15.0, x64)
  • self-compiler - node (v18.15.0, x64)
  • vscode - node (v18.15.0, x64)
  • webpack - node (v18.15.0, x64)
  • xstate - node (v18.15.0, x64)
Benchmark Name Iterations
Current pr 6
Baseline baseline 6

Developer Information:

Download Benchmarks

@typescript-bot
Copy link
Collaborator

Hey @jakebailey, the results of running the DT tests are ready.

Everything looks the same!

You can check the log here.

@jakebailey
Copy link
Member Author

@typescript-bot cherry-pick this to release-5.4

@typescript-bot
Copy link
Collaborator

typescript-bot commented Mar 27, 2024

Starting jobs; this comment will be updated as builds start and complete.

Command Status Results
cherry-pick this to release-5.4 ✅ Started ✅ Results

@typescript-bot
Copy link
Collaborator

Hey, @jakebailey! I've created #57976 for you.

@typescript-bot
Copy link
Collaborator

@jakebailey Here are the results of running the user tests comparing main and refs/pull/57973/merge:

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;
Copy link
Member

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

Copy link
Member Author

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...

Copy link
Member Author

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)

@typescript-bot
Copy link
Collaborator

@jakebailey Here are the results of running the top 400 repos comparing main and refs/pull/57973/merge:

Everything looks good!

@andrewbranch
Copy link
Member

Fixes #57802

@typescript-bot typescript-bot added For Milestone Bug PRs that fix a bug with a specific milestone and removed For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Mar 28, 2024
@jakebailey jakebailey merged commit 35f4f03 into microsoft:main Mar 28, 2024
25 checks passed
@jakebailey jakebailey deleted the weird-case-thing branch March 28, 2024 17:33
DanielRosenwasser pushed a commit that referenced this pull request Mar 28, 2024
…e-5.4 (#57976)

Co-authored-by: Jake Bailey <5341706+jakebailey@users.noreply.github.com>
@DanielRosenwasser DanielRosenwasser added this to the TypeScript 5.4.32 milestone Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Milestone Bug PRs that fix a bug with a specific milestone
Projects
None yet
7 participants