Suggestion
π Search Terms
exports, resolution, nodeResolution, traceResolution, esm, cjs
β
Viability Checklist
My suggestion meets these guidelines:
β Suggestion
--traceResolution should include the package.json#exports resolution in the output.
π Motivation
This algorithm is quite complex and involved and thus any insights that users can get from TS as to what is matched and why would be very much appreciated.
Compare the output for the classic moduleResolution:
classic: quite detailed mentions of all steps
======== Resolving module 'tiny-invariant' from '/test__/tiny-invariant-test/test.ts'. ========
Module resolution kind is not specified, using 'NodeJs'.
Loading module 'tiny-invariant' from 'node_modules' folder, target file type 'TypeScript'.
Directory '/test__/tiny-invariant-test/node_modules' does not exist, skipping all lookups in it.
Found 'package.json' at '/test__/node_modules/tiny-invariant/package.json'.
'package.json' does not have a 'typesVersions' field.
File '/test__/node_modules/tiny-invariant.ts' does not exist.
File '/test__/node_modules/tiny-invariant.tsx' does not exist.
File '/test__/node_modules/tiny-invariant.d.ts' does not exist.
'package.json' does not have a 'typings' field.
'package.json' has 'types' field 'dist/tiny-invariant.d.ts' that references '/test__/node_modules/tiny-invariant/dist/tiny-invariant.d.ts'.
File '/test__/node_modules/tiny-invariant/dist/tiny-invariant.d.ts' exist - use it as a name resolution result.
Resolving real path for '/test__/node_modules/tiny-invariant/dist/tiny-invariant.d.ts', result '/test__/node_modules/tiny-invariant/dist/tiny-invariant.d.ts'.
======== Module name 'tiny-invariant' was successfully resolved to '/test__/node_modules/tiny-invariant/dist/tiny-invariant.d.ts' with Package ID 'tiny-invariant/dist/tiny-invariant.d.ts@1.3.0'. ========
with the output for the moduleResolution: node16 and the existing export field in a package:
node16: seemingly random "jump" from lack of `typesVersions` to the resolved `.d.ts`
======== Resolving module 'tiny-invariant' from '/test__/tiny-invariant-test/test.ts'. ========
Explicitly specified module resolution kind: 'Node16'.
File '/test__/tiny-invariant-test/package.json' does not exist according to earlier cached lookups.
File '/test__/package.json' exists according to earlier cached lookups.
Loading module 'tiny-invariant' from 'node_modules' folder, target file type 'TypeScript'.
Directory '/test__/tiny-invariant-test/node_modules' does not exist, skipping all lookups in it.
Found 'package.json' at '/test__/node_modules/tiny-invariant/package.json'.
'package.json' does not have a 'typesVersions' field.
File '/test__/node_modules/tiny-invariant/dist/tiny-invariant.d.ts' exist - use it as a name resolution result.
Resolving real path for '/test__/node_modules/tiny-invariant/dist/tiny-invariant.d.ts', result '/test__/node_modules/tiny-invariant/dist/tiny-invariant.d.ts'.
======== Module name 'tiny-invariant' was successfully resolved to '/test__/node_modules/tiny-invariant/dist/tiny-invariant.d.ts' with Package ID 'tiny-invariant/dist/tiny-invariant.d.ts@1.3.0'. ========
cc Andrew Branch (@andrewbranch)
Suggestion
π Search Terms
exports, resolution, nodeResolution, traceResolution, esm, cjs
β Viability Checklist
My suggestion meets these guidelines:
β Suggestion
--traceResolutionshould include thepackage.json#exportsresolution in the output.π Motivation
This algorithm is quite complex and involved and thus any insights that users can get from TS as to what is matched and why would be very much appreciated.
Compare the output for the classic
moduleResolution:classic: quite detailed mentions of all steps
with the output for the
moduleResolution: node16and the existingexportfield in a package:node16: seemingly random "jump" from lack of `typesVersions` to the resolved `.d.ts`
cc Andrew Branch (@andrewbranch)