npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

esbuild-plugin-tsconfig-paths

v1.0.2

Published

Esbuild plugin: converting tsconfig's paths to relative paths

Readme

esbuild-plugin-tsconfig-paths

English | 中文

在 esbuild 构建过程中,将 tsconfig.jsoncompilerOptions.paths 定义的 路径别名转换为相对导入路径。这样无需在运行时处理别名解析,产物更易于分发和使用。

示例

转换前

// src/app/index.ts
import util from "@/utils/util"

转换后

import util from "../utils/util"

安装

npm install esbuild-plugin-tsconfig-paths --dev

使用

import { tsconfigPathsPlugin } from "esbuild-plugin-tsconfig-paths";
import esbuild from "esbuild";

esbuild.build({
    // ...other config
    plugins: [
        // ... other plugins
        tsconfigPathsPlugin({
            // tsconfig 文件所在目录
            cwd: process.cwd(),
            // tsconfig 文件名
            tsconfig: "custom-tsconfig.json",
            // 需要被转换的文件匹配规则
            filter: /.*/,
        })
    ]
})

参数说明

| 参数 | 类型 | 默认值 | 说明 | |------------|-----------|------------------|------------------------------| | filter | RegExp | /.*/ | 匹配需要转换的文件路径。 | | tsconfig | string | tsconfig.json | 指定使用的 tsconfig 文件名。 | | cwd | string | process.cwd() | 查找 tsconfig 的工作目录。 |

注意事项

  • 需要在 tsconfig.json 中配置 compilerOptions.pathsbaseUrl 默认 ./
  • 在 esbuild 的 onLoad 阶段执行,将匹配到的导入语句改写为相对路径。
  • loader: 'ts' 输出,目标为 TypeScript 源码;建议不要让 filter 匹配 .tsx 文件。
  • 仅改写静态导入语句;动态导入或非路径规则的解析不会变更。

为什么需要

  • 产物不依赖运行时别名解析,部署更简单。
  • 源码保持别名的整洁写法,构建后面向消费者的是相对路径。

许可协议

MIT