graph-viz-d3-js
graph-viz-d3-js copied to clipboard
Newbie question: How to use without doing "grunt dist"
While developing/debugging, it would be nice to have shorter iterations that the one minute it takes to "grunt dist". I tried "grunt build" and used:
requirejs.config({
//By default load any module IDs from js/lib
baseUrl: '/bower_components/graphviz-d3-renderer/src/js',
//except, if the module ID starts with "app",
//load it from the js/app directory. paths
//config is relative to the baseUrl, and
//never includes a ".js" extension since
//the paths config could be for a directory.
paths: {
d3: '/bower_components/d3/d3',
"dot-checker": '/bower_components/graphviz-d3-renderer/src/js/dot-checker',
"layout-worker": '/bower_components/graphviz-d3-renderer/src/js/layout-worker',
worker: '/bower_components/requirejs-web-workers/src/worker',
renderer: '/bower_components/graphviz-d3-renderer/src/js/renderer'
}
});
But in Chrome Version 57.0.2987.110 (64-bit) on Ubuntu 14.04, I get:
layout-worker.js:18 Uncaught DOMException: Failed to execute 'postMessage' on 'DedicatedWorkerGlobalScope': TypeError: viz is not a function could not be cloned. at onmessage (http://madrox.netinsight.se:8084/bower_components/graphviz-d3-renderer/src/js/layout-worker.js:18:9) layout-worker.js:18 Uncaught DataCloneError: Failed to execute 'postMessage' on 'DedicatedWorkerGlobalScope': TypeError: viz is not a function could not be cloned.
And with Firefox 48.0 on Ubuntu 14.04, I get:
DataCloneError: The object could not be cloned.layout-worker.js:18
Is there a better way? graphviz.it has "grunt development", but not graph-viz-d3-js
Some debugging shows that the reason for the exception is that viz is undefined in https://github.com/mstefaniuk/graph-viz-d3-js/blob/master/src/js/transformer.js#L6
To me, this is strange since viz loads without problems: GET http://madrox.netinsight.se:8084/bower_components/graphviz-d3-renderer/lib/viz.js/viz.js [HTTP/1.1 304 Not Modified 65ms]
To be honest I usually try to define test for changes in this component and then I'm using it in graphviz.it website.
If you want to use non-minified versions directly I suppose you should to add path to viz.js. Bundled worker has inlined this library.
viz.js is found as it is. I've added an explicit path to it, but the problem persists. The problem is not that it in not found. The problem seems to have something to to with how it's initialized. That's why the viz argument to the function in
define(['viz', 'parser/xdot', 'pegast'], function (viz, xdotparser, pegast) {
is undefined.
I can have a look at the development setup for graphviz.it for clues.
What do you mean with "undled worker has inlined this library.". Is it that the code is incorporated in dist/layout-worker.js?
Exactly. I had problem you mentioned for long time and solved it in that way.
But to reiterate - I would prefer to add a test for output result in rendering component instead of testing it through graphviz.it
development version.