-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Browser API depends on webpack #8
Comments
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. |
Should be good to go in 2.0.1. |
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 So seems it's hard to implement without breaking backyards compatibility. |
I'll look into this some more this evening most likely. |
I've fixed this in 8c48e49. There's now a new import, 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 |
I tried importing it using
const blake3 = await import('https://unpkg.com/[email protected]/browser.js?module')
and it failed withUncaught ReferenceError: exports is not defined
. Seems the code is a mix of ES modules and CommonJS modules.I also tried importing it using Parcel and it failed with
Imports argument must be present and must be an object
. Checking this issue seems Parcel's WASM importing behavior is different from webpack's. Then, after, I tried importing it using webpack, it worked.Is there a way to make it not dependent on webpack behavior?
The text was updated successfully, but these errors were encountered: