ts-import-resolver is a lightweight, zero-dependency utility for resolving TypeScript import paths to absolute file paths without invoking the TypeScript compiler. It supports path aliases, baseUrl, and other tsconfig resolution options. Current stable version is 0.1.23, released with minor updates. It is faster than using the TypeScript compiler API for pure path resolution, but lacks full compiler-level features like type checking or extension resolution in some edge cases. Designed for use in tools like bundlers, linters, or custom build scripts that need quick module resolution.
npm install ts-import-resolverNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to parse tsconfig.json and call resolveTsImportPath to resolve a path alias.
Use ES module imports or dynamic import() in CommonJS projects.
Always provide a valid tsconfig object for proper alias resolution.
Use path.resolve() to provide an absolute cwd.
If import path uses .js extension, ensure tsconfig includes 'allowJs' or handle extension manually.
Replace require('ts-import-resolver') with dynamic import('ts-import-resolver') or set 'type': 'module' in package.json.Ensure tsconfig is a valid parsed JSON object from tsconfig.json.
Verify tsconfig includes the correct 'paths' mapping and 'baseUrl' property.