Back to Tsx

Module resolution

notes/enhanced-resolve/module-resolution.md

4.23.91.7 KB
Original Source

Module resolution

enhanced-resolve defaults to .js, .json, and .node extensions without TypeScript substitution (options).

extensionAlias is ordered caller policy (configuration); the test order '.js': ['.ts', '.js'] prefers TypeScript and falls back to JavaScript (tests).

Configured aliases run before normal exact-file resolution, so TypeScript-first alias order replaces an existing .js file (pipeline). Alias/extension orders are resolver-global; resolve requests carry caller-supplied context, and custom plugins can inspect pipeline hooks (context, hooks).

Package imports targets receive extension aliasing; exports targets remain exact unless extensionAliasForExports opts in (imports pipeline, exports option).