Skip to content

Broken default export with Vite 8 / Rolldown #884

@PantherX99

Description

@PantherX99

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: ƒ CountUp

Steps to reproduce

  1. Use Vite 8 (Rolldown)
  2. Import react-countup as default import
  3. 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 proper exports field in package.json)
  • Or ensure the CJS bundle is compatible with the new Rolldown interop behavior (i.e. not set __esModule: true unless the default export is correct)

References

Environment

react-countup latest
Vite 8.x
Rolldown (bundled with Vite 8)
React 18 / 19

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions