Skip to content
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

Decorator errors since Vite 5.4.9 #18463

Closed
7 tasks done
dbelob opened this issue Oct 25, 2024 · 2 comments
Closed
7 tasks done

Decorator errors since Vite 5.4.9 #18463

dbelob opened this issue Oct 25, 2024 · 2 comments

Comments

@dbelob
Copy link

dbelob commented Oct 25, 2024

Describe the bug

There is an application using InversifyJS (DI container) together with Vite. Inversify heavily depends on decorators. To use decorators, all necessary settings were made and the application worked.

Since version Vite 5.4.9 the application stopped working.

Possible cause of errors is PR #18322

Reproduction

https://stackblitz.com/github/dbelob/vite-inversify-error

Steps to reproduce

Branch main of https://github.com/dbelob/vite-inversify-error repository (StackBlitz link: https://stackblitz.com/github/dbelob/vite-inversify-error) contains example with Vite 5.4.10 (last version) where errors are reproduced:

  1. git clone https://github.com/dbelob/vite-inversify-error.git
  2. cd vite-inversify-error
  3. npm install
  4. npm start

The browser will open automatically with errors in the console:

Uncaught TypeError: Cannot read properties of undefined (reading 'getMessage')
    at ClassComponent.render (ClassComponent.tsx? [sm]:18:46)
    at finishClassComponent (react-dom.development.js:19781:31)
    ...

Branch vite-5.4.8 of https://github.com/dbelob/vite-inversify-error repository (StackBlitz link: https://stackblitz.com/github/dbelob/vite-inversify-error/tree/vite-5.4.8) contains example with Vite 5.4.8 where errors are not reproduced:

  1. git clone -b vite-5.4.8 https://github.com/dbelob/vite-inversify-error.git vite-inversify-error-vite-5.4.8
  2. cd vite-inversify-error-vite-5.4.8
  3. npm install
  4. npm start

The browser will open automatically without errors in the console.

System Info

System:
    OS: Windows 10 10.0.19044
    CPU: (4) x64 AMD EPYC 7443 24-Core Processor
    Memory: 6.55 GB / 16.00 GB
  Binaries:
    Node: 20.18.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.17 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 10.8.2 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Chrome: 130.0.6723.70
    Edge: Chromium (128.0.2739.42)
    Internet Explorer: 11.0.19041.4355

Used Package Manager

npm

Logs

Click to expand!
Uncaught TypeError: Cannot read properties of undefined (reading 'getMessage')
    at ClassComponent.render (ClassComponent.tsx? [sm]:18:46)
    at finishClassComponent (react-dom.development.js:19781:31)
    at updateClassComponent (react-dom.development.js:19727:24)
    at beginWork (react-dom.development.js:21650:16)
    at HTMLUnknownElement.callCallback2 (react-dom.development.js:4164:14)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:4213:16)
    at invokeGuardedCallback (react-dom.development.js:4277:31)
    at beginWork$1 (react-dom.development.js:27490:7)
    at performUnitOfWork (react-dom.development.js:26596:12)
    at workLoopSync (react-dom.development.js:26505:5)

Validations

@hi-ogawa
Copy link
Collaborator

It looks like inversify requires useDefineForClassFields: false, so it needs to be configured correctly now. Here is an updated repro https://stackblitz.com/edit/github-g9jirc?file=tsconfig.app.json

Previously useDefineForClassFields: true in tsconfig.app.json was ignored, but that's what's fixed in the PR #18322

@dbelob
Copy link
Author

dbelob commented Oct 26, 2024

It looks like inversify requires useDefineForClassFields: false, so it needs to be configured correctly now. Here is an updated repro https://stackblitz.com/edit/github-g9jirc?file=tsconfig.app.json

Previously useDefineForClassFields: true in tsconfig.app.json was ignored, but that's what's fixed in the PR #18322

@hi-ogawa Thanks a lot!

@github-actions github-actions bot locked and limited conversation to collaborators Nov 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants