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

Parcel 2 compatibility #319

Open
lgarron opened this issue Nov 20, 2020 · 13 comments
Open

Parcel 2 compatibility #319

lgarron opened this issue Nov 20, 2020 · 13 comments

Comments

@lgarron
Copy link

lgarron commented Nov 20, 2020

I've been scratching my head about how to build compatible workers, and this library is the most promising so far! Unfortunately, I use Parcel 2, and the basic demo runs into an error. 😢

auth.bd78dd40.js:1 Uncaught DOMException: Failed to execute 'importScripts' on 'WorkerGlobalScope': The URL './index.d6afe8b1.js' is invalid.
    at http://localhost:1234/auth.bd78dd40.js:1:1
    at blob:http://localhost:1234/13b36260-4ae6-4c43-845c-0dfccc529f9c:1:1

I thought I found a reference suggesting that you can't use this kind of relative path from a blob, but Parcel 2 can definitely handle workers in general (e.g. libraries like comlink work with parcel server). However, I can't seem to find that again.

I'd really like to use threads.js, but this is a big blocker for our use case. Any thoughts on where best to attempt to address this?

@andywer
Copy link
Owner

andywer commented Nov 20, 2020

Hey @lgarron!
Is the importScripts() call part of your worker code or is it threads.js that adds it?

@lgarron
Copy link
Author

lgarron commented Nov 20, 2020

Hey @lgarron!
Is the importScripts() call part of your worker code or is it threads.js that adds it?

This is with the sample code, so it's either threads.js or Parcel 2 that adds it!

Here's a repro, which is basically the sample code:
https://github.com/lgarron/parcel-2-threads-repro

node master.js works in that repro, but npx parcel index.html runs into the error above.

@lgarron
Copy link
Author

lgarron commented Dec 5, 2020

Anything simple I could do to help debug this?

@andywer
Copy link
Owner

andywer commented Dec 5, 2020

Hmm, good question. Could you post the line with the failing importScripts() and the surrounding couple of lines?

Unfortunately I've already got a quite extensive backlog, so I'm afraid I won't have much time to look into this. If we can figure out the root of the issue, I could quickly prepare a fix, though.

@simplecommerce
Copy link

@lgarron long shot here but have you gotten it to work? I am having the same issue when I try to do a test using a simple function that returns a string and nothing seems to happen.

@lgarron
Copy link
Author

lgarron commented Jan 27, 2021

Unfortunately not. I've given up on having a good development flow for web workers while several Parcel issues are still outstanding:

parcel-bundler/parcel#5504
parcel-bundler/parcel#5473
parcel-bundler/parcel#3959

I'm hoping to give it another try once those issues are in a better place.

@lgarron
Copy link
Author

lgarron commented Jan 27, 2021

Also, the lack of module workers in Firefox/Safari is a real pain, along with some other things that are hard for Parcel and this library to work around:

https://github.com/lgarron/web-worker-compat-problems

@ProLoser
Copy link

Are you on nightly or next? Nightly fixes some of the module resolution logic but importing the same dependency from different webworkers creates bundling issues at the moment I think.

@lgarron
Copy link
Author

lgarron commented Jan 30, 2021

Are you on nightly or next? Nightly fixes some of the module resolution logic but importing the same dependency from different webworkers creates bundling issues at the moment I think.

Ooooh, the latest nightly fixes https://github.com/lgarron/parcel-2-threads-repro

(The bundling issues are still a blocker for me, though.)

@ProLoser
Copy link

parcel-bundler/parcel#5430 I'm trying to get audio worklet detection working, if I can just login to opencollective and sponsor them for their hard work lol.

@andywer
Copy link
Owner

andywer commented Jan 31, 2021

Great to see you all are looking into this!
I tried getting threads.js to work with Parcel 2 like one and a half years ago or so, but I gave up at some point as I would have needed to spend much more time on this and a lot of Parcel 2 felt very early stage back then.

I was hoping that by now they would have fixed most of the issues, though. Maybe not (yet)…

@ProLoser
Copy link

What solution did you end up with? I hate how much of my life is wasted on build pipelines

@andywer
Copy link
Owner

andywer commented Jan 31, 2021

We just kept using Parcel v1 😄

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

No branches or pull requests

4 participants