Skip to content

SSR/SSG production build fails with undefined component exports (React #130) #568

@natew

Description

@natew

Description

When using rolldown-vite for production SSR/SSG builds in a complex React framework (One), components become undefined during static page generation, causing React error #130.

Reproduction

Repository: https://github.com/onejs/one
Branch: rolldown-web-support

git clone https://github.com/onejs/one.git
cd one
git checkout rolldown-web-support
yarn install
cd tests/test
yarn test:with-rolldown:prod  # Fails with React #130
yarn test:with-rolldown:dev   # Works fine (62 tests pass)

Error

Error: Minified React error #130; visit https://react.dev/errors/130?args[]=undefined&args[]=
    at renderElement (file:///...dist/server/assets/server.browser-DN7apeF3.js:6198:10)

This error means: "Element type is invalid: expected a string or class/function but got: undefined"

Analysis

The issue appears related to rolldown's lazy module initialization pattern:

var __esmMin = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
var Text_default;
var init_Text = __esmMin(() => {
  Text_default = Text$1;
});

When chunks import Text_default from the entry:

  1. The import happens
  2. init_dist() is called which calls init_Text()
  3. But by the time the chunk uses Text_default, it's still undefined

This seems to violate ES module live binding semantics where imports should reflect the current value of exports.

What Works

  • Dev mode: All tests pass
  • Manual testing: Loading modules directly in Node.js works fine

What Doesn't Work

  • Production SSG: Fails when rendering routes that use components re-exported through the virtual entry

Attempted Fixes

  1. experimental.strictExecutionOrder: true - No effect on output
  2. inlineDynamicImports: true - Did not resolve
  3. minify: false - Error still occurs

Environment

  • rolldown-vite: 7.3.0
  • Node.js: 24.x
  • Platform: macOS Darwin

Related

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions