Skip to content

Prebundler incorrectly handles JSONs that has "default" as top-level property #22530

Description

Describe the bug

See reproduction link. The prebundled deps generated locally looks this, resulting in an incorrect accessor pattern for getting the property "default" within the JSON that results in undefined in this case:

Image Image

We ran into this issue last friday as one of our NPM packages contains an JSON that has "default" as top-level property in the JSON, resulting in null exception during local dev serve.

Reproduction

https://stackblitz.com/edit/vitejs-vite-yx2cumr5?file=src%2Fmain.js,src%2Flib.js&terminal=dev

Steps to reproduce

Open the link and check the console for output. You should see the following somewhere in the console:

Image

System Info

System:
    OS: Windows 11 10.0.26100
    CPU: (22) x64 Intel(R) Core(TM) Ultra 9 185H
    Memory: 37.51 GB / 63.45 GB
  Binaries:
    Node: 24.15.0 - C:\Program Files\nodejs\node.EXE
    npm: 11.12.1 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Chrome: 148.0.7778.179
    Edge: Chromium (142.0.3595.53)
    Firefox: 151.0 - C:\Program Files\Mozilla Firefox\firefox.exe
  npmPackages:
    vite: ^8.0.12 => 8.0.14

Used Package Manager

npm

Logs

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug: upstreamBug in a dependency of Vitefeat: deps optimizerDependencies Optimizationp3-minor-bugAn edge case that only affects very specific usage (priority)

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions