{"id":34248312,"url":"https://github.com/mrrefactoring/rollup-plugin-esnext-to-nodenext","last_synced_at":"2026-05-26T21:04:02.102Z","repository":{"id":292408461,"uuid":"980219206","full_name":"MrRefactoring/rollup-plugin-esnext-to-nodenext","owner":"MrRefactoring","description":"A Rollup plugin that automatically transforms ESM imports into Node.js-compatible nodenext format by adding explicit file extensions (.js/.mjs). Perfect for libraries needing to work with TypeScript's \"moduleResolution\": \"nodenext\".","archived":false,"fork":false,"pushed_at":"2025-06-08T11:28:59.000Z","size":47,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-19T16:56:04.053Z","etag":null,"topics":["bundler","commonjs","esm","esmodules","import-extension","javascript","js-extension","module-resolution","module-system","node-modules","nodejs","nodenext","rollup","rollup-plugin","typescript","typescript-plugin"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MrRefactoring.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-05-08T19:06:32.000Z","updated_at":"2025-06-08T11:27:42.000Z","dependencies_parsed_at":null,"dependency_job_id":"6557cfc9-5af6-485d-9dd1-0e0d3c4f38a1","html_url":"https://github.com/MrRefactoring/rollup-plugin-esnext-to-nodenext","commit_stats":null,"previous_names":["mrrefactoring/rollup-plugin-esnext-to-nodenext"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/MrRefactoring/rollup-plugin-esnext-to-nodenext","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrRefactoring%2Frollup-plugin-esnext-to-nodenext","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrRefactoring%2Frollup-plugin-esnext-to-nodenext/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrRefactoring%2Frollup-plugin-esnext-to-nodenext/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrRefactoring%2Frollup-plugin-esnext-to-nodenext/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MrRefactoring","download_url":"https://codeload.github.com/MrRefactoring/rollup-plugin-esnext-to-nodenext/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrRefactoring%2Frollup-plugin-esnext-to-nodenext/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33538670,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"ssl_error","status_checked_at":"2026-05-26T15:22:15.568Z","response_time":63,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bundler","commonjs","esm","esmodules","import-extension","javascript","js-extension","module-resolution","module-system","node-modules","nodejs","nodenext","rollup","rollup-plugin","typescript","typescript-plugin"],"created_at":"2025-12-16T08:08:27.214Z","updated_at":"2026-05-26T21:04:02.064Z","avatar_url":"https://github.com/MrRefactoring.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003ch1\u003eRollup Plugin ESNext to NodeNext\u003c/h1\u003e\n  \u003ca href=\"https://www.npmjs.com/package/rollup-plugin-esnext-to-nodenext\" target=\"_blank\" rel=\"noopener noreferrer\"\u003e\u003cimg alt=\"NPM version\" src=\"https://img.shields.io/npm/v/rollup-plugin-esnext-to-nodenext.svg?maxAge=3600\u0026style=flat-square\" /\u003e\u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.com/package/rollup-plugin-esnext-to-nodenext\" target=\"_blank\" rel=\"noopener noreferrer\"\u003e\u003cimg alt=\"NPM downloads per month\" src=\"https://img.shields.io/npm/dm/rollup-plugin-esnext-to-nodenext.svg?maxAge=3600\u0026style=flat-square\" /\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/mrrefactoring/rollup-plugin-esnext-to-nodenext\" target=\"_blank\" rel=\"noopener noreferrer\"\u003e\u003cimg alt=\"build status\" src=\"https://img.shields.io/github/actions/workflow/status/mrrefactoring/rollup-plugin-esnext-to-nodenext/.github/workflows/build.yml?branch=master\u0026style=flat-square\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/mrrefactoring/rollup-plugin-esnext-to-nodenext/blob/master/LICENSE\" target=\"_blank\" rel=\"noopener noreferrer\"\u003e\u003cimg alt=\"license\" src=\"https://img.shields.io/github/license/mrrefactoring/rollup-plugin-esnext-to-nodenext?color=green\u0026style=flat-square\"/\u003e\u003c/a\u003e\n\n\u003cspan\u003eA Rollup plugin that transforms `ESM` imports to Node.js-compatible `NodeNext` format by adding explicit file extensions.\u003c/span\u003e\n\u003c/div\u003e\n\n## Features\n\n- Automatically adds `.js` extensions to relative imports\n- Supports TypeScript and JavaScript files\n- Works with Rollup's output directory structure\n- Verbose logging option for debugging\n\n## Installation\n\n```bash\nnpm install rollup-plugin-esnext-to-nodenext --save-dev\n```\n\n```bash\nyarn add rollup-plugin-esnext-to-nodenext -D\n```\n\n```bash\npnpm add rollup-plugin-esnext-to-nodenext -D\n```\n\n## Usage\n\n```javascript\nimport esnextToNodeNext from 'rollup-plugin-esnext-to-nodenext';\nimport { defineConfig } from 'rollup';\n\nexport default defineConfig({\n  input: 'src/index.ts',\n  output: {\n    file: 'dist/index.mjs',\n    format: 'esm',\n    sourcemap: true,\n  },\n  plugins: [\n    esnextToNodeNext({\n      verbose: true,  // enable logging (optional)\n    }),\n  ],\n});\n```\n\n## Options\n\n| Option      | Type      | Default         | Description                          |\n|-------------|-----------|-----------------|--------------------------------------|\n| `verbose`   | `boolean` | `false`         | Enable detailed logging              |\n| `outputDir` | `string`  | *auto-detected* | Explicit output directory (optional) |\n\n## How It Works\n\nThe plugin:\n\n1. Detects your Rollup output directory automatically\n2. Processes all emitted files after bundling\n3. Transforms import statements like `from \"./file\"` to `from \"./file.js\"`\n4. Preserves all other bundling functionality\n\n## Why Use This?\n\nThis plugin solves a specific compatibility problem when your project uses **TypeScript with `bundler` module resolution\n** during development, but needs to output **Node.js-compatible ESM with `nodenext` resolution** (particularly important\nfor type declarations).\n\n### Typical Use Case Example\n\nYour `tsconfig.json` uses `bundler`-friendly settings:\n\n```json\n{\n  \"compilerOptions\": {\n    \"module\": \"esnext\",\n    \"moduleResolution\": \"bundler\",\n    // ← Development mode (no .js extensions needed)\n    \"outDir\": \"dist\"\n  }\n}\n```\n\nBut your output needs to work with Node.js ESM (`nodenext`):\n\n```json\n// package.json\n{\n  \"type\": \"module\",\n  \"exports\": {\n    \".\": {\n      \"types\": \"./dist/index.d.ts\",\n      // ← Must be nodenext-compatible\n      \"import\": \"./dist/index.js\"\n    }\n  }\n}\n```\n\nThe plugin bridges this gap by:\n\n1. Taking Rollup's bundled output (no extensions)\n2. Transforming imports to be Node.js ESM-compliant:\n   ```diff\n   - import { foo } from './utils';\n   + import { foo } from './utils.js';\n   ```\n3. Ensuring type declarations work in strict `nodenext` environments\n\n### When You Need This\n\n1. **Publishing libraries** with dual ESM/TypeScript support\n2. **Building CLI tools** that need strict Node.js ESM compliance\n3. **Generating type declarations** that must work in `nodenext` projects\n4. **Migrating codebases** from bundler-friendly to Node-native ESM\n\nWithout this transformation, you'll see Node.js errors like:\n\n```\nError [ERR_MODULE_NOT_FOUND]: Cannot find module './utils' imported from...\nDid you mean to import ./utils.js?\n```\n\n## License\n\nMIT © Vladislav Tupikin\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrrefactoring%2Frollup-plugin-esnext-to-nodenext","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrrefactoring%2Frollup-plugin-esnext-to-nodenext","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrrefactoring%2Frollup-plugin-esnext-to-nodenext/lists"}