UstymUkhman / vite-plugin-glsl

:spider_web: Import, inline (and compress) GLSL shader files :electric_plug:
https://www.npmjs.com/package/vite-plugin-glsl
MIT License
321 stars 21 forks source link

Can't load shaders #13

Closed AndresDiaz1 closed 2 years ago

AndresDiaz1 commented 2 years ago

Hi

I follow the readme, but it throws this error: [vite] Internal server error: shaderChunks.at is not a function

I had to do this workaround on loadShaders.js library file.:

I had to replace: const caller = shaderChunks.at(-1); to const caller = shaderChunks[shaderChunks.length-1]

Have you faced the same error?

UstymUkhman commented 2 years ago

Hi @AndresDiaz1 , thanks for reporting this issue. I haven't face the same error, but my guess this is happening due to your Node.js version. Array.at was introduced in v16.6.0 so most likely this issue is because you're running a node environment prior to that. Anyway, I will update that line to use a more classic approach with .length - 1 in order to support older node environments. For now you can use v0.1.2 to avoid this hack.

UstymUkhman commented 2 years ago

@AndresDiaz1 I'm closing this since version 0.2.0 should fix your issue. Feel free to open a new one if you notice some other problems. Also, please consider giving a ⭐ to this project if you've found it useful, thanks!

AndresDiaz1 commented 2 years ago

Thanks for the quick response! Yes, you're right it was the node version. I was using version 14.8.0 once I upgraded it above 16 it worked. Also using version 14.8.0 of node and the new version 0.2.0 works perfectly.

Thanks for your help :+1:

UstymUkhman commented 2 years ago

Nice! I'm glad to help and thanks for the star. 🙂