Registry / devops / esbuild-plugin-alias-path

esbuild-plugin-alias-path

JSON →
library2.0.2jsnpmunverified

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.

npm install esbuild-plugin-alias-path
INSTALL
IMPORT
SIG · ESBUILD-PLUGIN-ALI
E
esbuild-plugin-alias-path
devopsjavascriptv2.0.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

aliasPath
import { aliasPath } from 'esbuild-plugin-alias-path'
const aliasPath = require('esbuild-plugin-alias-path')
ESM-only package; CommonJS require will fail. Use dynamic import if needed.
aliasPath (default)
import aliasPath from 'esbuild-plugin-alias-path'
import { aliasPath } from 'esbuild-plugin-alias-path'
Package exports both named and default export; both work, but default import is an alias for the named export.
AliasOption
import type { AliasOption } from 'esbuild-plugin-alias-path'
Type import available for TypeScript users to type the options object.

Shows how to configure aliasPath with both exact and glob alias patterns in an esbuild build script.

import { build } from 'esbuild'; import { aliasPath } from 'esbuild-plugin-alias-path'; (async () => { const result = await build({ entryPoints: ['./src/main.ts'], bundle: true, outfile: './dist/main.js', plugins: [ aliasPath({ alias: { '@utils': './src/utils/index.ts', '@components/*': './src/components', }, }), ], }); })();
Debug
Known issues
gotchaDo not use 'require()' for importing the package; it is ESM-only and will throw.
fix
Use dynamic import: const { aliasPath } = await import('esbuild-plugin-alias-path');
affects: >=2.0.0
gotchaWhen using glob pattern like '@alias/*', do not include '**' or trailing slashes in the alias key — only single asterisk is supported.
fix
Use '@alias/*' instead of '@alias/**/*'.
affects: >=1.0.0
gotchaThis plugin is not needed for tsconfig paths resolution; ESBuild already reads 'compilerOptions.paths' by default.
fix
Only use this plugin if you need runtime/dynamic alias replacement.
affects: >=0.14.0
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module /path/to/node_modules/esbuild-plugin-alias-path/dist/index.mjs not supported
Attempting to require an ESM-only package in a CommonJS context.
fix
Change to: const { aliasPath } = await import('esbuild-plugin-alias-path');
TypeError: aliasPath is not a function
Using named import incorrectly when the package only exports default.
fix
Import as: import aliasPath from 'esbuild-plugin-alias-path';
Upgrade
Version history
2.0.2latest on npm
Audit
Dependencies
esbuildrequiredpeer dependency required to run the plugin
Agent activity
6 hits · last 30 days
node
6
Resources
esbuild-plugin-alias-path — npm install esbuild-plugin-alias-path · libregistry