jbeard4 / SCION

SCXML/Statecharts in JavaScript, moved to gitlab: https://gitlab.com/scion-scxml/scion
https://scion.scxml.io
Apache License 2.0
149 stars 29 forks source link

browserify bundle tickles scjson-analyzer bug #363

Open mattoshry opened 8 years ago

mattoshry commented 8 years ago

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

jbeard4 commented 8 years ago

Could you elaborate on the use case? Are you trying to create a browserify-based build, and use the build inside of Node.js?

Could you please provide a minimal repro of the issue you're encountering? Thanks.

mattoshry commented 8 years ago

That is the use case, Jake. Please check your email for the scxml and js bundle that reproduces this. On Sun, Oct 4, 2015 at 2:54 PM Jacob Beard notifications@github.com wrote:

Could you elaborate on the use case? Are you trying to create a browserify-based build, and use the build inside of Node.js?

Could you please provide a minimal repro of the issue you're encountering? Thanks.

— Reply to this email directly or view it on GitHub https://github.com/jbeard4/SCION/issues/363#issuecomment-145391688.