A plugin for esbuild that resolves TypeScript path aliases defined in tsconfig.json to absolute paths during bundling. Current stable version is 1.1.3, released as needed. It wraps esbuild's build API and replaces path aliases (e.g., '@/*') with resolved absolute paths before esbuild processes the code. Key differentiator: it is a lightweight, zero-config plugin specifically designed for esbuild, unlike tsconfig-paths-webpack-plugin for Webpack or general-purpose alias resolvers. However, it is critical to note that this plugin performs a simple string replacement and may not handle all edge cases, such as path aliases in complex configurations or dynamic imports.
npm install esbuild-ts-pathsVerified import paths — ran on the pinned version, not inferred.
Minimal setup showing how to use the plugin with esbuild to resolve TypeScript path aliases.
Manually resolve complex aliases or use an alternative resolver like tsx.
Provide a custom tsconfig path via the plugin options: esbuildTSPPaths({ tsconfig: 'path/to/tsconfig.json' }).Use dynamic import or switch to ESM: import esbuildTSPaths from 'esbuild-ts-paths'.
Remove the explicit tsconfig option if it points to the default tsconfig.json.
Change to dynamic import: const esbuildTSPaths = (await import('esbuild-ts-paths')).default; or use ESM.Import as default: import esbuildTSPaths from 'esbuild-ts-paths'.
Check tsconfig.json for correct paths mapping and ensure plugin is attached to esbuild build.