Skip to content

Async createObjectURL #84

Closed
Closed
@bmeck

Description

@bmeck

createObjectURL is unable to generate circular dependencies for ECMAScript Modules due to URLs requiring their content be given at time of creation. This leads to a problem when trying to recreate this file using createObjectURL:

// a.mjs
import './a.mjs';

It seems that there is no way to generate the URL for the import statement since it is returned from createObjectURL.

I would propose there be an async form or controller for this. I am not tied to any given API but can imagine something like:

// bikeshed method name, doesn't matter to me
const url = URL.createAsyncURL((async () => {
  await; // make sure `url` exists by waiting a tick
  return new Blob([`import ${url};`], {type: 'text/javascript'});
})());

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions