Open jimmywarting opened 1 year ago
Does importing a blob work in other JS runtimes? It doesn't seem to in Firefox. Are there WPT tests that cover this?
Are there WPT tests that cover this?
To answer my own question: yes, there are
Does importing a blob work in other JS runtimes?
Yes... i have done it many times in browsers to create dynamic code that i then import...
there are many other developer who dose this too. things like sql.js and JSZip think both are creating a hybrid solution that takes it's own minified source code and create a separate thread in order to not block havy calculations.
kinda like:
function ctx() { ... }
const blob = blob([ctx.toString(), `${ctx.name}()`])
const url = URL.createObjectURL(blob)
import(url)
new Worker(url)
works OK, as long as the function is "pure" and don't references any variable outside of it's own function
But i guess it's a bit unusual to do: import(blobURL)
then to create dynamic web workers.
JSFiddle and other code playgrounds certainly benefit of using import(blobUrl)
if there is code that uses import x from xyz
syntax
I just worked around this issue in my web worker polyfill
I created a custom loader and basically run NodeJS with: node --loader ./resolver.js app.js
And b/c blob urls are not working via cross threads: https://github.com/nodejs/node/issues/46557
then i had to resort to using BroadcastChannel
to request all threads if they have any references to those blobs.
so i guess ☝️ is a blocker...
I could add to that i would also like to be able to do:
const url = URL.createObjectURL(blob)
new worker_threads.Worker(url, { type: 'module' })
but that maybe will be a own issue in itself...
There has been no activity on this feature request for 5 months and it is unlikely to be implemented. It will be closed 6 months after the last non-automated comment.
For more information on how the project manages feature requests, please consult the feature request management document.
There has been no activity on this feature request and it is being closed. If you feel closing this issue is not the right thing to do, please leave a comment.
For more information on how the project manages feature requests, please consult the feature request management document.
@RedYetiDev I would like this as well. All web browsers support this, Deno supports this, Bun supports this. Node is the black sheep
Hey, I don't think I've interacted with this issue yet, was there a specific reason for pinging me?
Hey, I don't think I've interacted with this issue yet, was there a specific reason for pinging me?
It said that you removed this from Node.js feature requests, so I thought you would be the one to contact
Ahh okay, no problem, I was doing a bit of cleanup.
I've been working on this a bit today, and I think I almost have it down. I've assigned myself to prevent other users from doing work thats already been done, I'd hate to see anyone's time go to waste.
What is the problem this feature will solve?
tried doing:
but failed with:
What is the feature you are proposing to solve the problem?
being able to import dynamic generated code...
What alternatives have you considered?
converting it to a
data:
url works as a work around...