babel-plugin-glsl icon indicating copy to clipboard operation
babel-plugin-glsl copied to clipboard

Incompatibility with modern build tools

Open sarended opened this issue 2 years ago • 7 comments

As you are aware modern frontend toolings do not support old node modules importing. I am using Vite and i get the following error by importing 'babel-plugin-glsl/macro' indicating that process is not accessible.

Uncaught ReferenceError: process is not defined
    at node_modules/path-parse/index.js

I tried bypassing it with adding define: {'process.env': process.env} to the vite.config.js but i got the same error for utils.inherits which i couldn't fix and i think it's a chain of many errors. I saw the same errors on new versions of webpack as well. I assume rethinking the code for better compatibility with modern build tools is the best approach in here.

sarended avatar Aug 11 '22 10:08 sarended

It's work with me. https://github.com/vitejs/vite/issues/1973#issuecomment-787571499

GoreStarry avatar Dec 26 '22 10:12 GoreStarry

Yes that would fix the problem as long as the only missing file that you need is process.env But as i stated earlier if you miss other packages too this won't fix it

sarended avatar Dec 26 '22 18:12 sarended

@sarended hey I am suffering from this issue too have you found a way to work around?

momentchan avatar Apr 03 '24 02:04 momentchan

@momentchan sadly no. at the end i had to code the functions completely module-free since that the module be used.

sarended avatar Apr 04 '24 17:04 sarended

@sarended Thank you, got it. yes I ended up doing the same thing.

momentchan avatar Apr 05 '24 04:04 momentchan

@GoreStarry's solution worked, but then I got a different error: Uncaught TypeError: Unable to determine current node version.

More details here

marc-at-brightnight avatar Jun 04 '24 14:06 marc-at-brightnight

To those that are still struggling with this, I spent hours trying to make it work with different solutions. What ended up working for me is using vite-plugin-glslify-inject and removing this library completely as a dependency.

marc-at-brightnight avatar Jun 06 '24 11:06 marc-at-brightnight