Back to Tsx

Module resolution

notes/bun/module-resolution.md

4.23.91.1 KB
Original Source

Module resolution

Bun 1.3.14 checks the exact path, appends the request-kind extension order, then applies .js/.jsx/.mjs TypeScript substitution (file loader). Local ESM imports use .tsx, .jsx, .mts, .ts, .mjs, .js, .cts, .cjs, .json; local CommonJS requests use .tsx, .ts, .jsx, .cts, .cjs, .js, .mjs, .mts, .json (orders).

Dependencies use separate JavaScript-first ESM/CommonJS orders (dependency orders). An existing explicit JSON asset wins, but a missing asset.json receives appended candidates such as asset.json.ts before asset.json.js; .json is not substituted to asset.ts (file loader).