Skip to content

[Bug]: Vite 8 UMD builds with external dependencies from globals #8349

@Jinjiang

Description

@Jinjiang

Reproduction link or steps

https://github.com/Jinjiang/reproductions/tree/vite8-external-20260216

How to reproduce:

pnpm install
pnpm dev

see the browser console:

// vite 7 works
ƒ MDXContent(props = {}) {
		const { wrapper: MDXLayout } = props.components || {};
		return MDXLayout ? jsxRuntimeExports.jsx(MDXLayout, {
			...props,
			children: jsxRuntimeExports.jsx(_createMdxCon…

// vite 8 doesn't
foo8.umd.js:210 Uncaught (in promise) ReferenceError: require is not defined

What is expected?

The require('react') should somehow be linked to globalThis.React like rollup does in Vite 7 but it didn't.

What is actually happening?

It keeps require('react') in the source code which caused the browser runtime error.

System Info

System:
    OS: Linux 5.15 Ubuntu 22.04.3 LTS 22.04.3 LTS (Jammy Jellyfish)
    CPU: (10) arm64 unknown
    Memory: 3.82 GB / 7.64 GB
    Container: Yes
    Shell: 5.1.16 - /bin/bash
  Binaries:
    Node: 22.14.0 - /home/jinjiang/.volta/tools/image/node/22.14.0/bin/node
    npm: 11.6.4 - /home/jinjiang/.volta/tools/image/npm/11.6.4/bin/npm
    pnpm: 10.28.2 - /home/jinjiang/.volta/bin/pnpm
  Browsers:
    Chromium: 144.0.7559.132
  npmPackages:
    rolldown: 1.0.0-rc.2 => 1.0.0-rc.2

Any additional comments?

No response

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions