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 🙏

© 2025 – Pkg Stats / Ryan Hefner

rollup-plugin-esnext-to-nodenext

v1.0.1

Published

A Rollup plugin that transforms ESM imports to Node.js-compatible NodeNext format by adding explicit file extensions

Readme

A Rollup plugin that transforms ESM imports to Node.js-compatible NodeNext format by adding explicit file extensions.

Features

  • Automatically adds .js extensions to relative imports
  • Supports TypeScript and JavaScript files
  • Works with Rollup's output directory structure
  • Verbose logging option for debugging

Installation

npm install rollup-plugin-esnext-to-nodenext --save-dev
yarn add rollup-plugin-esnext-to-nodenext -D
pnpm add rollup-plugin-esnext-to-nodenext -D

Usage

import esnextToNodeNext from 'rollup-plugin-esnext-to-nodenext';
import { defineConfig } from 'rollup';

export default defineConfig({
  input: 'src/index.ts',
  output: {
    file: 'dist/index.mjs',
    format: 'esm',
    sourcemap: true,
  },
  plugins: [
    esnextToNodeNext({
      verbose: true,  // enable logging (optional)
    }),
  ],
});

Options

| Option | Type | Default | Description | |-------------|-----------|-----------------|--------------------------------------| | verbose | boolean | false | Enable detailed logging | | outputDir | string | auto-detected | Explicit output directory (optional) |

How It Works

The plugin:

  1. Detects your Rollup output directory automatically
  2. Processes all emitted files after bundling
  3. Transforms import statements like from "./file" to from "./file.js"
  4. Preserves all other bundling functionality

Why Use This?

This plugin solves a specific compatibility problem when your project uses **TypeScript with bundler module resolution ** during development, but needs to output Node.js-compatible ESM with nodenext resolution (particularly important for type declarations).

Typical Use Case Example

Your tsconfig.json uses bundler-friendly settings:

{
  "compilerOptions": {
    "module": "esnext",
    "moduleResolution": "bundler",
    // ← Development mode (no .js extensions needed)
    "outDir": "dist"
  }
}

But your output needs to work with Node.js ESM (nodenext):

// package.json
{
  "type": "module",
  "exports": {
    ".": {
      "types": "./dist/index.d.ts",
      // ← Must be nodenext-compatible
      "import": "./dist/index.js"
    }
  }
}

The plugin bridges this gap by:

  1. Taking Rollup's bundled output (no extensions)
  2. Transforming imports to be Node.js ESM-compliant:
    - import { foo } from './utils';
    + import { foo } from './utils.js';
  3. Ensuring type declarations work in strict nodenext environments

When You Need This

  1. Publishing libraries with dual ESM/TypeScript support
  2. Building CLI tools that need strict Node.js ESM compliance
  3. Generating type declarations that must work in nodenext projects
  4. Migrating codebases from bundler-friendly to Node-native ESM

Without this transformation, you'll see Node.js errors like:

Error [ERR_MODULE_NOT_FOUND]: Cannot find module './utils' imported from...
Did you mean to import ./utils.js?

License

MIT © Vladislav Tupikin