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.

esm import breaks in web worker

See original GitHub issue

Ethers Version

5.6.esm.min.js

Search Terms

es6 esm import web worker

Describe the Problem

importing ethers in web worker throws exceptions about missing window object

expected behavior: use ethers inside web worker to improve CPU efficiency while rendering UI Screen Shot 2022-05-11 at 11 57 28 PM

Code Snippet

// web_worker.js
import { ethers } from './ethers-5.6.esm.min.js';

Temp work around ?

// ethers-5.6.esm.min.js
var window = self;  

Contract ABI

No response

Errors

No response

Environment

No response

Environment (Other)

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
ricmoocommented, May 21, 2022

This should be fixed in 5.6.7. Please try it out and let me know.

Thanks! 😃

2reactions
ricmoocommented, May 20, 2022

I’ve confirmed this issue. Researching how to fix it now, as the dust files are generated by rollup; there is likely some config to make this play nicely with others.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Web Workers - How To Import Modules - Stack Overflow
So, my question is, how do we use the new import module syntax with workers? Second question is, what does importScripts import into...
Read more >
import - JavaScript - MDN Web Docs - Mozilla
The static import declaration is used to import read-only live bindings which are exported by another module. The imported bindings are ...
Read more >
164860 – JS Modules in Workers - WebKit Bugzilla
I am crafting a web workers driven ES8 framework, so module support for workers (including dynamic imports) is one of the key features...
Read more >
workers | API Reference | ArcGIS Maps SDK for JavaScript 4.25
ESM : import * as workers from "@arcgis/core/core/workers"; ... This module is a utility framework that simplifies the use of Web Workers in...
Read more >
Web workers, React, and TypeScript - LogRocket Blog
Let's break it down a bit. First, we begin by disabling the error that says we've used self incorrectly. Next, we'll import the...
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