Skip to content

Refactor module resolution Extensions, fix lookup priorities #51471

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

Merged

Conversation

andrewbranch
Copy link
Member

@andrewbranch andrewbranch commented Nov 9, 2022

Fixes two forever-standing resolution bugs:

  1. The order of adding extensions vs. replacing extensions was backwards. Previously, for an import of "./foo.js", we would look up "./foo.js.ts" at a higher priority than "./foo.ts". This has been fixed in every module resolution mode.
  2. Each module resolution algorithm previously ran two passes: one looking for .ts or .d.ts files, and then another full pass looking for .js files if the former returned nothing. This results in some priorities that are obviously wrong under allowJs, and since allowJs doesn’t actually affect resolution results (only whether JS resolutions are errors after the fact), probably always wrong by extension. An example:
    // dir/index.ts
    export {}
    // dir.js
    export {}
    // main.ts
    import "./dir"
    Here, import "./dir" should resolve to dir.js, but previously resolved to dir/index.ts in every module resolution algorithm. This has been fixed only in node16 and nodenext in an attempt to limit breaking changes to classic and node. Those algorithms now try all valid extensions in priority order for each lookup location. The exception is that node_modules lookups still happen in two passes: one that searches the implementation package followed by the @types package looking for .ts/.d.ts files for each node_modules folder found up the directory spine, followed (if necessary) by another pass up the directory spine looking for .js files in implementation packages. Making this change required a pretty extensive refactor of how the algorithms deal with extensions, and I think the result is much easier to reason about.

For file system hits and watches, this should be a wash—depending on what files are where, a given resolution might have a few more lookups, a few less, or the same number but in a different order.

Like most bug fixes, this is technically a breaking change, but only very strange edge cases that are already misbehaving should be affected.

@typescript-bot typescript-bot added Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Nov 9, 2022
@andrewbranch andrewbranch force-pushed the bug/module-resolution-refactor branch from 579a4a7 to ba45a79 Compare November 9, 2022 23:22
Comment on lines -87 to +93
enum Extensions {
TypeScript, /** '.ts', '.tsx', or '.d.ts' */
JavaScript, /** '.js' or '.jsx' */
Json, /** '.json' */
TSConfig, /** '.json' with `tsconfig` used instead of `index` */
DtsOnly, /** Only '.d.ts' */
TsOnly, /** '.[cm]tsx?' but not .d.ts variants */
const enum Extensions {
TypeScript = 1 << 0, // '.ts', '.tsx', '.mts', '.cts'
JavaScript = 1 << 1, // '.js', '.jsx', '.mjs', '.cjs'
Declaration = 1 << 2, // '.d.ts', etc.
Json = 1 << 3, // '.json'

ImplementationFiles = TypeScript | JavaScript,
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extensions is bit flags now, and TSConfig is changed to be an isConfigLookup on ModuleResolutionState.

Comment on lines +1607 to -1594
// ./foo.js -> ./foo.ts
const resolvedByReplacingExtension = loadModuleFromFileNoImplicitExtensions(extensions, candidate, onlyRecordFailures, state);
if (resolvedByReplacingExtension) {
return resolvedByReplacingExtension;
}

// esm mode resolutions don't include automatic extension lookup (without additional flags, at least)
// ./foo -> ./foo.ts
if (!(state.features & NodeResolutionFeatures.EsmMode)) {
// First, try adding an extension. An import of "foo" could be matched by a file "foo.ts", or "foo.js" by "foo.js.ts"
const resolvedByAddingExtension = tryAddingExtensions(candidate, extensions, "", onlyRecordFailures, state);
if (resolvedByAddingExtension) {
return resolvedByAddingExtension;
}
}

return loadModuleFromFileNoImplicitExtensions(extensions, candidate, onlyRecordFailures, state);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the extension adding/replacing order swap

export default 0;

// @Filename: /a.ts
import b from "./b";
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test asserted the incorrect behavior. It’s replaced by the two new tests.

Copy link
Member

@jakebailey jakebailey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but I'll leave it for Wesley/Sheetal to look at tomorrow.

ImplementationFiles = TypeScript | JavaScript,
}

function formatExtensions(extensions: Extensions) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW you can get a pretty similar result with Debug.formatEnum. Post-modules that's something I want to yank out into a module for use outside of Debug.

Copy link
Member Author

@andrewbranch andrewbranch Nov 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn’t use it mostly because it was in Debug and this is production code... I know it would work without any issue but it felt wrong.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I wouldn't have mentioned it but this seemed like it was just in tracing which straddles the line a little.

@andrewbranch andrewbranch added the Breaking Change Would introduce errors in existing code label Nov 10, 2022
@andrewbranch
Copy link
Member Author

Those algorithms now try all valid extensions in priority order for each lookup location. The exception is that for a given node_modules folder searched when looking up a non-relative name, the implementation package is searched for .ts/.d.ts files only, then the @types package is searched, then the implementation package is searched again for .js files.

I think this might be a problem for monorepos where @types packages might be hoisted to the monorepo root level while implementation packages might get installed in the monorepo subpackages due to different version requirements.

@andrewbranch
Copy link
Member Author

@typescript-bot test top100

@typescript-bot
Copy link
Collaborator

typescript-bot commented Nov 10, 2022

Heya @andrewbranch, I've started to run the diff-based top-repos suite on this PR at ba45a79. You can monitor the build here.

Update: The results are in!

@andrewbranch
Copy link
Member Author

@typescript-bot perf test faster

@typescript-bot
Copy link
Collaborator

typescript-bot commented Nov 10, 2022

Heya @andrewbranch, I've started to run the abridged perf test suite on this PR at ba45a79. You can monitor the build here.

Update: The results are in!

@sheetalkamat
Copy link
Member

this has been fixed only in node16 and nodenext in an attempt to limit breaking changes to classic and node.

if this is breaking change anyway why not correct it for all algorithms.. Havent looked at changes yet and will do soon but does it simplify code even further or it makes it worse. Apart from being breaking change does it have any other reasoning not to break these two modes. Will it not do right thing.

@andrewbranch
Copy link
Member Author

I intend for classic and node to be essentially unmaintained after 5.0, so I don’t see a great reason to “fix” them if nobody has complained about this, but node16 and nodenext are new enough to bother fixing. It’s essentially a one-line change to opt node and classic into or out of the fix, so either way has little impact on code complexity.

@typescript-bot
Copy link
Collaborator

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

Here they are:

Comparison Report - main..51471

Metric main 51471 Delta Best Worst
Angular - node (v16.17.1, x64)
Memory used 340,592k (± 0.01%) 340,536k (± 0.02%) -56k (- 0.02%) 340,396k 340,687k
Parse Time 1.89s (± 0.39%) 1.89s (± 0.62%) +0.00s (+ 0.05%) 1.86s 1.92s
Bind Time 0.65s (± 0.85%) 0.65s (± 0.46%) -0.00s (- 0.61%) 0.64s 0.65s
Check Time 5.17s (± 0.59%) 5.16s (± 0.27%) -0.01s (- 0.27%) 5.12s 5.19s
Emit Time 5.17s (± 1.05%) 5.13s (± 0.81%) -0.04s (- 0.74%) 5.07s 5.23s
Total Time 12.88s (± 0.57%) 12.83s (± 0.38%) -0.05s (- 0.42%) 12.75s 12.98s
Compiler-Unions - node (v16.17.1, x64)
Memory used 187,266k (± 0.52%) 187,586k (± 0.62%) +320k (+ 0.17%) 186,486k 190,061k
Parse Time 0.79s (± 0.73%) 0.79s (± 0.78%) -0.00s (- 0.50%) 0.78s 0.80s
Bind Time 0.42s (± 1.06%) 0.42s (± 0.87%) -0.01s (- 1.42%) 0.41s 0.42s
Check Time 6.04s (± 0.82%) 5.99s (± 0.64%) -0.05s (- 0.81%) 5.92s 6.08s
Emit Time 1.89s (± 0.45%) 1.89s (± 0.97%) +0.00s (+ 0.11%) 1.85s 1.93s
Total Time 9.14s (± 0.57%) 9.09s (± 0.39%) -0.06s (- 0.60%) 9.02s 9.16s
Monaco - node (v16.17.1, x64)
Memory used 319,837k (± 0.01%) 319,806k (± 0.01%) -32k (- 0.01%) 319,756k 319,838k
Parse Time 1.43s (± 0.70%) 1.42s (± 1.18%) -0.01s (- 0.98%) 1.40s 1.46s
Bind Time 0.59s (± 1.01%) 0.59s (± 0.76%) -0.01s (- 1.18%) 0.58s 0.60s
Check Time 4.87s (± 0.42%) 4.88s (± 0.54%) +0.01s (+ 0.21%) 4.84s 4.96s
Emit Time 2.74s (± 0.84%) 2.71s (± 0.62%) -0.02s (- 0.88%) 2.68s 2.75s
Total Time 9.63s (± 0.48%) 9.59s (± 0.35%) -0.04s (- 0.37%) 9.54s 9.68s
TFS - node (v16.17.1, x64)
Memory used 282,296k (± 0.01%) 282,288k (± 0.01%) -8k (- 0.00%) 282,250k 282,318k
Parse Time 1.17s (± 0.99%) 1.17s (± 1.08%) -0.01s (- 0.77%) 1.15s 1.20s
Bind Time 0.64s (± 4.05%) 0.67s (± 2.03%) +0.04s (+ 5.66%) 0.63s 0.70s
Check Time 4.75s (± 0.41%) 4.74s (± 0.52%) -0.01s (- 0.13%) 4.68s 4.79s
Emit Time 2.72s (± 1.71%) 2.74s (± 2.30%) +0.02s (+ 0.59%) 2.65s 2.91s
Total Time 9.28s (± 0.81%) 9.31s (± 0.84%) +0.04s (+ 0.38%) 9.20s 9.51s
material-ui - node (v16.17.1, x64)
Memory used 435,301k (± 0.00%) 435,281k (± 0.00%) -20k (- 0.00%) 435,250k 435,311k
Parse Time 1.65s (± 0.50%) 1.64s (± 0.72%) -0.01s (- 0.43%) 1.61s 1.67s
Bind Time 0.50s (± 1.15%) 0.50s (± 0.66%) 0.00s ( 0.00%) 0.49s 0.51s
Check Time 11.82s (± 0.68%) 11.84s (± 0.82%) +0.02s (+ 0.15%) 11.64s 12.06s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 13.97s (± 0.62%) 13.98s (± 0.75%) +0.01s (+ 0.08%) 13.77s 14.24s
xstate - node (v16.17.1, x64)
Memory used 516,313k (± 0.01%) 516,081k (± 0.01%) -232k (- 0.04%) 515,973k 516,301k
Parse Time 2.33s (± 0.34%) 2.31s (± 0.62%) -0.02s (- 0.73%) 2.27s 2.33s
Bind Time 0.85s (± 1.18%) 0.82s (± 1.07%) 🟩-0.03s (- 3.19%) 0.79s 0.83s
Check Time 1.35s (± 0.76%) 1.35s (± 0.83%) -0.01s (- 0.37%) 1.33s 1.37s
Emit Time 0.06s (± 0.00%) 0.06s (± 0.00%) 0.00s ( 0.00%) 0.06s 0.06s
Total Time 4.58s (± 0.47%) 4.54s (± 0.42%) -0.05s (- 1.05%) 4.50s 4.58s
System
Machine Namets-ci-ubuntu
Platformlinux 5.4.0-131-generic
Architecturex64
Available Memory16 GB
Available Memory15 GB
CPUs4 × Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
Hosts
  • node (v16.17.1, x64)
Scenarios
  • Angular - node (v16.17.1, x64)
  • Compiler-Unions - node (v16.17.1, x64)
  • Monaco - node (v16.17.1, x64)
  • TFS - node (v16.17.1, x64)
  • material-ui - node (v16.17.1, x64)
  • xstate - node (v16.17.1, x64)
Benchmark Name Iterations
Current 51471 10
Baseline main 10

Developer Information:

Download Benchmark

@typescript-bot
Copy link
Collaborator

@andrewbranch Here are the results of running the top-repos suite comparing main and refs/pull/51471/merge:

Everything looks good!

@andrewbranch
Copy link
Member Author

I really expected a couple monorepos to fail there. Interesting.

@andrewbranch
Copy link
Member Author

Ah, the lack of failures could be due to low usage of node16 and nodenext. I’ll try applying the same fix to node and see how much stuff changes.

@andrewbranch
Copy link
Member Author

@typescript-bot test top100

@typescript-bot
Copy link
Collaborator

typescript-bot commented Nov 10, 2022

Heya @andrewbranch, I've started to run the diff-based top-repos suite on this PR at 4014f30. You can monitor the build here.

Update: The results are in!

extensions = [Extensions.TsOnly];
if (compilerOptions.allowJs) extensions.push(Extensions.JavaScript);
if (compilerOptions.resolveJsonModule) extensions.push(Extensions.Json);
extensions = Extensions.ImplementationFiles;
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 the part where we are saying always looks for js and report error if allowJs is not on correct.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually only used by Find Source Definition, which always passes allowJs. But I removed the condition to be consistent with other resolution modes which always resolve JS, yes.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And to be clear, normal resolution has resolved JS and reported errors afterwards for like 6 years; that’s not new here 😄

@andrewbranch
Copy link
Member Author

@typescript-bot perf test this

@typescript-bot
Copy link
Collaborator

typescript-bot commented Nov 10, 2022

Heya @andrewbranch, I've started to run the perf test suite on this PR at 4014f30. You can monitor the build here.

Update: The results are in!

@andrewbranch
Copy link
Member Author

@typescript-bot test top100 again, even though you haven’t finished the last one

@typescript-bot
Copy link
Collaborator

typescript-bot commented Nov 10, 2022

Heya @andrewbranch, I've started to run the diff-based top-repos suite on this PR at 53f0a60. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

@andrewbranch Here are the results of running the top-repos suite comparing main and refs/pull/51471/merge:

Something interesting changed - please have a look.

Details

chakra-ui/chakra-ui

52 of 95 projects failed to build with the old tsc and were ignored

packages/hooks/context/tsconfig.json

  • error TS7016: Could not find a declaration file for module 'react'. '/mnt/ts_downloads/chakra-ui/node_modules/.pnpm/react@18.2.0/node_modules/react/index.js' implicitly has an 'any' type.

packages/hooks/use-merge-refs/tsconfig.json

  • error TS7016: Could not find a declaration file for module 'react'. '/mnt/ts_downloads/chakra-ui/node_modules/.pnpm/react@18.2.0/node_modules/react/index.js' implicitly has an 'any' type.

packages/legacy/react-utils/tsconfig.json

packages/legacy/hooks/tsconfig.json

packages/hooks/use-safe-layout-effect/tsconfig.json

packages/components/color-mode/tsconfig.json

packages/components/descendant/tsconfig.json

packages/hooks/use-callback-ref/tsconfig.json

  • error TS7016: Could not find a declaration file for module 'react'. '/mnt/ts_downloads/chakra-ui/node_modules/.pnpm/react@18.2.0/node_modules/react/index.js' implicitly has an 'any' type.

packages/hooks/use-controllable-state/tsconfig.json

packages/components/transition/tsconfig.json

packages/hooks/use-disclosure/tsconfig.json

packages/components/focus-lock/tsconfig.json

packages/components/portal/tsconfig.json

packages/components/clickable/tsconfig.json

packages/components/popper/tsconfig.json

packages/hooks/use-event-listener/tsconfig.json

packages/hooks/use-animation-state/tsconfig.json

packages/hooks/use-update-effect/tsconfig.json

packages/hooks/use-focus-effect/tsconfig.json

packages/hooks/use-outside-click/tsconfig.json

packages/components/css-reset/tsconfig.json

  • error TS7016: Could not find a declaration file for module 'react/jsx-runtime'. '/mnt/ts_downloads/chakra-ui/node_modules/.pnpm/react@18.2.0/node_modules/react/jsx-runtime.js' implicitly has an 'any' type.

packages/components/env/tsconfig.json

  • error TS7016: Could not find a declaration file for module 'react'. '/mnt/ts_downloads/chakra-ui/node_modules/.pnpm/react@18.2.0/node_modules/react/index.js' implicitly has an 'any' type.
  • error TS7016: Could not find a declaration file for module 'react/jsx-runtime'. '/mnt/ts_downloads/chakra-ui/node_modules/.pnpm/react@18.2.0/node_modules/react/jsx-runtime.js' implicitly has an 'any' type.

packages/components/counter/tsconfig.json

packages/hooks/use-focus-on-pointer-down/tsconfig.json

packages/components/live-region/tsconfig.json

packages/hooks/use-interval/tsconfig.json

packages/hooks/use-previous/tsconfig.json

  • error TS7016: Could not find a declaration file for module 'react'. '/mnt/ts_downloads/chakra-ui/node_modules/.pnpm/react@18.2.0/node_modules/react/index.js' implicitly has an 'any' type.

packages/hooks/use-latest-ref/tsconfig.json

  • error TS7016: Could not find a declaration file for module 'react'. '/mnt/ts_downloads/chakra-ui/node_modules/.pnpm/react@18.2.0/node_modules/react/index.js' implicitly has an 'any' type.

packages/hooks/use-pan-event/tsconfig.json

packages/hooks/use-size/tsconfig.json

packages/hooks/use-timeout/tsconfig.json

tooling/cli/tsconfig.json

  • error TS7016: Could not find a declaration file for module 'prettier'. '/mnt/ts_downloads/chakra-ui/node_modules/.pnpm/prettier@2.7.1/node_modules/prettier/index.js' implicitly has an 'any' type.

jaredpalmer/formik

4 of 7 projects failed to build with the old tsc and were ignored

app/tsconfig.json

  • error TS7016: Could not find a declaration file for module 'react'. '/mnt/ts_downloads/formik/app/node_modules/react/index.js' implicitly has an 'any' type.
  • error TS2322: Type '{ children: string; jsx: true; }' is not assignable to type 'DetailedHTMLProps<StyleHTMLAttributes<HTMLStyleElement>, HTMLStyleElement>'.

microsoft/vscode

4 of 53 projects failed to build with the old tsc and were ignored

extensions/markdown-language-features/server/tsconfig.json

  • error TS7016: Could not find a declaration file for module 'vscode-markdown-languageservice/out/workspace'. '/mnt/ts_downloads/vscode/extensions/markdown-language-features/server/node_modules/vscode-markdown-languageservice/out/workspace.js' implicitly has an 'any' type.

test/smoke/tsconfig.json

n8n-io/n8n

6 of 9 projects failed to build with the old tsc and were ignored

packages/design-system/tsconfig.json

packages/core/tsconfig.json

type-challenges/type-challenges

1 of 3 projects failed to build with the old tsc and were ignored

scripts/tsconfig.json

vercel/hyper

2 of 3 projects failed to build with the old tsc and were ignored

tsconfig.json

@typescript-bot
Copy link
Collaborator

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

Here they are:

Compiler

Comparison Report - main..51471
Metric main 51471 Delta Best Worst
Angular - node (v18.10.0, x64)
Memory used 341,196k (± 0.02%) 341,472k (± 0.02%) +276k (+ 0.08%) 341,254k 341,556k
Parse Time 1.56s (± 0.78%) 1.58s (± 1.08%) +0.01s (+ 0.96%) 1.54s 1.62s
Bind Time 0.54s (± 0.89%) 0.53s (± 0.89%) -0.00s (- 0.74%) 0.52s 0.54s
Check Time 4.03s (± 0.77%) 4.04s (± 0.48%) +0.02s (+ 0.40%) 3.99s 4.09s
Emit Time 4.25s (± 0.66%) 4.26s (± 0.75%) +0.02s (+ 0.38%) 4.18s 4.32s
Total Time 10.37s (± 0.48%) 10.41s (± 0.35%) +0.04s (+ 0.42%) 10.32s 10.48s
Compiler-Unions - node (v18.10.0, x64)
Memory used 188,241k (± 1.07%) 188,777k (± 1.01%) +537k (+ 0.29%) 184,849k 190,625k
Parse Time 0.61s (± 1.31%) 0.62s (± 0.99%) +0.01s (+ 1.47%) 0.61s 0.63s
Bind Time 0.33s (± 1.12%) 0.33s (± 1.58%) +0.00s (+ 0.92%) 0.32s 0.34s
Check Time 4.97s (± 0.94%) 4.98s (± 0.54%) +0.01s (+ 0.12%) 4.92s 5.02s
Emit Time 1.52s (± 0.79%) 1.53s (± 0.91%) +0.01s (+ 0.52%) 1.50s 1.55s
Total Time 7.43s (± 0.76%) 7.46s (± 0.32%) +0.03s (+ 0.38%) 7.41s 7.52s
Monaco - node (v18.10.0, x64)
Memory used 320,558k (± 0.01%) 320,568k (± 0.04%) +10k (+ 0.00%) 320,413k 321,064k
Parse Time 1.16s (± 1.15%) 1.16s (± 1.18%) +0.00s (+ 0.43%) 1.14s 1.20s
Bind Time 0.49s (± 1.33%) 0.49s (± 2.03%) +0.00s (+ 0.41%) 0.47s 0.51s
Check Time 3.83s (± 0.63%) 3.87s (± 0.45%) +0.05s (+ 1.23%) 3.83s 3.91s
Emit Time 2.24s (± 1.09%) 2.25s (± 1.10%) +0.02s (+ 0.67%) 2.20s 2.32s
Total Time 7.72s (± 0.50%) 7.78s (± 0.61%) +0.07s (+ 0.89%) 7.66s 7.89s
TFS - node (v18.10.0, x64)
Memory used 283,309k (± 0.21%) 283,466k (± 0.23%) +157k (+ 0.06%) 282,691k 284,859k
Parse Time 0.96s (± 1.58%) 0.97s (± 0.98%) +0.00s (+ 0.31%) 0.95s 0.99s
Bind Time 0.44s (± 1.77%) 0.45s (± 7.27%) +0.01s (+ 2.51%) 0.43s 0.58s
Check Time 3.78s (± 0.60%) 3.80s (± 0.74%) +0.02s (+ 0.53%) 3.74s 3.85s
Emit Time 2.19s (± 0.53%) 2.19s (± 0.87%) -0.00s (- 0.05%) 2.15s 2.23s
Total Time 7.38s (± 0.59%) 7.41s (± 0.71%) +0.03s (+ 0.41%) 7.28s 7.56s
material-ui - node (v18.10.0, x64)
Memory used 435,989k (± 0.01%) 436,908k (± 0.02%) +919k (+ 0.21%) 436,758k 437,073k
Parse Time 1.33s (± 0.85%) 1.34s (± 0.84%) +0.01s (+ 0.75%) 1.32s 1.37s
Bind Time 0.49s (± 1.18%) 0.50s (± 3.44%) +0.00s (+ 0.41%) 0.45s 0.53s
Check Time 10.30s (± 0.70%) 10.30s (± 0.71%) +0.00s (+ 0.05%) 10.16s 10.45s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 12.12s (± 0.64%) 12.14s (± 0.75%) +0.02s (+ 0.12%) 11.94s 12.31s
xstate - node (v18.10.0, x64)
Memory used 518,631k (± 0.01%) 518,671k (± 0.01%) +40k (+ 0.01%) 518,585k 518,951k
Parse Time 1.92s (± 0.52%) 1.93s (± 0.57%) +0.01s (+ 0.26%) 1.91s 1.96s
Bind Time 0.78s (± 2.64%) 0.74s (± 3.22%) 🟩-0.03s (- 4.36%) 0.70s 0.78s
Check Time 1.03s (± 0.66%) 1.05s (± 0.83%) +0.01s (+ 1.26%) 1.02s 1.06s
Emit Time 0.05s (± 4.37%) 0.05s (± 4.37%) 0.00s ( 0.00%) 0.05s 0.06s
Total Time 3.79s (± 0.56%) 3.77s (± 0.61%) -0.02s (- 0.48%) 3.72s 3.82s
Angular - node (v16.17.1, x64)
Memory used 340,542k (± 0.01%) 340,800k (± 0.01%) +257k (+ 0.08%) 340,671k 340,858k
Parse Time 1.88s (± 0.56%) 1.90s (± 0.73%) +0.01s (+ 0.58%) 1.86s 1.93s
Bind Time 0.65s (± 0.72%) 0.65s (± 0.72%) -0.00s (- 0.00%) 0.64s 0.66s
Check Time 5.14s (± 0.73%) 5.15s (± 0.68%) +0.01s (+ 0.10%) 5.06s 5.21s
Emit Time 5.09s (± 0.70%) 5.09s (± 0.74%) +0.01s (+ 0.10%) 5.01s 5.17s
Total Time 12.76s (± 0.57%) 12.78s (± 0.59%) +0.02s (+ 0.16%) 12.56s 12.90s
Compiler-Unions - node (v16.17.1, x64)
Memory used 187,226k (± 0.53%) 187,242k (± 0.53%) +16k (+ 0.01%) 186,486k 189,943k
Parse Time 0.79s (± 0.87%) 0.80s (± 1.12%) +0.01s (+ 1.15%) 0.78s 0.82s
Bind Time 0.42s (± 1.14%) 0.42s (± 0.95%) +0.00s (+ 0.48%) 0.41s 0.43s
Check Time 6.01s (± 0.83%) 6.04s (± 0.32%) +0.03s (+ 0.50%) 5.99s 6.07s
Emit Time 1.88s (± 0.83%) 1.90s (± 0.73%) +0.02s (+ 0.85%) 1.87s 1.92s
Total Time 9.08s (± 0.58%) 9.15s (± 0.31%) +0.06s (+ 0.69%) 9.06s 9.19s
Monaco - node (v16.17.1, x64)
Memory used 319,827k (± 0.01%) 319,844k (± 0.01%) +17k (+ 0.01%) 319,782k 319,922k
Parse Time 1.42s (± 0.47%) 1.42s (± 0.52%) +0.01s (+ 0.42%) 1.41s 1.44s
Bind Time 0.59s (± 0.57%) 0.59s (± 0.75%) -0.00s (- 0.17%) 0.58s 0.60s
Check Time 4.87s (± 0.59%) 4.86s (± 0.49%) -0.01s (- 0.21%) 4.80s 4.90s
Emit Time 2.75s (± 0.90%) 2.71s (± 0.77%) -0.03s (- 1.24%) 2.67s 2.76s
Total Time 9.63s (± 0.48%) 9.59s (± 0.42%) -0.04s (- 0.44%) 9.49s 9.66s
TFS - node (v16.17.1, x64)
Memory used 282,298k (± 0.01%) 282,266k (± 0.02%) -31k (- 0.01%) 282,078k 282,328k
Parse Time 1.16s (± 0.80%) 1.17s (± 0.65%) +0.00s (+ 0.26%) 1.15s 1.18s
Bind Time 0.65s (± 4.04%) 0.67s (± 3.67%) +0.01s (+ 1.99%) 0.60s 0.74s
Check Time 4.73s (± 0.37%) 4.76s (± 0.17%) +0.02s (+ 0.49%) 4.74s 4.77s
Emit Time 2.76s (± 2.05%) 2.75s (± 1.73%) -0.01s (- 0.40%) 2.67s 2.85s
Total Time 9.31s (± 0.53%) 9.34s (± 0.49%) +0.03s (+ 0.30%) 9.23s 9.44s
material-ui - node (v16.17.1, x64)
Memory used 435,304k (± 0.00%) 436,169k (± 0.00%) +865k (+ 0.20%) 436,134k 436,221k
Parse Time 1.64s (± 0.44%) 1.65s (± 0.79%) +0.01s (+ 0.49%) 1.61s 1.67s
Bind Time 0.50s (± 0.80%) 0.50s (± 1.40%) +0.00s (+ 0.40%) 0.48s 0.51s
Check Time 11.78s (± 0.64%) 11.85s (± 0.83%) +0.07s (+ 0.58%) 11.65s 12.04s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 13.92s (± 0.54%) 13.99s (± 0.73%) +0.07s (+ 0.53%) 13.75s 14.18s
xstate - node (v16.17.1, x64)
Memory used 516,273k (± 0.01%) 516,264k (± 0.01%) -9k (- 0.00%) 516,178k 516,448k
Parse Time 2.31s (± 0.46%) 2.30s (± 0.39%) -0.01s (- 0.43%) 2.29s 2.32s
Bind Time 0.83s (± 1.09%) 0.83s (± 0.90%) +0.00s (+ 0.48%) 0.82s 0.86s
Check Time 1.34s (± 0.71%) 1.36s (± 0.41%) +0.01s (+ 0.97%) 1.34s 1.37s
Emit Time 0.06s (± 0.00%) 0.06s (± 0.00%) 0.00s ( 0.00%) 0.06s 0.06s
Total Time 4.55s (± 0.43%) 4.56s (± 0.27%) +0.00s (+ 0.04%) 4.53s 4.58s
Angular - node (v14.15.1, x64)
Memory used 334,022k (± 0.01%) 334,338k (± 0.01%) +316k (+ 0.09%) 334,297k 334,391k
Parse Time 2.04s (± 0.38%) 2.06s (± 0.70%) +0.02s (+ 0.93%) 2.04s 2.10s
Bind Time 0.70s (± 0.88%) 0.71s (± 0.52%) +0.01s (+ 1.00%) 0.70s 0.71s
Check Time 5.49s (± 0.62%) 5.53s (± 0.66%) +0.04s (+ 0.75%) 5.46s 5.61s
Emit Time 5.19s (± 0.51%) 5.26s (± 0.71%) +0.07s (+ 1.31%) 5.19s 5.34s
Total Time 13.42s (± 0.38%) 13.56s (± 0.54%) +0.13s (+ 0.98%) 13.40s 13.73s
Compiler-Unions - node (v14.15.1, x64)
Memory used 181,554k (± 0.01%) 181,592k (± 0.01%) +38k (+ 0.02%) 181,553k 181,662k
Parse Time 0.89s (± 0.93%) 0.89s (± 0.65%) -0.00s (- 0.22%) 0.88s 0.90s
Bind Time 0.46s (± 0.74%) 0.46s (± 1.02%) +0.00s (+ 0.66%) 0.45s 0.47s
Check Time 6.31s (± 0.49%) 6.35s (± 0.42%) +0.04s (+ 0.57%) 6.28s 6.43s
Emit Time 2.04s (± 0.94%) 2.05s (± 1.08%) +0.01s (+ 0.49%) 2.00s 2.09s
Total Time 9.70s (± 0.42%) 9.75s (± 0.45%) +0.04s (+ 0.46%) 9.64s 9.86s
Monaco - node (v14.15.1, x64)
Memory used 314,615k (± 0.01%) 314,590k (± 0.01%) -25k (- 0.01%) 314,515k 314,633k
Parse Time 1.57s (± 0.76%) 1.58s (± 0.55%) +0.01s (+ 0.38%) 1.56s 1.60s
Bind Time 0.64s (± 0.75%) 0.64s (± 1.05%) -0.00s (- 0.00%) 0.63s 0.66s
Check Time 5.17s (± 0.49%) 5.20s (± 0.29%) +0.03s (+ 0.52%) 5.17s 5.24s
Emit Time 2.88s (± 0.63%) 2.90s (± 0.82%) +0.02s (+ 0.80%) 2.84s 2.94s
Total Time 10.25s (± 0.36%) 10.31s (± 0.31%) +0.06s (+ 0.59%) 10.23s 10.38s
TFS - node (v14.15.1, x64)
Memory used 279,312k (± 0.01%) 279,300k (± 0.01%) -12k (- 0.00%) 279,261k 279,363k
Parse Time 1.34s (± 0.96%) 1.34s (± 0.82%) -0.01s (- 0.37%) 1.31s 1.36s
Bind Time 0.59s (± 0.68%) 0.59s (± 0.88%) +0.00s (+ 0.34%) 0.58s 0.61s
Check Time 5.10s (± 0.40%) 5.10s (± 0.38%) 0.00s ( 0.00%) 5.06s 5.14s
Emit Time 3.05s (± 1.77%) 3.06s (± 0.89%) +0.00s (+ 0.16%) 3.00s 3.12s
Total Time 10.09s (± 0.57%) 10.09s (± 0.38%) +0.00s (+ 0.03%) 10.00s 10.17s
material-ui - node (v14.15.1, x64)
Memory used 430,752k (± 0.01%) 431,598k (± 0.00%) +846k (+ 0.20%) 431,572k 431,651k
Parse Time 1.89s (± 1.12%) 1.89s (± 0.44%) -0.01s (- 0.26%) 1.87s 1.90s
Bind Time 0.53s (± 0.63%) 0.54s (± 0.96%) +0.01s (+ 2.08%) 0.53s 0.55s
Check Time 12.21s (± 0.66%) 12.25s (± 0.67%) +0.04s (+ 0.32%) 12.09s 12.40s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 14.64s (± 0.64%) 14.68s (± 0.60%) +0.04s (+ 0.29%) 14.50s 14.82s
xstate - node (v14.15.1, x64)
Memory used 504,455k (± 0.01%) 504,494k (± 0.01%) +39k (+ 0.01%) 504,431k 504,544k
Parse Time 2.64s (± 0.78%) 2.62s (± 0.83%) -0.02s (- 0.64%) 2.58s 2.68s
Bind Time 0.84s (± 1.25%) 0.84s (± 0.98%) +0.00s (+ 0.12%) 0.83s 0.87s
Check Time 1.48s (± 0.64%) 1.49s (± 0.47%) +0.01s (+ 0.88%) 1.47s 1.50s
Emit Time 0.07s (± 0.00%) 0.07s (± 0.00%) 0.00s ( 0.00%) 0.07s 0.07s
Total Time 5.03s (± 0.47%) 5.02s (± 0.49%) -0.01s (- 0.16%) 4.95s 5.07s
System
Machine Namets-ci-ubuntu
Platformlinux 5.4.0-131-generic
Architecturex64
Available Memory16 GB
Available Memory15 GB
CPUs4 × Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
Hosts
  • node (v18.10.0, x64)
  • node (v16.17.1, x64)
  • node (v14.15.1, x64)
Scenarios
  • Angular - node (v18.10.0, x64)
  • Angular - node (v16.17.1, x64)
  • Angular - node (v14.15.1, x64)
  • Compiler-Unions - node (v18.10.0, x64)
  • Compiler-Unions - node (v16.17.1, x64)
  • Compiler-Unions - node (v14.15.1, x64)
  • Monaco - node (v18.10.0, x64)
  • Monaco - node (v16.17.1, x64)
  • Monaco - node (v14.15.1, x64)
  • TFS - node (v18.10.0, x64)
  • TFS - node (v16.17.1, x64)
  • TFS - node (v14.15.1, x64)
  • material-ui - node (v18.10.0, x64)
  • material-ui - node (v16.17.1, x64)
  • material-ui - node (v14.15.1, x64)
  • xstate - node (v18.10.0, x64)
  • xstate - node (v16.17.1, x64)
  • xstate - node (v14.15.1, x64)
Benchmark Name Iterations
Current 51471 10
Baseline main 10

TSServer

Comparison Report - main..51471
Metric main 51471 Delta Best Worst
Compiler-UnionsTSServer - node (v18.10.0, x64)
Req 1 - updateOpen 1,047ms (± 0.74%) 1,062ms (± 0.75%) +15ms (+ 1.47%) 1,047ms 1,089ms
Req 2 - geterr 2,555ms (± 0.94%) 2,575ms (± 0.58%) +20ms (+ 0.77%) 2,527ms 2,602ms
Req 3 - references 167ms (± 0.93%) 167ms (± 0.60%) -0ms (- 0.12%) 165ms 169ms
Req 4 - navto 138ms (± 0.84%) 139ms (± 0.52%) +0ms (+ 0.29%) 138ms 141ms
Req 5 - completionInfo count 1,356 (± 0.00%) 1,356 (± 0.00%) 0 ( 0.00%) 1,356 1,356
Req 5 - completionInfo 61ms (± 2.33%) 61ms (± 2.03%) +0ms (+ 0.33%) 58ms 64ms
CompilerTSServer - node (v18.10.0, x64)
Req 1 - updateOpen 1,102ms (± 0.95%) 1,105ms (± 0.89%) +3ms (+ 0.25%) 1,082ms 1,136ms
Req 2 - geterr 1,573ms (± 0.65%) 1,562ms (± 1.10%) -10ms (- 0.65%) 1,522ms 1,605ms
Req 3 - references 170ms (± 1.06%) 172ms (± 3.01%) +2ms (+ 1.42%) 167ms 192ms
Req 4 - navto 152ms (± 0.90%) 155ms (± 7.03%) +3ms (+ 2.11%) 148ms 199ms
Req 5 - completionInfo count 1,518 (± 0.00%) 1,518 (± 0.00%) 0 ( 0.00%) 1,518 1,518
Req 5 - completionInfo 52ms (± 1.13%) 53ms (± 4.61%) +0ms (+ 0.76%) 49ms 61ms
xstateTSServer - node (v18.10.0, x64)
Req 1 - updateOpen 1,520ms (± 0.76%) 1,513ms (± 0.74%) -7ms (- 0.43%) 1,494ms 1,541ms
Req 2 - geterr 555ms (± 0.61%) 556ms (± 1.37%) +1ms (+ 0.14%) 545ms 579ms
Req 3 - references 58ms (± 1.81%) 59ms (± 2.79%) +1ms (+ 2.07%) 57ms 63ms
Req 4 - navto 195ms (± 0.80%) 196ms (± 1.23%) +1ms (+ 0.31%) 191ms 202ms
Req 5 - completionInfo count 3,151 (± 0.00%) 3,151 (± 0.00%) 0 ( 0.00%) 3,151 3,151
Req 5 - completionInfo 214ms (± 1.02%) 211ms (± 1.67%) -3ms (- 1.26%) 202ms 218ms
Compiler-UnionsTSServer - node (v16.17.1, x64)
Req 1 - updateOpen 1,303ms (± 0.57%) 1,305ms (± 0.38%) +2ms (+ 0.13%) 1,298ms 1,315ms
Req 2 - geterr 3,155ms (± 0.90%) 3,160ms (± 0.61%) +5ms (+ 0.15%) 3,101ms 3,190ms
Req 3 - references 193ms (± 0.79%) 192ms (± 0.94%) -1ms (- 0.42%) 188ms 196ms
Req 4 - navto 152ms (± 0.90%) 151ms (± 0.79%) -1ms (- 0.46%) 147ms 153ms
Req 5 - completionInfo count 1,356 (± 0.00%) 1,356 (± 0.00%) 0 ( 0.00%) 1,356 1,356
Req 5 - completionInfo 60ms (± 2.34%) 59ms (± 2.66%) -1ms (- 1.17%) 57ms 63ms
CompilerTSServer - node (v16.17.1, x64)
Req 1 - updateOpen 1,389ms (± 0.61%) 1,404ms (± 0.73%) +15ms (+ 1.04%) 1,388ms 1,431ms
Req 2 - geterr 2,059ms (± 0.42%) 2,076ms (± 0.31%) +18ms (+ 0.85%) 2,058ms 2,089ms
Req 3 - references 199ms (± 0.54%) 203ms (± 0.72%) +4ms (+ 1.81%) 201ms 208ms
Req 4 - navto 165ms (± 0.54%) 168ms (± 1.46%) +3ms (+ 1.76%) 163ms 173ms
Req 5 - completionInfo count 1,518 (± 0.00%) 1,518 (± 0.00%) 0 ( 0.00%) 1,518 1,518
Req 5 - completionInfo 59ms (± 1.54%) 58ms (± 2.36%) -1ms (- 0.85%) 56ms 61ms
xstateTSServer - node (v16.17.1, x64)
Req 1 - updateOpen 1,820ms (± 0.48%) 1,831ms (± 0.64%) +11ms (+ 0.60%) 1,803ms 1,854ms
Req 2 - geterr 711ms (± 0.48%) 713ms (± 0.66%) +2ms (+ 0.25%) 703ms 723ms
Req 3 - references 68ms (± 1.83%) 68ms (± 1.39%) -0ms (- 0.44%) 66ms 71ms
Req 4 - navto 197ms (± 0.95%) 200ms (± 0.93%) +2ms (+ 1.17%) 194ms 202ms
Req 5 - completionInfo count 3,151 (± 0.00%) 3,151 (± 0.00%) 0 ( 0.00%) 3,151 3,151
Req 5 - completionInfo 253ms (± 0.76%) 254ms (± 1.07%) +2ms (+ 0.59%) 249ms 260ms
Compiler-UnionsTSServer - node (v14.15.1, x64)
Req 1 - updateOpen 1,461ms (± 0.64%) 1,455ms (± 0.43%) -7ms (- 0.44%) 1,443ms 1,470ms
Req 2 - geterr 3,393ms (± 0.82%) 3,435ms (± 0.57%) +43ms (+ 1.26%) 3,404ms 3,493ms
Req 3 - references 207ms (± 0.88%) 207ms (± 0.65%) -0ms (- 0.19%) 205ms 211ms
Req 4 - navto 163ms (± 1.20%) 164ms (± 1.19%) +1ms (+ 0.43%) 161ms 169ms
Req 5 - completionInfo count 1,356 (± 0.00%) 1,356 (± 0.00%) 0 ( 0.00%) 1,356 1,356
Req 5 - completionInfo 66ms (± 6.59%) 68ms (± 7.08%) +2ms (+ 3.20%) 57ms 73ms
CompilerTSServer - node (v14.15.1, x64)
Req 1 - updateOpen 1,530ms (± 0.62%) 1,530ms (± 0.45%) -0ms (- 0.01%) 1,513ms 1,543ms
Req 2 - geterr 2,256ms (± 0.37%) 2,255ms (± 0.80%) -1ms (- 0.04%) 2,218ms 2,300ms
Req 3 - references 216ms (± 0.88%) 213ms (± 1.20%) -3ms (- 1.39%) 208ms 218ms
Req 4 - navto 175ms (± 0.76%) 174ms (± 0.83%) -0ms (- 0.23%) 172ms 178ms
Req 5 - completionInfo count 1,518 (± 0.00%) 1,518 (± 0.00%) 0 ( 0.00%) 1,518 1,518
Req 5 - completionInfo 62ms (± 8.84%) 61ms (± 8.23%) -1ms (- 1.61%) 55ms 71ms
xstateTSServer - node (v14.15.1, x64)
Req 1 - updateOpen 2,027ms (± 0.88%) 2,031ms (± 0.54%) +4ms (+ 0.19%) 1,996ms 2,050ms
Req 2 - geterr 746ms (± 0.67%) 749ms (± 0.49%) +2ms (+ 0.29%) 742ms 755ms
Req 3 - references 72ms (± 1.81%) 72ms (± 0.94%) +0ms (+ 0.42%) 71ms 74ms
Req 4 - navto 221ms (± 0.63%) 221ms (± 0.50%) +0ms (+ 0.18%) 220ms 224ms
Req 5 - completionInfo count 3,151 (± 0.00%) 3,151 (± 0.00%) 0 ( 0.00%) 3,151 3,151
Req 5 - completionInfo 272ms (± 1.41%) 272ms (± 1.90%) -0ms (- 0.15%) 265ms 286ms
System
Machine Namets-ci-ubuntu
Platformlinux 5.4.0-131-generic
Architecturex64
Available Memory16 GB
Available Memory15 GB
CPUs4 × Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
Hosts
  • node (v18.10.0, x64)
  • node (v16.17.1, x64)
  • node (v14.15.1, x64)
Scenarios
  • Compiler-UnionsTSServer - node (v18.10.0, x64)
  • Compiler-UnionsTSServer - node (v16.17.1, x64)
  • Compiler-UnionsTSServer - node (v14.15.1, x64)
  • CompilerTSServer - node (v18.10.0, x64)
  • CompilerTSServer - node (v16.17.1, x64)
  • CompilerTSServer - node (v14.15.1, x64)
  • xstateTSServer - node (v18.10.0, x64)
  • xstateTSServer - node (v16.17.1, x64)
  • xstateTSServer - node (v14.15.1, x64)
Benchmark Name Iterations
Current 51471 10
Baseline main 10

Startup

Comparison Report - main..51471
Metric main 51471 Delta Best Worst
tsc-startup - node (v16.17.1, x64)
Execution time 117.66ms (± 0.37%) 117.63ms (± 0.37%) -0.04ms (- 0.03%) 115.65ms 122.81ms
tsserver-startup - node (v16.17.1, x64)
Execution time 198.75ms (± 0.34%) 198.65ms (± 0.32%) -0.10ms (- 0.05%) 195.80ms 204.98ms
tsserverlibrary-startup - node (v16.17.1, x64)
Execution time 192.29ms (± 0.32%) 192.89ms (± 0.40%) +0.60ms (+ 0.31%) 189.23ms 202.55ms
typescript-startup - node (v16.17.1, x64)
Execution time 177.30ms (± 0.29%) 177.22ms (± 0.32%) -0.08ms (- 0.04%) 174.69ms 185.13ms
System
Machine Namets-ci-ubuntu
Platformlinux 5.4.0-131-generic
Architecturex64
Available Memory16 GB
Available Memory15 GB
CPUs4 × Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
Hosts
  • node (v16.17.1, x64)
Scenarios
  • tsc-startup - node (v16.17.1, x64)
  • tsserver-startup - node (v16.17.1, x64)
  • tsserverlibrary-startup - node (v16.17.1, x64)
  • typescript-startup - node (v16.17.1, x64)
Benchmark Name Iterations
Current 51471 10
Baseline main 10

Developer Information:

Download Benchmark

@andrewbranch
Copy link
Member Author

^ Yeah, that’s what I expected. I’ve reverted the node_modules searching algorithm back to two full passes, so I expect the second top100 run to come back clean. Updated the PR description:

The exception is that node_modules lookups still happen in two passes: one that searches the implementation package followed by the @types package looking for .ts/.d.ts files for each node_modules folder found up the directory spine, followed (if necessary) by another pass up the directory spine looking for .js files in implementation packages.

@typescript-bot
Copy link
Collaborator

@andrewbranch Here are the results of running the top-repos suite comparing main and refs/pull/51471/merge:

Everything looks good!

@andrewbranch andrewbranch merged commit 3fcd1b5 into microsoft:main Nov 15, 2022
@andrewbranch andrewbranch deleted the bug/module-resolution-refactor branch November 15, 2022 22:18
@andrewbranch
Copy link
Member Author

#51973 found an example of a break (a hypothetical break—the project uses --moduleResolution node, but would be broken trying to switch to bundler or nodenext that have the behavior changed in this PR) from this that is arguably correct and trivially fixable, but nonetheless tricky to diagnose. lensapp/lens has this in their tsconfig:

    "paths": {
      "*": [
        "node_modules/*",
        "types/*"
      ]
    }

If we evaluate the resolution of a package name, cli-progress for example, that is typed by @types/cli-progress in the old algorithm, where a full pass looking for only TS files is followed by a full pass looking for only JS files, the first pass looks in node_modules/cli-progress and finds the JS file, which is discarded because we only keep TS files. We don’t immediately look for a @types package, because having been directed to node_modules/cli-progress by paths, we don’t even realize we’re in node_modules—we’re just doing a plain old directory lookup. So paths resolution fails, and we move on to regular resolution, where we look in node_modules with the knowledge that we should try @types too, and that succeeds.

But in the new algorithm, paths resolution finds the JS file in node_modules/cli-progress and keeps it, because JS is a valid resolution. This is not what was intended, and it’s impossible to argue which behavior is correct based on runtime behavior, since paths does not model a specific runtime resolution behavior, but is more of a useful escape hatch. I’m arguing that our new behavior is more explainable and consistent. What you put in paths is our top priority, and node_modules has no special behavior there (it never has). If you point us to a directory via paths, your settings indicate that you can resolve to JS files, and we find a JS file there, that’s our resolution result. Moreover, the intent of this configuration can be more accurately captured by

"paths": {
  "*": ["types/*"]
}

There’s no need to put node_modules there. It will be part of the normal resolution algorithm if types/* fails. I’m comfortable with calling this an intentional change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team Breaking Change Would introduce errors in existing code For Uncommitted Bug PR for untriaged, rejected, closed or missing bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants