Skip to content

[Bug]: Unexpected undefined variable is exported for code with export * from ... #6017

@brijeshb42

Description

@brijeshb42

Reproduction link or steps

Repo - https://github.com/brijeshb42/mui-x/tree/build-tsdown (branch build-tsdown)
Config - https://github.com/brijeshb42/mui-x/blob/build-tsdown/packages/x-charts-pro/rolldown.config.mjs

Clone the repo/branch, install packages and build a package with rolldown.

pnpm i
pnpm -F @mui/x-charts-pro build:rolldown

The affected file -

source file: https://github.com/brijeshb42/mui-x/blob/build-tsdown/packages/x-charts-pro/src/constants/index.ts

Check the output in packages/x-charts-pro/build/constants/index.ts

Another repro - https://repl.rolldown.rs/#eNptkNtuwyAMhl/F4gZpYml3SzVpL7AnaHqBEjMxEROB6VJFvPtItx6i9s7+/fnwexZW6Fk46nFqOC0xCX3LlehqitMYIsML2BgGkM2mC5TYEKfKyJZa+ifOOhh4h7ftdle7UWiOGYsSMXjfhx9qKmPdV/N9XfakslrbozXZM8yAE2Mk4zXs5ceQ3Wa6XSIPCkLmMbOGuSWAwZGzJw2y7/A1kD9Jtcg2xMFURmIa/pQxYsJ4xM/QZ49Jw3JxrRQFjs7z9vLyEKlArswfoLQkqr979eJspT195YOLnSh12LGS3jAmFuUXuDSN+Q==

Look at the output var index_exports = {};. Seems unexpected and is similar to the bug in the repo.

What is expected?

Input code -

export * from '@mui/x-charts/constants';

Expected output -

export * from '@mui/x-charts/constants';

or maybe something similar along the same lines.

What is actually happening?

import { __reExport } from "../_virtual/rolldown_runtime.js";

export * from "@mui/x-charts/constants"

export { constants_exports };

Unexpected undefined variable constants_exports and non-usage of imported __reExport. Also check the output of build/index.js -

import { constants_exports } from "./constants/index.js";
import { hooks_exports } from "./hooks/index.js";
import { context_exports } from "./context/index.js";
import { models_exports } from "./models/index.js";
import { colorPalettes_exports } from "./colorPalettes/index.js";

// imported above 5 but not exported

System Info

System:
    OS: macOS 15.6.1
    CPU: (14) arm64 Apple M3 Max
    Memory: 1.16 GB / 36.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.18.0 - ~/.nvm/versions/node/v22.18.0/bin/node
    npm: 11.5.2 - ~/.nvm/versions/node/v22.18.0/bin/npm
    pnpm: 10.15.1 - ~/.nvm/versions/node/v22.18.0/bin/pnpm
    bun: 1.2.17 - ~/.bun/bin/bun
  Browsers:
    Safari: 18.6
  npmPackages:
    rolldown: 1.0.0-beta.34

Any additional comments?

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions