from Hacker News

Recommendations when publishing a WASM library

by comagoosie on 3/28/22, 10:54 AM with 19 comments

  • by jitl on 3/28/22, 1:23 PM

    Wow, this is a great resource! I’ve been dealing with a lot of these issues with a JS sandbox library I’m building quickjs-emecripten. I want to offer a ton of different build variants of my core WASM file. Here’s what I tried: https://github.com/justjake/quickjs-emscripten/blob/master/t...

    This approach works great for NodeJS, but once I ran a test bundle I found that Webpack (and bundlephobia) included all the base64 “release” variants instead of lazy-loading the import statements. Bummer. I assumed this because Typescript on its own compiled import to Promise.resolve(require(…)), so it’s good to know that most bundlers will STILL get this wrong even if I’m emitting ES6 module import syntax. Yikes! I need to bite the bullet and start using Rollup to emit a slew of separate entry points. Oy veh.

    Anyways A+++ would read again. This will save me 4-5 days of work stubbing my toe on bundlers and build system which is the Least Fun part of JS work.

  • by Shadonototra on 3/28/22, 12:15 PM

    Security wise, it is not a good idea to consume WASM libraries "as is", ask for the source, read it, and compile it yourself

    You don't want to be in a position to ship code to production with binary code that could potentially be harmful

    Off topic: Please don't mess up the way my browser scroll pages, it is infuriating

  • by modeless on 3/28/22, 3:21 PM

    I really hate that base64 is the best option for embedding inline assets in HTML/JS files. Have there been any proposals to add real heredoc support to HTML/JS? With the ability to choose delimiters and support for unrestricted binary data?
  • by kylebarron on 3/28/22, 4:13 PM

    Looks to be a great resource. I've been working on a WASM implementation of reading and writing Apache Parquet [0] and it's been difficult being new to WASM to find the best way of distributing the WASM that works on Node and through bundlers like Webpack.

    [0]: https://github.com/kylebarron/parquet-wasm

  • by westurner on 3/28/22, 2:03 PM

    conda: "Adding a WebAssembly platform" https://github.com/conda/conda/issues/7619

      pyodide.loadPackage("numpy");
     
      pyodide.loadPackage("https://foo/bar/numpy.js");
      
    
      #  import micropip
     
     micropip.install('https://example.com/files/snowballstemmer-2.0.0-py2.py3-none-any.whl')
    
    "Creating a Pyodide package" > "2. Creating the meta.yaml file" https://pyodide.org/en/stable/development/new-packages.html#...

    conda-forge: "WASM as a supported architecture" https://github.com/conda-forge/conda-forge.github.io/issues/...

  • by kansface on 3/28/22, 4:06 PM

    Does anyone have practical experience running WASM in long running processes on node, as compared to something like Neon? Writing C in TS doesn't look particularly appealing to me, but node extensions bring their own set of problems.