Closed Omegahed closed 1 year ago
Hi @Omegahed, thanks for a detailed explanation on repro steps, I appreciate that! Unfortunately I wasn't able to reproduce it for some reason.., but this issue seems to be related to this one. Since v1.1.1
was just released with a fix for that, I'll ask you to give it a try please and let me know if this plugin is working properly in your project now. I won't be closing this until then, thanks!
Hi @UstymUkhman, thank you very much for looking into this bug. I'm happy to report that I'm unable to reproduce the error with version 1.1.1
. I also had a few team members try it out, and they aren't having any issues either. I reinstalled Node today, so I'm going to chalk it up to something weird on my side.
After the update, the error in my original project changed to this:
failed to load config from \vite.config.ts
error when starting dev server:
Error [ERR_REQUIRE_ESM]: require() of ES Module \node_modules\vite-plugin-glsl\src\index.js from \vite.config.ts not supported.
Instead change the require of index.js in \vite.config.ts to a dynamic import() which is available in all CommonJS modules.
After doing some further research I was able to determine that adding "type": "module"
to my package.json
file resolved the issue. I'm not sure why that was missing, as it seems to be a default for Vite projects. I'm probably the only one who will run into this issue, but if anyone else comes I hope they will see this and give that a try.
I really appreciate your help and effort on on this plugin!
Hey, no problem @Omegahed, I'm glad to help and that it worked out well for you! Actually, your issue is far more common than you think, here are some links that may be useful, where you (or others) can find some more info about why require()
is not supported in vite
anymore. I hope this helps if anyone runs into a similar error again:
X [ERROR] [plugin externalize-deps] Failed to resolve entry for package "vite-plugin-glsl". The package may have incorrect main/module/exports specified in its package.json: No known conditions for "." entry in "vite-plugin-glsl" package
The plugin appears to work correctly with a Vite vanilla JavaScript project, but not a vanilla TypeScript project.
Node version:
18.13.0
npm version:9.3.1
Vite version:4.0.4
Repro steps:
npm create vite@latest
vite-project
, and press the Enter keycd vite-project
npm install
npm install --save-dev vite-plugin-glsl
Create a
vite.config.ts
file and add the following code:npm run dev
Result: The project won't build and produces the following error...