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

dts-paths

v2.2.1

Published

Replace alias paths with relative paths after typescript compilation.

Downloads

296

Readme

dts-paths

Replace alias paths with relative paths after typescript compilation.

NPM Version Download Status Languages Status Tree Shakeable Side Effect License

Usage

1. Install

npm i -D dts-paths typescript

2. Compile declaration files first

tsc --emitDeclarationOnly

3. Rewrite alias paths in emitted files

import { resolvePaths } from 'dts-paths';

await resolvePaths('./dist/types', {
  tsconfig: './tsconfig.json'
});

4. Optional configuration

import { resolvePaths } from 'dts-paths';

await resolvePaths('./dist/types', {
  // Supports tsconfig path or inline tsconfig object
  tsconfig: './tsconfig.json',
  // Number of concurrent tasks for scanning/rewrite/rename stages
  concurrency: 16,
  // Skip files that do not need to be processed
  exclude: path => path.includes('/internal/'),
  // Rewrite module specifiers before resolving
  mapSpecifier: ({ specifier, importer }) => {
    if (importer.endsWith('legacy.d.ts') && specifier === 'lodash-es') {
      return 'lodash';
    }

    return specifier;
  },
  // Custom extension mapping strategy for import specifiers and file renaming
  mapExtension: ({ extname, importer }) => {
    // Import specifier rewrite stage
    if (importer && extname === '.ts') {
      return '.js';
    }

    // File rename stage: *.ts -> *.js, *.cts -> *.cjs, *.mts -> *.mjs by default
    return extname;
  },
  // Called when a specifier cannot be resolved
  onResolveFailed: ({ specifier, importer }) => {
    console.warn(`[dts-paths] failed to resolve '${specifier}' from '${importer}'`);
  }
});

API

resolvePaths(root, options?)

Returns Promise<Set<string>>; the set contains files whose content was rewritten. If a rewritten declaration file is renamed by mapExtension, the returned path is the renamed file path. Scan-stage entry read errors are skipped and do not interrupt the process.

options.tsconfig

  • Type: string | TsConfig
  • Default: './tsconfig.json'
  • Supports either a tsconfig path or an inline object.
  • Supported inline TsConfig.compilerOptions fields:
    • paths
    • rootDir
    • preserveSymlinks
  • Use inline object is treated as a virtual tsconfig in cwd, following standard tsconfig rules.

options.concurrency

  • Type: number
  • Default: os.cpus().length
  • Controls concurrent tasks for directory scanning, specifier rewriting, and output-file renaming.

options.exclude

  • Type: (path: string) => boolean
  • Default: () => false
  • Filters declaration files during scanning.
  • path is the relative path (from root) built with POSIX separators (for example: foo/bar.d.ts).

options.mapSpecifier

  • Type: (context: MapSpecifierContext) => string
  • Default: identity mapping (specifier => specifier)
  • Called before resolving a module specifier.
  • context contains:
    • specifier: module specifier from the original import/export
    • importer: file path of the declaration file that imports the package

options.mapExtension

  • Type: (context: MapExtensionContext) => string
  • Default mapping:
    • .ts / .tsx / .jsx -> .js
    • .cts -> .cjs
    • .mts -> .mjs
  • Called in two places:
    • while rewriting import/export specifiers (context.importer is defined)
    • while renaming declaration output files (context.importer is undefined)
  • context contains:
    • path: resolved file path being processed
    • extname: original extension from the resolved target path
    • importer: declaration file path that triggered the resolution (optional during rename stage)

options.onResolveFailed

  • Type: (context: OnResolveFailedContext) => void
  • Default: throws an Error
  • Called when a module specifier cannot be resolved.
  • context contains:
    • specifier: unresolved module specifier from the original import/export
    • importer: file path of the declaration file that imports/exports the unresolved specifier