#8213·naive-ui

n-dropdown submenus do not render in the CommonJS build since 2.45.0

Author: anguiaoCreated Sep 6, 2026Updated Sep 6, 2026

Describe the bug

Since 2.45.0, n-dropdown submenus do not render when loading the published CommonJS entry. Hovering an option with children produces Component is missing template or render function and Vue receives an empty component object ({}). The ESM entry works with the same options.

Reproduced in 2.45.0, 2.45.1, 2.45.2 and 2.45.3; 2.44.1 works. I intend to submit a PR for this issue.

Steps to reproduce

  1. Clone/download the reproduction below and run npm install.
  2. Run node --no-warnings repro.mjs cjs.
  3. The script mounts an open dropdown containing a parent and one child, then dispatches mouseenter on the parent.
  4. The result is before: 1, after: 1, child: false, with a Vue missing-render warning. Expected: two menus and a visible child option.
  5. Run node --no-warnings repro.mjs esm: it returns before: 1, after: 2, child: true, without Vue warnings. Installing [email protected] also makes the CJS case work.

The reproduction has no JSX compilation or application dependencies. --no-warnings only suppresses Node's circular-dependency property-access warnings; the JSON output still includes captured Vue warnings.

The CJS build has a DropdownMenu → DropdownOption → DropdownMenu cycle. DropdownOption.js captures require('./DropdownMenu.js') while its exports are still {}. DropdownMenu.js later replaces module.exports, leaving the captured reference stale. In 2.44.1 the exports object is retained and .default is read during rendering. The DropdownOption.tsx source is identical between these versions.

Forcing named CJS exports in tsdown fixes the reproduction. The current main is still at the v2.45.3 commit (42a52e6).

Link to minimal reproduction

https://gist.github.com/anguiao/fffa4eaf5b333f1a66ddcfb1e36dfe21

System Info

bash
System: macOS
Node: 24.20.0
naive-ui: 2.45.3
vue: 3.5.42
happy-dom: 20.14.0

Used Package Manager

npm

Validations