Git Product home page Git Product logo

Comments (16)

mdaines avatar mdaines commented on June 2, 2024 1

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.

mdaines avatar mdaines commented on June 2, 2024 1

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.

mdaines avatar mdaines commented on June 2, 2024 1

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.

mdaines avatar mdaines commented on June 2, 2024 1

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.

mdaines avatar mdaines commented on June 2, 2024

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.

StoneCypher avatar StoneCypher commented on June 2, 2024

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.

StoneCypher avatar StoneCypher commented on June 2, 2024

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.

StoneCypher avatar StoneCypher commented on June 2, 2024

You're very generous with your time 😁

TYVM

from viz-js.

StoneCypher avatar StoneCypher commented on June 2, 2024

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.

StoneCypher avatar StoneCypher commented on June 2, 2024

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.

StoneCypher avatar StoneCypher commented on June 2, 2024

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.

StoneCypher avatar StoneCypher commented on June 2, 2024

hm, no.

okay. sanity check: is this actually expected to work in node?

from viz-js.

mdaines avatar mdaines commented on June 2, 2024

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.

StoneCypher avatar StoneCypher commented on June 2, 2024

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.

StoneCypher avatar StoneCypher commented on June 2, 2024

That's great news

from viz-js.

StoneCypher avatar StoneCypher commented on June 2, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.