Skip to content

Live binding does not work when the Object constructor is shadowed #19993

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
7 tasks done
x0k opened this issue May 2, 2025 · 4 comments · May be fixed by #19996
Open
7 tasks done

Live binding does not work when the Object constructor is shadowed #19993

x0k opened this issue May 2, 2025 · 4 comments · May be fixed by #19996
Labels
feat: ssr p3-minor-bug An edge case that only affects very specific usage (priority) regression The issue only appears after a new release

Comments

@x0k
Copy link

x0k commented May 2, 2025

Describe the bug

After updating to vite@6.3.3, SSR in my app stopped working.
I discovered that the issue was introduced in this commit: 80a91ff

lib.js contains the following code, which shadows the global Object constructor and causes the following error:

export default function Object() {}
TypeError: Object.defineProperty is not a function
    at eval (/home/projects/vitejs-vite-b63hinxr/src/lib.js:5:8)
    at ESModulesEvaluator.runInlinedModule (file:///home/projects/vitejs-vite-b63hinxr/node_modules/vite/dist/node/module-runner.js:1078:6)
    at ModuleRunner.directRequest (file:///home/projects/vitejs-vite-b63hinxr/node_modules/vite/dist/node/module-runner.js:1292:82)
    at ModuleRunner.cachedRequest (file:///home/projects/vitejs-vite-b63hinxr/node_modules/vite/dist/node/module-runner.js:1187:28)
    at request (file:///home/projects/vitejs-vite-b63hinxr/node_modules/vite/dist/node/module-runner.js:1236:79)
    at async eval (/home/projects/vitejs-vite-b63hinxr/src/main.js:3:44)
    at async ESModulesEvaluator.runInlinedModule (file:///home/projects/vitejs-vite-b63hinxr/node_modules/vite/dist/node/module-runner.js:1070:5)
    at async ModuleRunner.directRequest (file:///home/projects/vitejs-vite-b63hinxr/node_modules/vite/dist/node/module-runner.js:1292:61)
    at async ModuleRunner.cachedRequest (file:///home/projects/vitejs-vite-b63hinxr/node_modules/vite/dist/node/module-runner.js:1188:76)
    at async ModuleRunner.import (file:///home/projects/vitejs-vite-b63hinxr/node_modules/vite/dist/node/module-runner.js:1125:12)

Reproduction

https://stackblitz.com/edit/vitejs-vite-cpvgnuhv?file=src%2Flib.js

Steps to reproduce

open stackblitz

System Info

System:
    OS: Linux 6.6 cpe:/o:nixos:nixos:24.11 24.11 (Vicuna)
    CPU: (12) x64 Intel(R) Core(TM) i5-10400F CPU @ 2.90GHz
    Memory: 3.82 GB / 15.56 GB
    Container: Yes
    Shell: 5.2.37 - /run/current-system/sw/bin/bash
  Binaries:
    Node: 23.9.0 - /nix/store/wwdh9slw3km4a1cpwacanciinz742wxa-nodejs-23.9.0/bin/node
    npm: 10.9.2 - /nix/store/wwdh9slw3km4a1cpwacanciinz742wxa-nodejs-23.9.0/bin/npm
    pnpm: 10.1.0 - /nix/store/7v3vl4fgjqswj50zm8na25bnxqgli7sn-pnpm-10.6.2/bin/pnpm
  Browsers:
    Brave Browser: 135.1.77.101
  npmPackages:
    vite: catalog: => 6.3.3

Used Package Manager

pnpm

Logs

No response

Validations

@hi-ogawa
Copy link
Collaborator

hi-ogawa commented May 3, 2025

Your reproduction fails before 6.3.3 and that would be a known issue #15485 Do you have maybe a slightly different code which fails on 6.3.3 specifically?

Copy link

github-actions bot commented May 3, 2025

Hello @x0k. Please provide a minimal reproduction using a GitHub repository or StackBlitz. Issues marked with needs reproduction will be closed if they have no activity within 3 days.

@x0k
Copy link
Author

x0k commented May 3, 2025

It seems that before 6.3.3 the following code was not added to the output file

  Object.defineProperty(__vite_ssr_exports__, "default", {
    enumerable: true,
    configurable: true,
    get() {
      return __vite_ssr_export_default__;
    },
  });

@hi-ogawa
Copy link
Collaborator

hi-ogawa commented May 3, 2025

@x0k Ah, yes. That's the "slight" difference. These two are semantically different and you probably have the latter. The former was broken for a long time but the latter just got broken since 6.3.3 due to our natural generalization and we should fix both.

export default function Object() {}
function Object() {}
export default Object;

@hi-ogawa hi-ogawa added p3-minor-bug An edge case that only affects very specific usage (priority) and removed needs reproduction labels May 3, 2025
@hi-ogawa hi-ogawa added the regression The issue only appears after a new release label May 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat: ssr p3-minor-bug An edge case that only affects very specific usage (priority) regression The issue only appears after a new release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants