n-dropdown submenus do not render in the CommonJS build since 2.45.0
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
- Clone/download the reproduction below and run
npm install. - Run
node --no-warnings repro.mjs cjs. - The script mounts an open dropdown containing a parent and one child, then dispatches
mouseenteron the parent. - The result is
before: 1, after: 1, child: false, with a Vue missing-render warning. Expected: two menus and a visible child option. - Run
node --no-warnings repro.mjs esm: it returnsbefore: 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
System: macOS
Node: 24.20.0
naive-ui: 2.45.3
vue: 3.5.42
happy-dom: 20.14.0Used Package Manager
npm
Validations
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion.
- The provided reproduction is a minimal reproducible example of the bug.
Source: tusen-ai/naive-ui