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
Describe the bug
Using the latest version of
backboneandbackbone-relational, the following code works fine using vite v7 dev and production mode, vite v8 dev mode, but not using vite v8 production mode:Reproduction
https://github.com/tyilo/vite8-backbone-relational
Steps to reproduce
Open the page and see that
Uncaught TypeError: can't access property "extend", Mo.RelationalModel is undefinedis 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.10Used Package Manager
npm
Logs
No response
Validations