onnovisser / babel-plugin-glsl

Process GLSL code with Glslify
MIT License
30 stars 2 forks source link

Incompatibility with modern build tools #2

Open sarended opened 2 years ago

sarended commented 2 years ago

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.

GoreStarry commented 1 year ago

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

sarended commented 1 year ago

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

momentchan commented 4 months ago

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

sarended commented 4 months ago

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

momentchan commented 4 months ago

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

marc-at-brightnight commented 2 months ago

@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 commented 2 months ago

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.