Skip to content

fix(esm-shim): match typings to actual exports#2013

Open
greymoth-jp wants to merge 1 commit into
rollup:masterfrom
greymoth-jp:fix-esm-shim-typings
Open

fix(esm-shim): match typings to actual exports#2013
greymoth-jp wants to merge 1 commit into
rollup:masterfrom
greymoth-jp:fix-esm-shim-typings

Conversation

@greymoth-jp

Copy link
Copy Markdown

The hand-written types/index.d.ts for @rollup/plugin-esm-shim does not match what the package actually exports.

src/index.ts exposes the plugin as both a named and a default export, and re-exports the Output type:

export * from './types';   // Output
export default esmShim;
export { esmShim };

The typings only declare the default, under the stale name commonjsShim, and omit the named esmShim export. As a result import { esmShim } from '@rollup/plugin-esm-shim' does not type-check even though it works at runtime.

This is the same typings/exports drift that #1985 fixed for @rollup/plugin-swc. Every other plugin with a named export already declares it in its typings (swc, babel, wasm, node-resolve, html, dynamic-import-vars); esm-shim is the one that was left out.

Changes:

  • declare the named esmShim export and give the default its real name, matching the shape fix(swc): fix typings to match actual exports #1985 landed (export function swc(...): Plugin; export default swc;)
  • export the Output type, which src/index.ts already re-exports from ./types
  • assert the named export in the package's existing test:ts type test

pnpm --filter @rollup/plugin-esm-shim test:ts reports has no exported member 'esmShim' on the current typings and passes with this change.

@greymoth-jp greymoth-jp requested a review from tada5hi as a code owner June 29, 2026 03:44
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.

1 participant