Skip to content

request/load/identify #2

Description

@tolmasky
  1. request (URL) -> Response { status, headers, body }
    a. If Response contains Content-Type, then done.
    b. Otherwise, fall into Content-Type identifier, which for most cases, is auto-generated from supplied file extension to mime-type mapping
    c. However, if you supply a custom identify function or whatever, then you are given (URL, bytes) and can return mime-type or false.
  2. identify returns a Content-Type given (URL, bytes). By default this function is automatically generated from the file extension to mime-type mapping. But something like Dockerfiles need custom logic (and only needs to URLs), but imagine a shell script, which would determine the Content-Type based on the first line of the file.
    a. Or should it be headers, where it is { Content-Type: }, but could include additional headers, such as x-ecma-goal-symbol: "module" or "script".
  3. load(Response: { headers: { Content-Type } }, body) -> { source, type, exports? }

Nice to be able to access load from outside import.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions