probmods / webppl-viz

Visualization for WebPPL
http://probmods.github.io/webppl-viz/
Other
14 stars 9 forks source link

Bundling webppl and viz broken #16

Closed jsalvatier closed 8 years ago

jsalvatier commented 8 years ago

Bundling webppl and webppl-viz together no longer seems to work (which agentmodels.org uses to run viz in the browser). Looks like you recently moved to React which does some code transformation and that's not happening during bundling?

➜  webppl git:(dev) ✗ grunt bundle:../webppl-viz
Running "bundle:../webppl-viz" (bundle) task

Running "browserify:../webppl-viz" (browserify) task
Error: Line 632: Unexpected token < (/Users/jsalvatier/workspace/webppl-viz/src/index.js) while parsing file: /Users/jsalvatier/workspace/webppl-viz/src/index.js
    at Stream.end (/Users/jsalvatier/workspace/webppl/node_modules/brfs/index.js:39:32)
    at _end (/Users/jsalvatier/workspace/webppl/node_modules/through/index.js:61:9)
    at Stream.stream.end (/Users/jsalvatier/workspace/webppl/node_modules/through/index.js:70:5)
    at DestroyableTransform.onend (/Users/jsalvatier/npm/lib/node_modules/browserify/node_modules/readable-stream/lib/_stream_readable.js:495:10)
    at DestroyableTransform.g (events.js:260:16)
    at emitNone (events.js:72:20)
    at DestroyableTransform.emit (events.js:166:7)
    at endReadableNT (/Users/jsalvatier/npm/lib/node_modules/browserify/node_modules/readable-stream/lib/_stream_readable.js:865:12)
    at nextTickCallbackWith2Args (node.js:441:9)
    at process._tickCallback (node.js:355:17)
Warning: Command failed: browserify -t [./src/bundle.js --require ../webppl-viz] -g brfs src/browser.js -o bundle/webppl.js
Error: Line 632: Unexpected token < (/Users/jsalvatier/workspace/webppl-viz/src/index.js) while parsing file: /Users/jsalvatier/workspace/webppl-viz/src/index.js
    at Stream.end (/Users/jsalvatier/workspace/webppl/node_modules/brfs/index.js:39:32)
    at _end (/Users/jsalvatier/workspace/webppl/node_modules/through/index.js:61:9)
    at Stream.stream.end (/Users/jsalvatier/workspace/webppl/node_modules/through/index.js:70:5)
    at DestroyableTransform.onend (/Users/jsalvatier/npm/lib/node_modules/browserify/node_modules/readable-stream/lib/_stream_readable.js:495:10)
    at DestroyableTransform.g (events.js:260:16)
    at emitNone (events.js:72:20)
    at DestroyableTransform.emit (events.js:166:7)
    at endReadableNT (/Users/jsalvatier/npm/lib/node_modules/browserify/node_modules/readable-stream/lib/_stream_readable.js:865:12)
    at nextTickCallbackWith2Args (node.js:441:9)
    at process._tickCallback (node.js:355:17)
 Use --force to continue.

Aborted due to warnings.
longouyang commented 8 years ago

Yes, it looks like the React JSX transforms aren't being done.

webppl-viz isn't, in the strictest sense, a webppl package. Because it installs the viz object into the global namespace, you don't have to bundle it with webppl for it to work.

You can just include the webppl-viz.js and webppl-viz.css files along side your webppl bundle in the browser and things should just work.

If that workflow doesn't work for you guys, then the appropriate fix is probably to modify the webppl Gruntfile so that we can specify transforms on a per-require basis.

stuhlmueller commented 8 years ago

We're using that workflow now for agentmodels (since e17b148). John, can you take a stab at using it for gridworld as well?

longouyang commented 8 years ago

@jsalvatier There's been enough demand for rendering from the command line that it made sense for me to make webppl-viz usable as a webppl package (i.e., make it work with --require)

As of b8332fd5af990b325653febeb148a4427f27f1df, there's no more JSX, so I believe that bundling should work again. Can you try this and let me know whether it works for you? If so we can close the issue.

jsalvatier commented 8 years ago

Yup, this worked.