- Node v20
npm ci
npm run start # samples it works
npm run broken # samples it does not work
There are several ways to alias import paths. The purpose of this repository is to see how to express them, their expressiveness, and their interoperability.
Tool and conditions | Prefix replacement "@/" -> "./src/" |
Exact replacement "libfoo" -> "libbar" |
Capture(single |
RegExp | note |
---|---|---|---|---|---|
Node.js v21.6.0 ESM | ✅1 | ✅ | ❌ | - | |
Node.js v21.6.0 CJS | ✅1 | ✅ | ❌ | Extension guessing does not work | |
Bun v1.0.23 | ✅ | ✅ | ❌ | parse jsconfig, tsconfig 🔗 | |
Deno (application), Import Maps | ✅ | ✅ | ❌ | ❌ | - |
Deno (library), 🔗1, 🔗2 | ❌ | ❌ | ❌ | ❌ | - |
TypeScript v5.3.3, paths |
✅ | ✅ | ❌ | - | |
TypeScript v5.3.3, resolvePackageJsonImports |
✅1 | ✅ | ❌ | Node.js (imports field), auto-import is coming soon | |
Flow | ✅ | ✅ | ✅ | ✅ | - |
Webpack v5.89.0 + resolve.alias | ✅ | ✅ | ❌ | ❌ | - |
Webpack v5.89.0 + NormalModuleReplacementPlugin | ✅ | ✅ | ✅ | ✅ | - |
Webpack v5.89.0 + tsconfig-paths-webpack-plugin v4.1.0 | ✅ | ✅ | ❌ | parse tsconfig via tsconfig-paths | |
Rollup + @rollup/plugin-alias v5.1.0 | ✅ | ✅ | ✅ | ✅ | - |
Rollup + @rollup/plugin-typescript v11.1.6 | ✅ | ✅ | ❌ | tsconfig via typescript | |
esbuild v0.19.11 | ✅ | ✅ | ❌ | parse jsconfig, tsconfig 🔗 | |
esbuild + --alias | ✅ | ❌ | ❌ | ❌ | - |
SWC v1.3.102 for JavaScript, jsc.paths | ✅ | ✅ | ❌ | - | |
SWC v1.3.102 for TypeScript | ✅ | ✅ | ❌ | parse tsconfig 🔗 | |
Babel v7.23.7 + babel-plugin-module-resolver | ✅ | ✅ | ✅ | ✅ | - |
Next.js v14 | ✅ | ✅ | ❌ | parse tsconfig,jsconfig 🔗webpack, or 🔗turbopack | |
Vite + resolve.alias | ✅ | ✅ | ❌ | ❌ | - |
Vite + vite-tsconfig-paths | ✅ | ✅ | ❌ | parse jsconfig, tsconfig via tsconfck and resolve itself 🔗 | |
Remix, remix-run/remix#2412 | ✅ | ✅ | ❌ | parse tsconfig via esbuild? 🔗 | |
Nuxt, original vite plugin | ✅ | ✅ | ❌ | ❌ | |
Jest, moduleNameMapper | ✅ | ✅ | ✅ | ✅ | - |
Vitest | ✅ | ✅ | ❌ | ❌ | see Vite |
ESLint + eslint-import-resolver-alias | ✅ | ✅ | ❌ | ❌ | - |
ESLint + eslint-import-resolver-typescript | ✅ | ✅ | ❌ | parse jsconfig, tsconfig and resolve via get-tsconfig | |
ESLint + eslint-plugin-resolver-webpack | ✅ | ✅ | ❌ | webpack + resolve.alias | |
ESLint + eslint-import-resolver-babel-module | ✅ | ✅ | ❌ | babel-plugin-module-resolver | |
Biome Linter | ❌ | ❌ | ❌ | ❌ | - |
Oxlint | ❌ | ❌ | ❌ | ❌ | - |