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

Support Web Workers #519

Open
JustAnotherJavaProgrammer opened this issue Mar 23, 2023 · 0 comments
Open

Support Web Workers #519

JustAnotherJavaProgrammer opened this issue Mar 23, 2023 · 0 comments

Comments

@JustAnotherJavaProgrammer

I don't know if this is the right place to post this, but here is my problem:

I am using vite-imagetools with sveltekit. I also use pdf-lib to generate PDFs inside a Web Worker. To get image URLs for embedding, I import the images like so:

// @ts-ignore
import oldPaper from "$lib/assets/img/certificate/kiwihug-3gifzboyZk0-unsplash.jpg?rotate=270";
import coatOfArms from "$lib/assets/img/certificate/coat_of_arms.png";

After building the project, this results in the following lines in the output:

var aM = "" + new URL("assets/kiwihug-3gifzboyZk0-unsplash-0925bf36.jpg?rotate=270",document.currentScript && document.currentScript.src || document.baseURI).href
      , oM = "" + new URL("assets/coat_of_arms-a692f603.png",document.currentScript && document.currentScript.src || document.baseURI).href;

This obviously fails, as Web Workers have no document:

Uncaught ReferenceError: document is not defined

Apart from putting these files in my static directory and essentially bypassing imagetools entirely, what can I do?

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

1 participant