gpujs / gpu.js

GPU Accelerated JavaScript
https://gpu.rocks
MIT License
15.1k stars 652 forks source link

create-react-app minify step of build is causing errors at run time #642

Open RossKinsella opened 3 years ago

RossKinsella commented 3 years ago

What is wrong?

Code which is working in an un-minified development environment is crashing after creating a build via create-react-app, where the code has been minified and uglified

Where does it happen?

gpu.js 2.10.4

The code which I create inside of the gpu.createKernel function

How do we replicate the issue?

Download source code

See it working in dev environment

See it breaking in a build

How important is this (1-5)?

5

Expected behavior (i.e. solution)

For the build step to not break the code

Other Comments

Thanks for your hard work on this project.

I spent a few hours looking over the other issues related to minify problems, I think I am running into some other edge case here.

ted-piotrowski commented 3 years ago

I just ran into this. The minifier often does variable assignment/mutation inside of if statements. This is legal javascript but breaks the GPU.js compiler:

if (d = 0) {
  return -1;
}
return 1

Another example:

if (d=0,d+=1,d>0) {
  return d;
}
Error: Error compiling fragment shader: ERROR: 0:478: 'assign' : cannot convert from 'bool' to 'lowp float'