Skip to content

Creating a build with vite causes method to be undefined #15319

@hybridherbst

Description

@hybridherbst

Describe the bug

The code in the reproduction case only breaks when making a build. Local development works fine.

Related issue on the three.js side to keep track of it:

I have tracked down the difference between local run and a build run being that functionNode.call is undefined in builds, but defined and working in local development:

I am not 100% sure if this is a vite bug during bundling but I don't know where the discrepancy comes from.

Reproduction

https://stackblitz.com/edit/vitejs-vite-9b37bu

Steps to reproduce

  1. Go to https://stackblitz.com/edit/vitejs-vite-9b37bu
  2. Open the browser console
  3. Run npm run start
  4. Note no errors (code runs fine)
  5. Cancel the run by pressing Ctrl + C in the terminal
  6. Run npm run preview which builds the code and hosts the resulting bundled code
  7. In the console, note error: Uncaught TypeError: functionNode.call is not a function

System Info

System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 18.18.0 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 9.4.2 - /usr/local/bin/npm
    pnpm: 8.10.5 - /usr/local/bin/pnpm
  npmPackages:
    vite: ^5.0.4 => 5.0.7

Used Package Manager

npm

Logs

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions