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 blob/Object URLs for workers #9210

Closed
kitsonk opened this issue Jan 21, 2021 · 1 comment · Fixed by #10045
Closed

Support blob/Object URLs for workers #9210

kitsonk opened this issue Jan 21, 2021 · 1 comment · Fixed by #10045
Labels
runtime Relates to code in the runtime crate suggestion suggestions for new features (yet to be agreed)

Comments

@kitsonk
Copy link
Contributor

kitsonk commented Jan 21, 2021

Deno should support blob/Object URLs for workers.

For example the following should work:

const src = new Blob([`console.log("hello deno");`]);
new Worker(URL.createObjectURL(src), { type: "module" });

This is splitting off from #5683 as it far more than allowing the blob: protocol. This is because we do all the processing of modules/worker scripts inside Rust. This means we expect the specifier to be fully resolvable inside of Rust. For http/https URLs we go and fetch the resources in Rust. For file URLs we have a whole string which we can decode to provide us the module text. With Object URLs, the actual content is still located in JavaScript isolate/sandbox, so it means for these Object URLs, we need to serialise them to a string before passing them out to Rust and then deal with them there. This is more complex than simply passing out a string.

It also means it won't work for things like import and export, because these need to be fully statically analysed before they are loaded. We might be able to get it for dynamic import() but it would require doing some gymnastics in rusty_v8, because import() is syntax, not a runtime construct.

Because of all of these challenges it goes from "yeah sure, makes sense" to "hmmm... we need to think about it".

@johnspurlock
Copy link
Contributor

This is great for my use case, thanks!

But how do I add sourcemaps to make the debugging experience sane?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
runtime Relates to code in the runtime crate suggestion suggestions for new features (yet to be agreed)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants