Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

[@rollup/plugin-commonjs] Bring back named exports in commonjs entry points

Open
#1,885 11 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
42/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Quiet
Tech stack
javascript
Domain
build-system

Research direction

Start by reviewing @rollup/plugin-commonjs handling of CommonJS entry points and the discussion around the export behavior. Use the linked updateLibs.js and undici context to understand the reported reproduction and compare generated default and named exports. Done means CommonJS entry points provide the expected named exports without breaking the documented interoperability behavior.

Written by the indexing model from the issue text.

Description

  • Rollup Plugin Name: commonjs
  • Rollup Plugin Version: 27.0.0 - 28.0.6
Expected Behavior / Situation

When using commonjs file as an entry point I want to be able to use named exports

Actual Behavior / Situation

Only default export is generated

Modification Proposal

Bring back the behavior with named exports for entry point.

Motivation

We use rollup to vendor our dependencies:
https://github.com/tutao/tutanota/blob/2218892625ed3b717ac987e531c4553989b9bf59/buildSrc/updateLibs.js

It makes much easier to review the changes and ensures that the build is less reliant on npm registry.

Unfortunately we run into an issue with undici where their changes to the entrypoint caused rollup to not generate named exports. We worked around it by normalizing the exports:
https://github.com/nodejs/undici/pull/4324
but now when updating the plugin we run into the same issue.

It would make sense that we can use the library like the docs and types suggest and not import it differently just because it is vendored. When using node's native ES module interop the mapping would be different.

I would love if libraries provided native ESM entry point but right now it is not the case for some libraries that we use so we would kindly ask to reconsider the change. The alternative for us would be to maintain our own entry point/wrapper with named ESM exports which is not very appealing.

Dominant language
JavaScript
Stars
3.8k
Forks
635
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rollup/plugins

All issues in rollup/plugins

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.