{"id":21232,"library":"esbuild-plugin-alias-path","title":"esbuild-plugin-alias-path","description":"ESBuild plugin for resolving and replacing alias paths (e.g., '@foo' → './src/alias/foo.ts') with or without glob patterns. v2.0.2 supports ESBuild >= 0.14.0, ships TypeScript definitions, and is updated with fix releases on npm. Unlike tsconfig paths (which ESBuild reads automatically), this plugin enables dynamic alias replacement at build time.","status":"active","version":"2.0.2","language":"javascript","source_language":"en","source_url":"https://github.com/LinbuduLab/esbuild-plugins","tags":["javascript","ESBuild","plugin","typescript"],"install":[{"cmd":"npm install esbuild-plugin-alias-path","lang":"bash","label":"npm"},{"cmd":"yarn add esbuild-plugin-alias-path","lang":"bash","label":"yarn"},{"cmd":"pnpm add esbuild-plugin-alias-path","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency required to run the plugin","package":"esbuild","optional":false}],"imports":[{"note":"ESM-only package; CommonJS require will fail. Use dynamic import if needed.","wrong":"const aliasPath = require('esbuild-plugin-alias-path')","symbol":"aliasPath","correct":"import { aliasPath } from 'esbuild-plugin-alias-path'"},{"note":"Package exports both named and default export; both work, but default import is an alias for the named export.","wrong":"import { aliasPath } from 'esbuild-plugin-alias-path'","symbol":"aliasPath (default)","correct":"import aliasPath from 'esbuild-plugin-alias-path'"},{"note":"Type import available for TypeScript users to type the options object.","wrong":null,"symbol":"AliasOption","correct":"import type { AliasOption } from 'esbuild-plugin-alias-path'"}],"quickstart":{"code":"import { build } from 'esbuild';\nimport { aliasPath } from 'esbuild-plugin-alias-path';\n\n(async () => {\n  const result = await build({\n    entryPoints: ['./src/main.ts'],\n    bundle: true,\n    outfile: './dist/main.js',\n    plugins: [\n      aliasPath({\n        alias: {\n          '@utils': './src/utils/index.ts',\n          '@components/*': './src/components',\n        },\n      }),\n    ],\n  });\n})();","lang":"typescript","description":"Shows how to configure aliasPath with both exact and glob alias patterns in an esbuild build script."},"warnings":[{"fix":"Use dynamic import: const { aliasPath } = await import('esbuild-plugin-alias-path');","message":"Do not use 'require()' for importing the package; it is ESM-only and will throw.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Use '@alias/*' instead of '@alias/**/*'.","message":"When using glob pattern like '@alias/*', do not include '**' or trailing slashes in the alias key — only single asterisk is supported.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Only use this plugin if you need runtime/dynamic alias replacement.","message":"This plugin is not needed for tsconfig paths resolution; ESBuild already reads 'compilerOptions.paths' by default.","severity":"gotcha","affected_versions":">=0.14.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Change to: const { aliasPath } = await import('esbuild-plugin-alias-path');","cause":"Attempting to require an ESM-only package in a CommonJS context.","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module /path/to/node_modules/esbuild-plugin-alias-path/dist/index.mjs not supported"},{"fix":"Import as: import aliasPath from 'esbuild-plugin-alias-path';","cause":"Using named import incorrectly when the package only exports default.","error":"TypeError: aliasPath is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}