Skip to content
This repository was archived by the owner on Mar 19, 2026. It is now read-only.
This repository was archived by the owner on Mar 19, 2026. It is now read-only.

Incorrect new.target.prototype transformation #601

@barclayadam

Description

@barclayadam

Describe the bug

In Vite 8.0.0-beta.15, new.target.prototype is incorrectly transformed to _vite_importMeta.prototype in Web Worker contexts, causing a runtime TypeError when the code executes.

Source code:

Object.setPrototypeOf(this, new.target.prototype);

Built output (Vite 8 beta.15):

var _vite_importMeta = { url: self.location.href };
// ...
Object.setPrototypeOf(this, _vite_importMeta.prototype); // ❌ _vite_importMeta.prototype is undefined!

Reproduction

https://stackblitz.com/edit/ak5xqjbd?file=vite.config.ts,index.html,README.md

Steps to reproduce

npm run build OR npm run preview. Details in README.md

System Info

System:                                                                                                            │
  │     OS: Windows 11 10.0.26100                                                                                        │
  │     CPU: (22) x64 Intel(R) Core(TM) Ultra 7 165H                                                                     │
  │     Memory: 11.00 GB / 63.46 GB                                                                                      │
  │   Binaries:                                                                                                          │
  │     Node: 24.7.0 - C:\Program Files\nodejs\node.EXE                                                                  │
  │     npm: 11.5.1 - C:\Program Files\nodejs\npm.CMD                                                                    │
  │     pnpm: 10.24.0 - C:\Users\AdamBarclay(Symprex)\AppData\Local\Microsoft\WinGet\Links\pnpm.EXE                      │
  │     bun: 1.3.3 - C:\Users\AdamBarclay(Symprex)\AppData\Local\Microsoft\WinGet\Links\bun.EXE                          │
  │   Browsers:                                                                                                          │
  │     Chrome: 145.0.7632.116                                                                                           │
  │     Edge: Chromium (140.0.3485.54)                                                                                   │
  │     Firefox: 145.0.2 - C:\Program Files\Mozilla Firefox\firefox.exe                                                  │
  │     Internet Explorer: 11.0.26100.7309                                                                               │
  │   npmPackages:                                                                                                       │
  │     vite: 8.0.0-beta.15 => 8.0.0-beta.15

Used Package Manager

npm

Logs

No response

Validations

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