Skip to content

Add type: "any" #116

Open
Open
@weswigham

Description

@weswigham

Right now, the WHATWG HTML spec makes assertionless imports imply a JS type (that can't be otherwise uttered yet), while json imports use a "json" type, and css imports use a "css" type - there's no type to indicate that you don't care what the type is and fully trust the webserver (or runtime) to tell you what mime to load as (and are OK with the possibly-executable result). A type: "any" would be useful - it would let you import something that at some points in time is a javascript file, and others, a json document or wasm file. It'd also let you write an arbitrary importThing function that can actually import anything, rather than just javascript, eg

function importThing(url) {
  return import(url, {assert: { type: "any" }});
}

right now, if you want to write a function that lets you import arbitrary resources, you need to know the type in advance and pass it along as well, which may not always be the case (and while on the web you could prefetch the resource and then set the type based on the mime received, that'd be inefficient).

Some discussions over on the node repo made me realize that a standardized type indicating that you explicitly didn't actually care about the type might be useful for all runtimes, and not just a useful behavior for node.

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