Comments (16)
Yes, the output of the webpack-no-worker
example is a single file, bundle.js
, that includes both viz.js
and full.render.js
.
I'll see if I can come up with a rollup example as well. I forgot that there already is one: https://github.com/mdaines/viz-examples/tree/master/rollup but it uses a worker.
from viz-js.
I've added an example for Rollup that doesn't use a worker: https://github.com/mdaines/viz-examples/tree/master/rollup-no-worker
You'll need to effectively tell Rollup not to worry about built-in Node modules like fs
, and one way to do that is with the "ignore" Rollup plugin. References to such modules are currently included in the code generated by Emscripten, but aren't actually executed when running in the browser.
from viz-js.
No problem! I closed it as "not planned" because I'm working on a new version of Viz.js that's somewhat different from 2.x, including when it comes to bundling. (No separate ".render.js" file, for one thing.)
from viz-js.
That's great to hear. I've published the new version, so please give it a try. Although there's a new package name, @viz-js/viz
and the API is a little different because of using WebAssembly.
from viz-js.
What error are you getting from rollup?
Here's an example of producing a single bundle with webpack: https://github.com/mdaines/viz-examples/tree/master/webpack-no-worker However, Viz.js 2.1.1 has a bug that prevents webpack from processing it successfully in this situation, so I wonder if this is related to what you're seeing? See #160. I have a fix in 2.1.2-pre.1, and I'm going to release 2.1.2 today.
You can also concatenate the viz.js
and full.render.js
(or lite.render.js
) files along with your script. Have a look at this example, which includes them using <script>
tags: https://github.com/mdaines/viz-examples/blob/master/script-tag/no-worker.html If you use the that approach, you need to put viz.js
before the render script, so the render script add its code to the global Viz
object: https://github.com/mdaines/viz.js/blob/master/src/boilerplate/post-module.js#L57
from viz-js.
I got a thousand errors from a thousand paths through rollup, at least 995 of them my own fault, and I don't know enough to tell them apart. However I did not see #160. (Or if I did, I didn't notice it.)
My pernicious problem wasn't actually an error. It was rollup proceeding thinking things were done, with the code not actually physically present in the bundle.
I will see what I can squeeze out of webpack-no-worker. I've managed to avoid webpack this entire time, so, examples in it aren't as universal to me as they ought to be. But I'll see what I can do. Thank you
Concatenation is a last-resort strategy because ideally I want to provide bundles to downstream users, which concatenation basically renders impossible
from viz-js.
Sorry for the stupid question
no-worker
implies that the worker is being packaged in, and that there's no ancillary load, rather than that the facility offered is removed, yes?
from viz-js.
You're very generous with your time 😁
TYVM
from viz-js.
uhuhuhuhuhuhu
so. this now builds and runs correctly in the browser, but attempting to load the commonjs version causes node to respond as if a successful load had happened, then immediately die. wrapping in a try catch does not help or give further information.
john@DESKTOP-26H4050 MINGW64 ~/projects/jssm-viz/build (AttemptingVizJs2Again)
$ node
> try { let v = require('./jssm-viz.cjs.js'); } catch (e) { console.log(e); }
undefined
>
john@DESKTOP-26H4050 MINGW64 ~/projects/jssm-viz/build (AttemptingVizJs2Again)
Which is ... interesting.
from viz-js.
You can see it here if you're curious.
Load the html
in ./docs/
to see it work correctly in le browseur in iife
cd to ./build
and attempt to load the cjs
in node in the method above to see the kaboom
from viz-js.
oh wait, i think it's trying to append to a document
that doesn't exist, and for some reason that failure is invisible
from viz-js.
hm, no.
okay. sanity check: is this actually expected to work in node?
from viz-js.
It should run in node. Here are the tests if you're curious: https://github.com/mdaines/viz.js/blob/master/test-node/render.js
from viz-js.
oh wow, i'm sorry, i didn't realize this was still open
i solved it around two months later, after trying to switch to a fork then coming back
users of modern rollup can see a working example here
from viz-js.
That's great news
from viz-js.
incidentally i'm an active user of your library with a strong interest in the contemporary version of graphviz, so if you need a guinea pig, please let me know
from viz-js.
Related Issues (20)
- Is synchronous use still possible? HOT 1
- Update viz-js.com to use new version
- Add type definitions HOT 4
- Publish lang-dot package
- Figure out why pkg-config doesn't work as expected for Expat
- Investigate distributing a non-WASM build
- Investigate support for separate WebAssembly instantiation
- Support -x (reduce) option
- Image support in v3 HOT 6
- RuntimeError with long label starting with newline HOT 1
- Android Project HOT 1
- Types can not be imported with current package.json HOT 2
- Dynamic font Family HOT 2
- Strict mode but merge labels HOT 1
- Text not rendering in nodes HOT 11
- Question about usage without Webassembly and some other questions HOT 1
- I need to remove tooltip i.e title for entire graph. How can it be done HOT 4
- Having trouble with new image support - can't use same image URL in two different places HOT 3
- Positions will never change HOT 3
- DockerFile uses Expat 2.5.0 which is vulnerable for CVE-2023-52425 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from viz-js.