-
Notifications
You must be signed in to change notification settings - Fork 136
Open
Description
Bug: Broken default export with Vite 8 / Rolldown
Description
After upgrading to Vite 8, importing react-countup breaks with the following warning:
Warning: React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: object.
Root cause
Vite 8 switched from esbuild/Rollup to Rolldown as its bundler. Rolldown changed the CJS interop behavior: when module.exports.__esModule === true, the default import now resolves to module.exports.default instead of module.exports itself.
Because react-countup ships as CJS with __esModule: true, the default import returns the whole module object instead of the component function:
import CountUp from 'react-countup';
console.log(CountUp);
// → { __esModule: true, default: ƒ CountUp, useCountUp: ƒ }
// Expected: ƒ CountUpSteps to reproduce
- Use Vite 8 (Rolldown)
- Import
react-countupas default import - Render
<CountUp />— React throws the invalid type warning
Current workaround
Adding legacy.inconsistentCjsInterop: true in vite.config.js restores the old behavior, but this option is marked as deprecated.
Expected fix
The package should either:
- Ship an ESM build (
"type": "module"or a properexportsfield inpackage.json) - Or ensure the CJS bundle is compatible with the new Rolldown interop behavior (i.e. not set
__esModule: trueunless the default export is correct)
References
Environment
| react-countup | latest |
| Vite | 8.x |
| Rolldown | (bundled with Vite 8) |
| React | 18 / 19 |
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels