Error installing glslify-optimize
Opened this issue · 5 comments
Been having some issues installing this module. Have you guys ran into something similar?
Gist: https://gist.github.com/FarhadG/604299589d2233b7f4df
Node v0.12.0
Having the exact same issue.
I think the problem might actually be with the mapbox-glsl-optimizer dependency, but I'm getting the same issue.
This is because the V8 API changes with every Node release, unless you're using nan for handling the bindings and have that up to date too then it won't compile across every version. It won't work for io.js either, and sadly all I can recommend is falling back to node@0.10.x
for the time being.
It's an issue with mapbox-glsl-optimizer but unfortunately native bindings are a little beyond my understanding – @mikolalysenko @tmpvar do you guys have any ideas? :)
Actually was able to get this compiled on a fork, but I still can't get it working. I ended up ditching mapbox-glsl-optimizer and using marcs-glsl-optimizer instead.
There's some things in this package that just look weird to me. I'm not sure where 'glslify/adapter.js' is coming from. I've never seen it in the node tree and omitting this statement seems to let things continue onward. Also the final if(!(callee = callee.callee)) return
causes an exit. And nowhere did I see callee.name ever being require
. I added a check for if(node.value.length < 1) return
and that finally dumped out my shader, but I'm not sure this would work in all instances. So what finally worked for just a single frag shader was:
walk(function(node){
if (node.type !== 'Literal') return
var parent = node
var callee = node
if (!(parent = parent.parent)) return
if (!(parent = parent.parent)) return
if (!(callee = parent.callee)) return
// if (!(callee = callee.callee)) return
// my glslify func variable name....
if (callee.name !== 'glsl') return
if(node.value.length < 1) return
var args = parent.arguments
var opti = optimize.frag(node.value);
console.log(opti);
.....
I'm wondering if those checks are looking for the wrong thing. Perhaps something changed in the way that these trees are structured in the past couple years? Here's a sample node output.
{ type: 'Literal',
value: '#define GLSLIFY 1\n\n void main(){\n vec4 t = vec4(1.0);\n vec4 color = vec4(1.0,0.0,0.0,1.0);\n gl_FragColor = color;\n }\n',
raw: '"#define GLSLIFY 1\\n\\n void main(){\\n vec4 t = vec4(1.0);\\n vec4 color = vec4(1.0,0.0,0.0,1.0);\\n gl_FragColor = color;\\n }\\n"',
parent:
{ type: 'ArrayExpression',
elements: [ [Circular], [Object] ],
parent:
{ type: 'CallExpression',
callee: [Object],
arguments: [Object],
parent: [Object] } } }
Ok, think I got this sorted here aferriss@3680d4c and seems to be working for me. I'm not 100% that it is safe for all setups, would love if someone could take a look and see if I'm doing anything dangerous. Otherwise, I'm happy to submit a pr!