Skip to content

Vite 8 breaks backbone-relational #22435

Description

@tyilo

Describe the bug

Using the latest version of backbone and backbone-relational, the following code works fine using vite v7 dev and production mode, vite v8 dev mode, but not using vite v8 production mode:

import * as Backbone from "backbone";
import "backbone-relational";

// Uncaught TypeError: can't access property "extend", Mo.RelationalModel is undefined
Backbone.RelationalModel.extend({});

alert("Success!");

Reproduction

https://github.com/tyilo/vite8-backbone-relational

Steps to reproduce

npm ci
npm run build && npm run preview

Open the page and see that Uncaught TypeError: can't access property "extend", Mo.RelationalModel is undefined is logged and the alert is not shown.

System Info

System:
    OS: Linux 6.18 Arch Linux
    CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
    Memory: 14.74 GB / 31.06 GB
    Container: Yes
    Shell: 4.6.0 - /usr/bin/fish
  Binaries:
    Node: 24.15.0 - /home/tyilo/.local/share/mise/installs/node/24/bin/node
    Yarn: 1.22.22 - /home/tyilo/bin/yarn
    npm: 11.12.1 - /home/tyilo/.local/share/mise/installs/node/24/bin/npm
    pnpm: 11.0.9 - /home/tyilo/bin/pnpm
    bun: 1.3.11 - /usr/bin/bun
    Deno: 2.7.14 - /usr/bin/deno
  Browsers:
    Chromium: 147.0.7727.137
    Firefox: 150.0.1
    Firefox Developer Edition: 150.0.1
  npmPackages:
    vite: ^8.0.10 => 8.0.10

Used Package Manager

npm

Logs

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    feat: deps optimizerDependencies Optimizationhas workaroundinconsistencyInconsistency between dev & buildp2-edge-caseBug, but has workaround or limited in scope (priority)regressionThe issue only appears after a new release

    Type

    Fields

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions