browserify bundle tickles scjson-analyzer bug
Created by: mattoshry
Attempting to use browserify [1] to write modules once and reuse them on the server and in the browser - including a SCION-based scxml browser.
Referencing a browserify generated bundle that requires 'util' [2] causes the following:
< TypeError: Cannot read property 'name' of undefined < at Object.scJsonAnalyzer.analyze.treeTypes.AssignmentExpression (/Users/matto/gerrit/scxml/node_modules/scxml/lib/compiler/static-analysis/scjson-analyzer.js:270:71) < at /Users/matto/gerrit/scxml/node_modules/scxml/lib/compiler/static-analysis/scjson-analyzer.js:285:37 < at Array.forEach (native) < at traverseSyntaxTree (/Users/matto/gerrit/scxml/node_modules/scxml/lib/compiler/static-analysis/scjson-analyzer.js:282:22) < at /Users/matto/gerrit/scxml/node_modules/scxml/lib/compiler/static-analysis/scjson-analyzer.js:289:15 < at Array.forEach (native) < at traverseSyntaxTree (/Users/matto/gerrit/scxml/node_modules/scxml/lib/compiler/static-analysis/scjson-analyzer.js:282:22) < at /Users/matto/gerrit/scxml/node_modules/scxml/lib/compiler/static-analysis/scjson-analyzer.js:289:15 < at Array.forEach (native) < at traverseSyntaxTree (/Users/matto/gerrit/scxml/node_modules/scxml/lib/compiler/static-analysis/scjson-analyzer.js:282:22) break in node_modules/scxml/lib/compiler/static-analysis/scjson-analyzer.js:260 258 } catch (e) { 259 console.error(e.stack);
260 debugger;
In treeTypes, there's an assumption that tree.init and tree.expression both always have a 'left' object: if(tree.init && systemVariables.indexOf(tree.init.left.name) !== -1) {
if(tree.expression && systemVariables.indexOf(tree.expression.left.name) !== -1) {
Also, in the catch handler: errors.push(e.description); should be errors.push(e.message);
[1] http://browserify.org/ [2] https://www.npmjs.com/package/util