Skip to content

[Bug]: Minifier DCE's a side-effecting new RegExp used for engine feature detection #10279

Description

@nebutch

Reproduction link or steps

Rolldown REPL

What is expected?

The new RegExp is not dead code eliminated.

Rollup/ES REPL (for comparison)

Input

export function supportsUnicodeRegExp() {
  try {
    new RegExp('\\p{Ll}', 'u'); // constructor throws on engines without \p{} support
    return true;
  } catch {
    return false;
  }
}

Output:

function supportsUnicodeRegExp() {
  try {
    new RegExp('\\p{Ll}', 'u'); // constructor throws on engines without \p{} support
    return true;
  } catch {
    return false;
  }
}

export { supportsUnicodeRegExp };

What is actually happening?

The new RegExp code is being dead code eliminated

Input

export function supportsUnicodeRegExp() {
  try {
    new RegExp('\\p{Ll}', 'u'); // constructor throws on engines without \p{} support
    return true;
  } catch {
    return false;
  }
}

Output

//#region index.ts
function supportsUnicodeRegExp() {
	try {
		return true; // <-- defaults to true, causing runtime errors in legacy engines
	} catch {
		return false;
	}
}
//#endregion
export { supportsUnicodeRegExp };

System Info

System:
    OS: macOS 26.5
    CPU: (10) arm64 Apple M1 Max
    Memory: 84.97 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.17.0 - ~/.volta/tools/image/node/22.17.0/bin/node
    Yarn: 1.22.19 - ~/.volta/bin/yarn
    npm: 10.9.2 - ~/.volta/tools/image/node/22.17.0/bin/npm
    pnpm: 11.1.2 - ~/.volta/tools/image/pnpm/11.1.2/bin/pnpm
    Watchman: 2026.04.27.00 - /opt/homebrew/bin/watchman
  Browsers:
    Chrome: 150.0.7871.115
    Chrome Canary: 152.0.7949.0
    Firefox: 152.0.4
    Safari: 26.5
  npmPackages:
    rolldown: 1.0.3 => 1.0.3

Any additional comments?

This issue is primarily affecting applications compiled with Rolldown (via Vite v8) when running on older connected devices, such as 2018/2019 Samsung Tizen (Chromium v56/63 respectively).

In this specific case, the relevant code is part of a 3rd party library (Datadog v6), which we are currently patching in order to prevent the DCE.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Fields

Priority

None yet

Effort

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions