Bug 102019 - *.mjs files should be part of mime application/javascript
Summary: *.mjs files should be part of mime application/javascript
Alias: None
Product: shared-mime-info
Classification: Unclassified
Component: freedesktop.org.xml (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: Shared Mime Info group
QA Contact:
Depends on:
Reported: 2017-08-02 22:18 UTC by Bradley Farias
Modified: 2017-08-07 14:26 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:

patch (1.40 KB, patch)
2017-08-02 22:18 UTC, Bradley Farias
Details | Splinter Review
patch (1.71 KB, patch)
2017-08-07 13:33 UTC, Bradley Farias
Details | Splinter Review

Description Bradley Farias 2017-08-02 22:18:08 UTC
Created attachment 133216 [details] [review]

Javascript Language body is re-using the MIME for a new parse goal:

Used by Node:

Already being merged into other tools:
Comment 1 Bastien Nocera 2017-08-07 12:03:03 UTC
(In reply to Bradley Farias from comment #0)
> Right now whatwg/html#443 is overloading the application/javascript mime type for both script and module goals. This creates ambiguity in node if they share the same file extensions but cause different semantics. I suggest adding application/javascript+module and a different filetype to remove this.

But that's not what you're doing. I also suggest adding a new mime-type that would be a subclass of application/javascript for that purpose.
Comment 2 Bradley Farias 2017-08-07 13:10:19 UTC
Bastien: As shown in the TC39 issue, they will not be using a new MIME type. This can also be seen in the currently being deployed specification for web browsers. See step 7 of https://html.spec.whatwg.org/multipage/webappapis.html#fetch-a-single-module-script . Using a new MIME type would introduce incompatibility from `.mjs` and `.js` when served via a HTTP server using MIME detection.

This needs to stay the main mime type of `application/javascript`. We can discuss why it needs to be the same, but if it is not the same there is little to no reason to add it since it won't be loadable in web browsers.
Comment 3 Bastien Nocera 2017-08-07 13:14:35 UTC
Linking to what action was actually taken would certainly have helped. I'm not that super interested in what ECMA does to follow the links :/

Can you please update the patch to include direct links to the actual result of the discussion? The issue you pointed to is simply marked as closed, and without any labels that could make me think that it was rejected.
Comment 4 Bradley Farias 2017-08-07 13:30:26 UTC
Comment on attachment 133216 [details] [review]

From b234ef886b50d36b3ced839f2a30d7d36e628949 Mon Sep 17 00:00:00 2001
From: Bradley Farias <bradley.meck@gmail.com>
Date: Wed, 2 Aug 2017 17:09:48 -0500
Subject: [PATCH] Add *.mjs glob for Javascript

As used in Node.js related projects.

Web browsers will not be using any new MIME as seen in the MIME check of:


This means `.mjs` should be served with the same MIME to have files work in
both Node.js and the web.
 freedesktop.org.xml.in | 1 +
 tests/esm.mjs          | 2 ++
 tests/list             | 1 +
 3 files changed, 4 insertions(+)
 create mode 100644 tests/esm.mjs

diff --git a/freedesktop.org.xml.in b/freedesktop.org.xml.in
index 645c538..901b686 100644
--- a/freedesktop.org.xml.in
+++ b/freedesktop.org.xml.in
@@ -2424,6 +2424,7 @@ command to generate the output files.
     <glob pattern="*.js"/>
     <glob pattern="*.jsm"/>
+    <glob pattern="*.mjs"/>
   <mime-type type="application/json">
     <_comment>JSON document</_comment>
diff --git a/tests/esm.mjs b/tests/esm.mjs
new file mode 100644
index 0000000..48c2d4a
--- /dev/null
+++ b/tests/esm.mjs
@@ -0,0 +1,2 @@
diff --git a/tests/list b/tests/list
index 9aa40c4..313bb37 100644
--- a/tests/list
+++ b/tests/list
@@ -236,6 +236,7 @@ helloworld.java text/x-java ox
 survey.js application/javascript ox
 # Copied from gecko/accessible/src/jsat/Utils.jsm in Boot2Gecko
 Utils.jsm application/javascript ox
+esm.mjs application/javascript ox
 javascript-without-extension application/javascript xoo
 # The following two copied from RFC 4627.
 json_object.json application/json ox
Comment 5 Bradley Farias 2017-08-07 13:31:51 UTC
Edit as comment appears to make just a comment without editing?
Comment 6 Bradley Farias 2017-08-07 13:33:07 UTC
Created attachment 133291 [details] [review]

add link to HTML spec requirements of JS MIME
Comment 7 Bastien Nocera 2017-08-07 14:26:08 UTC
Pushed to master, thanks!

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.