Subscribe on changes!

Error when instantiating class in props

avatar
Feb 22nd 2023

Vue version

3.2.47

Link to minimal reproduction

https://stackblitz.com/edit/vitejs-vite-e4ur7u?file=src/App.vue

Steps to reproduce

Stackblitz will automatically run "npm install & npm run build & npm run preview"

Open developer console to see the error.

What is expected?

Instantiating a new instance of an imported class inside of a property should work the same in dev and prod. The imported class should not be "unref()"ed.

Something like this would be expected, this is what is generated for a barrel import: image

What is actually happening?

Vue adds unref around the class and behind the "new" keyword. This causes the built site to crash while it works in development. image

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: 16.14.2 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 7.17.0 - /usr/local/bin/npm
  npmPackages:
    vue: ^3.2.47 => 3.2.47

Any additional comments?

This error does not occur in development (npm run dev).

I added a second Div to the Stackblitz which uses a barrel import, this does seem to be handled differently and does not cause an error.

avatar
Feb 22nd 2023

looks like a duplicate of #6483