Repository navigation
Being able to do import(blobUrls) #47573
Description
Activity
- addedfeature requestIssues requesting new Node.js features.Issues requesting new Node.js features.
on Apr 15, 2023 - addedesmIssues and PRs related to the ECMAScript Modules implementation.Issues and PRs related to the ECMAScript Modules implementation.
on Apr 15, 2023 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 usesimport x from xyzsyntax
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.jsAnd b/c blob urls are not working via cross threads: #46557
then i had to resort to usingBroadcastChannelto request all threads if they have any references to those blobs.so i guess ☝️ is a blocker...
Reacted by Anton Strogonoff and YAMAMOTO YujiI 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.
- addedstaleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.Issues and PRs marked stale due to inactivity and scheduled for automatic closure.
on Nov 6, 2023 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?
12 remaining items
I’ve been playing with
import()ing blob URls successfully in browsers, but in Node a similar approach still doesn’t work. It’d be useful to have this functionality. It looks like the blocker is Blob support in worker threads?There's only one caveat: parent blob URLs aren't shared with workers. Once that's resolved, this can move forward.
- addedblockedPRs that are blocked by other issues or PRs.PRs that are blocked by other issues or PRs.
on Oct 13, 2024 IIUC, this can't move forward until #54719 is fixed, as it requires that functionality to work.
I suspect I have to tone down my claim on how useful it’d be useful to simply have import work with blobs in my case, and it has to do with imports within the blob.
When in the browser, I can register an import map, and those imports become available to the code I
await import()as a blob URL. However—correct me if I’m wrong—there is no equivalent mechanism of resolving further imports in Node so far. Unless experimental loader import hooks can somehow do it already (which I suspect not, but haven’t gotten around to trying due to the difficulty of registering them since my command is invoked vianpx), it would probably only be possible once import maps are implemented (I know they are on the roadmap for the team working on experimental loader, but I don’t know the status). Maybe I’m wrong?For now when it comes to blob imports + import maps I seem to be able to achieve some parity in Node using the good old
vm, can’t wait to see how things break…github-actions commented
on Apr 13, 2025 on Apr 13, 2025 – with GitHub ActionsContributorMore actionsThere has been no activity on this feature request for 5 months. To help maintain relevant open issues, please add the never-stale
Issues and PRs exempt from automated stale handling. label or close this issue if it should be closed. If not, the issue will be automatically 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.- addedstaleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.Issues and PRs marked stale due to inactivity and scheduled for automatic closure.
on Apr 13, 2025 Is there any clean way to workaround this?
Is there any clean way to workaround this?
Use
vm.SourceTextModule(yourCodeString, { identifier, context }). Requires--experimental-vm-modulesflag but works in Node 22.- removedstaleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.Issues and PRs marked stale due to inactivity and scheduled for automatic closure.
on May 13, 2025 There has been no activity on this feature request for 5 months. To help maintain relevant open issues, please add the never-stale
Issues and PRs exempt from automated stale handling. label or close this issue if it should be closed. If not, the issue will be automatically 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.- addedstaleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.Issues and PRs marked stale due to inactivity and scheduled for automatic closure.
on Nov 9, 2025 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.
reopen
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsIn Progress
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...