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
Description
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
istext/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: exampleapplication/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 usingtext/javascript;goal=Module
, files with the script goal can be served with thetext/javascript;goal=Script
MIME type. - The IETF proposal recommends
.mjs
to meantext/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
Labels
No labels