question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Browser API depends on webpack

See original GitHub issue

I tried importing it using const blake3 = await import('https://unpkg.com/blake3@2.0.0/browser.js?module') and it failed with Uncaught 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?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
connor4312commented, Feb 12, 2020

I’ve fixed this in https://github.com/connor4312/blake3/commit/8c48e49f7747b86101c8eb79876d9daf9254ebc9.

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.

0reactions
connor4312commented, Jan 27, 2020

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Concepts - webpack
webpack is a module bundler. Its main purpose is to bundle JavaScript files for usage in a browser, yet it is also capable...
Read more >
Using Webpack for API development! - DEV Community ‍ ‍
A simple explanation of Webpack, what it does for you and why and how you could use it to build an Express API...
Read more >
Browser Extension Webpack Boilerplate - GitHub
Google Chrome; Chromium; Mozilla Firefox; Firefox for Android; Opera; Microsoft Edge. Actual compatibility will depend on the APIs you used. MDN provides a ......
Read more >
How I can provide an api url to my library that is run via the ...
A good approach is for the config.js to be aqutogenerated via webpack or gulp. In my case I use the gulp tool to...
Read more >
Bundling Extensions - Visual Studio Code
Bundling Visual Studio Code extensions (plug-ins) with webpack. ... When VS Code is running in the browser, it can only load one file...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found