Skip to content

traceResolution "according to earlier cached lookups" is noisyΒ #51722

@IanVS

Description

@IanVS

Suggestion

πŸ” Search Terms

according to earlier cached lookups
traceResolution

βœ… Viability Checklist

My suggestion meets these guidelines:

  • This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • This wouldn't change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.

⭐ Suggestion

I've been experimenting with different forms of module resolution in preparation for an upcoming talk, and the --traceResolution flag has been amazingly helpful. However, there are some cases, particularly when using "moduleResolution": "NodeNext" when, at the end of the trace, I get a ton of duplicate cache lookup logs.

For example:

======== Module name 'exports' was successfully resolved to '/Users/ianvs/code/experiments/ts-module-resolution-examples/src/NodeNext/node_modules/exports/index.d.ts'. ========
File '/Users/ianvs/code/experiments/ts-module-resolution-examples/node_modules/typescript/lib/package.json' does not exist.
Found 'package.json' at '/Users/ianvs/code/experiments/ts-module-resolution-examples/node_modules/typescript/package.json'.
'package.json' does not have a 'typesVersions' field.
File '/Users/ianvs/code/experiments/ts-module-resolution-examples/node_modules/typescript/lib/package.json' does not exist according to earlier cached lookups.
File '/Users/ianvs/code/experiments/ts-module-resolution-examples/node_modules/typescript/package.json' exists according to earlier cached lookups.
File '/Users/ianvs/code/experiments/ts-module-resolution-examples/node_modules/typescript/lib/package.json' does not exist according to earlier cached lookups.
File '/Users/ianvs/code/experiments/ts-module-resolution-examples/node_modules/typescript/package.json' exists according to earlier cached lookups.
File '/Users/ianvs/code/experiments/ts-module-resolution-examples/node_modules/typescript/lib/package.json' does not exist according to earlier cached lookups.
File '/Users/ianvs/code/experiments/ts-module-resolution-examples/node_modules/typescript/package.json' exists according to earlier cached lookups.
File '/Users/ianvs/code/experiments/ts-module-resolution-examples/node_modules/typescript/lib/package.json' does not exist according to earlier cached lookups.
File '/Users/ianvs/code/experiments/ts-module-resolution-examples/node_modules/typescript/package.json' exists according to earlier cached lookups.
File '/Users/ianvs/code/experiments/ts-module-resolution-examples/node_modules/typescript/lib/package.json' does not exist according to earlier cached lookups.
File '/Users/ianvs/code/experiments/ts-module-resolution-examples/node_modules/typescript/package.json' exists according to earlier cached lookups.
File '/Users/ianvs/code/experiments/ts-module-resolution-examples/node_modules/typescript/lib/package.json' does not exist according to earlier cached lookups.
File '/Users/ianvs/code/experiments/ts-module-resolution-examples/node_modules/typescript/package.json' exists according to earlier cached lookups.
File '/Users/ianvs/code/experiments/ts-module-resolution-examples/node_modules/typescript/lib/package.json' does not exist according to earlier cached lookups.
File '/Users/ianvs/code/experiments/ts-module-resolution-examples/node_modules/typescript/package.json' exists according to earlier cached lookups.
File '/Users/ianvs/code/experiments/ts-module-resolution-examples/node_modules/typescript/lib/package.json' does not exist according to earlier cached lookups.
File '/Users/ianvs/code/experiments/ts-module-resolution-examples/node_modules/typescript/package.json' exists according to earlier cached lookups.

...except I get about 5 times as many lines as shown here.

I don't know if this indicates a problem, or it's just a normal part of the resolution process, but maybe those logs could at least be cleaned up and they could be combined with a (x24) at the end, or something?

πŸ“ƒ Motivating Example

I plan to use --traceResoltuion in a meetup talk, and the extra output is a bit distracting.

I've pushed up a reproduction at https://github.com/IanVS/ts-module-resolution-examples/tree/d857f0e2fa44f3b5c14d30049fe95ee47074a75f

Run npm install then npm run repro to see the behavior I'm discussing here.

πŸ’» Use Cases

Improving the output of --traceResolution will make it more friendly for developers to use.

On the other hand, if this does indicate a possible problem, then adding visibility by having this huge block of repeating text might be a good thing, so I could see wanting to keep it if that's the case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DeclinedThe issue was declined as something which matches the TypeScript visionSuggestionAn idea for TypeScript

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions