Skip to content
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

web-worker example doesn't work #26

Closed
VirtualTim opened this issue Aug 27, 2019 · 2 comments
Closed

web-worker example doesn't work #26

VirtualTim opened this issue Aug 27, 2019 · 2 comments

Comments

@VirtualTim
Copy link

VirtualTim commented Aug 27, 2019

The web-worker example (https://shimport-demos.surge.sh/web-worker/) no longer works.
The evaluate function:

function evaluate(code: string) {

uses document.createElement, however document is obviously not available in a worker.
This causes the promise to be be rejected with: shimport.js Uncaught (in promise) ReferenceError: document is not defined.

Edit: looks like 0.0.14 was the last version where this worked.

@VirtualTim
Copy link
Author

I think swapping typeof URL !== 'undefined'

if (typeof URL !== 'undefined') {

with typeof document !== 'undefined' fixes this, although obviously you don't get the ability to debug the eval'd scripts. But better that than not working at all, right?

@Rich-Harris
Copy link
Owner

Only took a year and a bit, but this is fixed in 2.0.3. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants