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

request/load/identify #2

Open
tolmasky opened this issue Nov 19, 2022 · 0 comments
Open

request/load/identify #2

tolmasky opened this issue Nov 19, 2022 · 0 comments

Comments

@tolmasky
Copy link

tolmasky commented Nov 19, 2022

  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.

@tolmasky tolmasky changed the title request/load request/load/identify Nov 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant