Description
Bug Report
In the NodeJS resolve spec is mentioned that the main field and all other alias fields like browser modules
get shadowed by exports so there is a fallback if a field is missing it looks up the original fields Typescript 4.6 does not do so and so I am forced to split dependencies for consumption into the once that support package.json exports: field including all sub dependencies.
see: #46452 (comment)
for me that is not a big issue as i tend to create dev bundels any way but most people will not have a good time without that fallback
see: #46452
🔎 Search Terms
node12 nodenext moduleResolve
🕗 Version & Regression Information
4.5 + new resolveModes
🙁 Actual behavior
I Started Consuming libs with node12 and nodenext resolve mode and got a lot of errors then I looked into the packages to identify what they did and found out there is no fallback in typescript which helped me to identify packages fast that got no exports field or export fields with subPath patterns as they are also not supported.
🙂 Expected behavior
always remember the rule that is most specific is the one that gets in effect! Like with css when a selector is more specific it gets used.
lookup patterns nodenext :
- package.json => exports: types:,
- package.json => types:,
- package.json => exports: node?.import|import|default,
- package.json => main:
same for node12
Short
moduleResolve modes node12 and nodenext should be backward compatible and should inhire resolve mode node which also includes Classic
Related Partial (Classic)
- The ESM resolver does not respect package
main
s for packages imported via relative imports nodejs/node#41940 - Missing node12 + nodenext => node (which includes classic which is resolved maybe) - TypeScript module "NodeNext" does not resolve
index.d.ts
from CJS modules #47848 - Implements node12 + nodenext => Classic (as far as i understood) - ESM mode nonrelative imports should assume index.js entrypoints even … #47854 - Implements node12 + nodenext => Classic (as far as i understood)