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

@torthu/fix-imports

v0.0.4

Published

Tiny utility for rewriting imports and exports in a dist folder.

Readme

@torthu/fix-imports

Vite does not rely on Node module resolution. Therefore, it expects imports to include file extensions. It also does not support directory imports.

This util 1) rewrites imports to include .js file extension and 2) replaces directory imports with imports from the index.js file.

You only need this package if you:

  1. are using a naive tsc build
  2. are not merging/minifying output
  3. are using barrel files / directory imports / extensionless imports
  4. are consuming whatever you are building in a project without Node module resolution

Installation and usage

npm i -D @torthu/fix-imports

pnpm add -D @torthu/fix-imports

In your package.json:

"scripts": {
    "fix-imports": "fix-imports --dir ./dist"
}

In my use case I have set up a simple build command using rimraf to clean the dist-folder, tsc to compile the code and fix-imports to rewrite the imports:

"scripts": {
    "build": "rimraf dist && tsc && fix-imports --dir ./dist"
}

| Argument | Description | | ------------ | --------------------------------------------------------------------------- | | --dir | Path to dist folder. Defaults to "dist" if no --dir or --tsconfig is passed | | --tsconfig | Path to tsconfig.json (compilerOptions.outDir will be used as dir) | | --verbose | Print verbose output | | --dry-run | Dry run: log files that would be impacted |

Note: if passing both --dir and --tsconfig, --dir will take precedence.

Note: if neither --dir or --tsconfig is passed, dist will be used as default.


Example library build setup

tsconfig.json

{
  "$schema": "https://json.schemastore.org/tsconfig",
  "compilerOptions": {
    "target": "ES2022",
    "module": "ESNext",
    "lib": ["DOM", "ESNext"],
    "jsx": "react-jsx",
    "strict": true,
    "moduleResolution": "node",
    "esModuleInterop": true,
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true,
    "resolveJsonModule": true,
    "isolatedModules": true,
    "baseUrl": ".",
    "noEmit": false,
    "declaration": true,
    "declarationMap": false,
    "outDir": "dist",
    "rootDir": "src",
    "emitDeclarationOnly": false,
    "sourceMap": false,
  },
  "include": ["src"]
}

package.json

{
    "name": "my-package",
    "version": "1.0.0",
    "files": [
        "./dist"
    ],
    "scripts": {
        "build": "tsc && fix-imports dist"
    },
    "devDependencies": {
        "@torthu/fix-imports": "^1.0.0",
        "typescript": "^5.0.4"
    },
}

file structure

  src/
    index.ts
    utils/
      index.ts
      utils.ts
  dist/
    index.js
    utils/
      index.js
      utils.js
  package.json
  tsconfig.json