Giter Club home page Giter Club logo

Comments (5)

connor4312 avatar connor4312 commented on August 18, 2024 1

I've fixed this in 8c48e49.

There's now a new import, blake3/browser-async, that exports an function which returns a promise that resolves to the module.

import load from 'blake3/browser-async';

load().then(blake3 => {
  console.log(blake3.hash('hello world'));
});

I expanded the integration tests to test both Webpack and a plain <script type="module"> import.

from blake3.

connor4312 avatar connor4312 commented on August 18, 2024

Good issue. I didn't bother having an entirely separate, pure ES module tree here like I normally do because wasm is not tree shakable anyway. But I didn't recognize that that would trip up non-Webpack bundlers. Will make a patch release this evening or tomorrow.

from blake3.

connor4312 avatar connor4312 commented on August 18, 2024

Should be good to go in 2.0.1. ./browser.js now points to an esm build. Let me know if you run into any more problems, happy hashing.

from blake3.

qgustavor avatar qgustavor commented on August 18, 2024

I just want to note that making it a ESM build just makes it easier to be imported into browsers without requiring a bundler, in the other hand it don't solves the issue.

The issue is that blake3_js.js imports "blake3_js_bg.wasm" as a ES module and it is not standardized yet, so browsers don't support it and some bundlers handle it in different ways than Webpack.

"blake3_js.js" is generated using wasm-pack and seems it don't support Parcel. You can use --target web, which will create a module that already handles WASM loading without depending on the bundler implementation, but then you need to initialize the module manually.

So seems it's hard to implement without breaking backyards compatibility.

from blake3.

connor4312 avatar connor4312 commented on August 18, 2024

I'll look into this some more this evening most likely.

from blake3.

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.