-
Notifications
You must be signed in to change notification settings - Fork 717
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
Stats component not working with the latest update (StatsImpl is not a constructor) #1865
Comments
This seems to be only happening in a vite project. I tried the default create-react-app template that uses webpack and the import seems to work there. There's an open issue in the vite repo, I have added a reproducable example there: vitejs/vite#15851 It'd be great if it's possible to have some sort of workaround in drei in the meantime. I think one possible solution is to import from stats.js using the syntax |
same here |
One other alternative is to use |
In practical terms what's the downside of allowing |
I think some bundlers might not work as expected with the library in that case. Kind of like the issue we are facing right now. |
three
version: "^0.161.0"@react-three/fiber
version: "^8.15.16"@react-three/drei
version: "^9.101.0"node
version: v18.15.0npm
(oryarn
) version: pnpm 8.14.1Problem description:
After updating
@react-three/drei
from v9.97.1 to v9.101.0, the stats component stopped working and threw the following error:Relevant code:
Suggested solution:
The issue seems to have been introduced with the three.js update to v0.151.0 through #1850. In particular, the change in import syntax for the
Stats
class seemed to be the root cause.import StatsImpl from 'stats.js'
->import * as StatsImpl from 'stats.js'
https://github.com/pmndrs/drei/pull/1850/files#diff-49739308cbf61365d9e1da0ff995973345abe032e3445fdf766cca5c2f19cc36R3
Reverting this change back should fix the issue. I explored
stats.js
code and the export for theStats
class is default, which means that the previous syntax should be the correct one.I have tested the change locally and it works for me.
The text was updated successfully, but these errors were encountered: