Skip to content

Just reporting two libs I tried to use that didn't work for me 😉 (elkjs & netlistsvg) #4213

Open
@akavel

Description

@akavel

Describe the bug
I wanted to try if I could use boa in my statically generated blog, to render circuit diagrams using two open-source JS libs (netlistsvg + elkjs), which IIUC seem quite self-contained when taken as a pair. I'm not sure how to do this with the CLI, and also at least one of them seems to throw an error.

To Reproduce

$ cargo install --version 0.20.0 boa_cli
$ curl -O https://unpkg.com/[email protected]/built/netlistsvg.bundle.js
$ curl -O https://unpkg.com/[email protected]/lib/elk.bundled.js
$ boa elk.bundled.js
undefined
$ # ok, this seemed to kinda work; can I use it as a module? is this the way?
$ boa -m elk.bundled.js
Uncaught TypeError: cannot convert 'null' or 'undefined' to object
$ # uh, this didn't seem to go well :( let's see what happens if I try netlistsvg:
$ boa netlistsvg.bundle.js
Uncaught TypeError: not a constructor
$ # oops, this didn't seem to work even without -m :(
$ # also, how can I then use those from a non-module script? should I use -m or not use -m?

Expected behavior

  1. no Uncaught TypeError lines

  2. some example in --help how can I run a simple script with those libraries - for example, I could imagine something like:

    $ boa --require elk=elk.bundled.js --require netlistsvg=netlistsvg.bundle.js --expression "netlistsvg.render(netlistsvg.digitalSkin, netlistsvg.exampleDigital, (err, result) => console.log(result));"
    

Build environment (please complete the following information):

  • OS: Windows
  • Version: 10
  • Target triple: ?
  • Rustc version: rustc 1.85.0 (4d91de4e4 2025-02-17)

Additional context

netlistsvg simple call example via script tag: https://github.com/nturley/netlistsvg?tab=readme-ov-file#web-bundle

<script type="text/javascript" src="https://nturley.github.io/netlistsvg/elk.bundled.js"></script>
<script type="text/javascript" src="https://nturley.github.io/netlistsvg/built/netlistsvg.bundle.js"></script>
netlistsvg.render(netlistsvg.digitalSkin, netlistsvg.exampleDigital, (err, result) => console.log(result));

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions