Skip to content

feat(exports): add extensions option for subpath export keys#899

Merged
sxzz merged 5 commits intorolldown:mainfrom
SinhSinhAn:feat/js-extension-exports
Apr 13, 2026
Merged

feat(exports): add extensions option for subpath export keys#899
sxzz merged 5 commits intorolldown:mainfrom
SinhSinhAn:feat/js-extension-exports

Conversation

@SinhSinhAn
Copy link
Copy Markdown
Contributor

Summary

Adds a new jsExtension boolean option to ExportsOptions that appends .js extensions to all subpath export keys (except the root "."), following the Node.js recommendation for subpath exports.

Before (jsExtension: false or unset):

{
  "exports": {
    ".": "./index.js",
    "./utils": "./utils.js"
  }
}

After (jsExtension: true):

{
  "exports": {
    ".": "./index.js",
    "./utils.js": "./utils.js"
  }
}

Changes

  • Added jsExtension?: boolean to ExportsOptions interface with JSDoc documentation
  • Implemented the extension logic in the export key generation loop (only affects non-root keys)
  • Works correctly with all existing features: dual formats, directory index entries, devExports, customExports

Tests

Added 5 new test cases covering:

  • Basic subpath export keys with .js extension
  • Directory index entries (e.g., ./foo.js from foo/index.js)
  • Dual format (ESM + CJS) with jsExtension
  • Root export is unaffected
  • Interaction with devExports and publishExports

All existing tests continue to pass (40 total).

Closes #898

Add a new `jsExtension` boolean option to `ExportsOptions` that appends
`.js` extensions to all subpath export keys (except the root `"."`).

This follows the Node.js recommendation for subpath exports:
https://nodejs.org/api/packages.html#extensions-in-subpaths

Closes rolldown#898
@netlify
Copy link
Copy Markdown

netlify bot commented Apr 10, 2026

Deploy Preview for tsdown-main ready!

Name Link
🔨 Latest commit 51f69aa
🔍 Latest deploy log https://app.netlify.com/projects/tsdown-main/deploys/69dce87bdf34ea00070b77c0
😎 Deploy Preview https://deploy-preview-899--tsdown-main.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 10, 2026

Open in StackBlitz

tsdown

pnpm add https://pkg.pr.new/tsdown@899 -D
npm i https://pkg.pr.new/tsdown@899 -D
yarn add https://pkg.pr.new/tsdown@899.tgz -D

create-tsdown

pnpm add https://pkg.pr.new/create-tsdown@899 -D
npm i https://pkg.pr.new/create-tsdown@899 -D
yarn add https://pkg.pr.new/create-tsdown@899.tgz -D

@tsdown/css

pnpm add https://pkg.pr.new/@tsdown/css@899 -D
npm i https://pkg.pr.new/@tsdown/css@899 -D
yarn add https://pkg.pr.new/@tsdown/css@899.tgz -D

@tsdown/exe

pnpm add https://pkg.pr.new/@tsdown/exe@899 -D
npm i https://pkg.pr.new/@tsdown/exe@899 -D
yarn add https://pkg.pr.new/@tsdown/exe@899.tgz -D

tsdown-migrate

pnpm add https://pkg.pr.new/tsdown-migrate@899 -D
npm i https://pkg.pr.new/tsdown-migrate@899 -D
yarn add https://pkg.pr.new/tsdown-migrate@899.tgz -D

commit: 51f69aa

Copy link
Copy Markdown
Member

@sxzz sxzz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please rename jsExtension to extensions

Comment thread src/features/pkg/exports.ts Outdated
Comment thread src/features/pkg/exports.ts Outdated
SinhSinhAn and others added 2 commits April 10, 2026 09:44
Rename the option from `jsExtension` to `extensions` and update the
JSDoc description to be more general, as requested by the maintainer.
@sxzz sxzz changed the title feat(exports): add jsExtension option for subpath export keys feat(exports): add extensions option for subpath export keys Apr 10, 2026
@sxzz sxzz merged commit 1bb7ab5 into rolldown:main Apr 13, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support adding .js extensions to all exports (except root)

2 participants