Skip to content

fix(virtual): support default imports with Node16 and NodeNext - #2028

Draft
Boulea7 wants to merge 1 commit into
rollup:masterfrom
Boulea7:ln-cx/fix-virtual-nodenext-types
Draft

Boulea7 wants to merge 1 commit into
rollup:masterfrom
Boulea7:ln-cx/fix-virtual-nodenext-types

Conversation

@Boulea7

@Boulea7 Boulea7 commented Sep 30, 2026 •

Copy link
Copy Markdown

Rollup Plugin Name: @rollup/plugin-virtual

This PR contains:

  • bugfix
  • feature
  • refactor
  • documentation
  • other

Are tests included?

  • yes (bugfixes and features will not be merged without tests)
  • no

Breaking Changes?

  • yes (breaking changes will not be merged unless absolutely necessary)
  • no

If yes, then include "BREAKING CHANGES:" in the first commit message body, followed by a description of what is breaking.

List any relevant issue numbers:

Fixes #2024

Description

With Node16 or NodeNext module resolution, an ESM consumer's documented default import is typed as a namespace and cannot be called:

import virtual from '@rollup/plugin-virtual';
virtual({ entry: 'export default 42' });

Route the import condition to an ESM declaration that reuses the existing function type. Existing runtime entries, CJS declarations, top-level types, and the default fallback are preserved.

The regression checks public package-name imports for ESM and CJS, plus a directory-entry fixture for legacy Node resolution. From packages/virtual, run pnpm test:ts.

Validation:

  • pnpm build, pnpm test (7 tests), and pnpm test:ts pass.

  • TypeScript 4.8.4 and 5.9.3 pass the Node16/NodeNext ESM and CJS checks and legacy resolution fixture.

  • Public package-name ESM and CJS runtime imports pass against the rebuilt package.

  • Root pnpm lint passes with 0 errors and 45 warnings in unchanged files in other packages; virtual has no warnings.

  • Root pnpm fix:js passes with 0 errors and 39 warnings.

Draft pending maintainer approval for GitHub Actions.

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.

@rollup/plugin-virtual: TS2349: This expression is not callable under modern "moduleResolution": "NodeNext"

1 participant