Skip to content
This repository was archived by the owner on Sep 2, 2023. It is now read-only.
This repository was archived by the owner on Sep 2, 2023. It is now read-only.

MIME types #146

Closed
Closed
@demurgos

Description

@demurgos

Hi,
I want to open an issue dedicated to MIME types. MIME types are mentioned fairly often in the issue #142 but their relevance is not entirely clear for me. Since the other issue is already extremely long, I prefer to open a separate issue.

I would like a clarification about the relation between MIME types, ESM and Node.

Here is what I currently understand, please correct anything wrong and provide more details to clarify the role of MIME types.

  • The authoritative source for MIME types for scripting files is RFC4329
  • There is a pending update for this RFC: ECMAScript Media Types Updates
  • The default MIME type for .js is text/javascript
  • A file loaded by <script src=...> or <script type="module" src=...> can be served with any MIME type, browsers don't care: <script src=...> will use the Script goal, <script type="module" src=...> will use the Module goal.
  • Browser will also ignore the MIME type of transitive dependencies of ESM (static or dynamic import) and treat these dependencies as ESM (even if they are obviously not: example application/wasm)
  • Node uses internally the MIME type application/node for the script file (for which extensions: .js, .mjs, .node?!). Where is it used? Why? Are servers supposed to serve files with this MIME type?
  • The IETF proposal recommends the same MIME type (text/javascript) for both .js and .mjs.
  • The IETF proposal recommends the use of the optional goal parameter for the parse goal. So files with the Module goal can be served using text/javascript;goal=Module, files with the script goal can be served with the text/javascript;goal=Script MIME type.
  • The IETF proposal recommends .mjs to mean text/javascript;goal=Module
  • The browsers don't care about the goal MIME parameter currently.
  • There is a PR so if the goal parameter is present, the browsers must error if the goal used by the browser does not match the goal served by the server.

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