Bug 61383 (MJS) - *.mjs files should be part of mime text/javascript
Summary: *.mjs files should be part of mime text/javascript
Status: RESOLVED FIXED
Alias: MJS
Product: Apache httpd-2
Classification: Unclassified
Component: mod_mime (show other bugs)
Version: 2.5-HEAD
Hardware: PC Mac OS X 10.1
: P2 normal (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
URL: https://github.com/apache/httpd/pull/318
Keywords: PatchAvailable
Depends on:
Blocks:
 
Reported: 2017-08-04 16:17 UTC by Bradley Farias
Modified: 2022-07-07 12:32 UTC (History)
2 users (show)



Attachments
Attaching patch from https://github.com/apache/httpd/pull/318 (1.63 KB, patch)
2022-05-23 08:58 UTC, Mathias Bynens
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Bradley Farias 2017-08-04 16:17:32 UTC
Javascript Language body is re-using the MIME for a new parse goal:
https://github.com/tc39/ecma262/issues/322

Used by Node:
https://github.com/nodejs/node-eps/blob/6cc060e94e56859bdb446a0820ef4704731ff0a8/002-es-modules.md
https://github.com/nodejs/node/pull/14369

Already being merged into other tools:
https://github.com/Microsoft/vscode/pull/25747
Comment 1 Jacob Champion 2017-08-04 18:46:26 UTC
Thanks for the heads up! Based on those links, I think this needs to be baked a little bit more before we add it to the official mime.types. You've linked to a draft proposal, and IMO it belongs in httpd after it's standardized and/or in wide use.

In the meantime, server admins are welcome to adjust the mime.types themselves if they need it, so we're not obstructing the rollout.
Comment 2 Bradley Farias 2017-08-04 19:02:53 UTC
What level of support are you needing. If I move the draft to accepted is that enough? Is the merged PR for node needed if not? This issue is being brought up because it was a web compatiblity concern where people cannot use the same files due to lack of MIME support.

Would written statements from browser vendors sway anything?
Comment 3 Jacob Champion 2017-08-04 19:36:38 UTC
(In reply to Bradley Farias from comment #2)
> What level of support are you needing. If I move the draft to accepted is
> that enough?
Now you have me worried/confused. Is that document you linked to binding in any way on the Javascript community? Do you have the power to "accept" it yourself -- and if so, should we use it as proof of standardization? ;D

My point is not that we should meet an arbitrary milestone that I'd be making up on the spot, but that we should feel like the types we add are actually standards (either de facto or otherwise). The stuff you've linked to highlights relatively recent arguments over whether a new MIME suffix should be registered, whether the extension should be .mjs or .jsm, etc.

IMO we should add this to httpd once the world says "yes, *this* is how it is." Which does imply a slight bit of lag time.

> This issue is being
> brought up because it was a web compatiblity concern where people cannot use
> the same files due to lack of MIME support.
Right. Server admins have full power over their mime.types, and if they need their servers to support this, they don't have to wait for us. We're not blocking early adoption as far as I can tell.

> Would written statements from browser vendors sway anything?
Sure, it'd certainly give us a better idea of who intends to make use of this.

Keep in mind that I am not the sole gatekeeper for this. If, at any point, an httpd dev is convinced, then in all likelihood it's going in. I'm just saying that I'm not personally convinced *yet*.
Comment 4 Eric Covener 2017-08-05 01:42:21 UTC
IIUC the bar for httpd to list a type is registration in IANA, but the bar for adding an extension to an existing type is to show it in common use (assuming it's not already in use elsewhere) or present in some standard.

https://www.iana.org/assignments/media-types/media-types.xml

Where we'd normally look to confirm an extension:
https://www.iana.org/assignments/media-types/application/javascript

I didn't find the specific references here too compelling but someone else might be more familiar/comfortable with it.
Comment 5 Bradley Farias 2020-06-15 20:58:19 UTC
Considering Node 12+ now uses the .mjs MIME publicly and it is present even in WHATWG's HTML specification for clarity https://github.com/whatwg/html/pull/3810 how would I go about bumping this issue?
Comment 6 Bradley Farias 2020-10-20 13:31:38 UTC
The ECMAScript specification itself now has a reference to .mjs https://tc39.es/ecma262/#sec-hostresolveimportedmodule
Comment 7 Bradley Farias 2021-04-07 18:43:15 UTC
Bringing this up again, lots of tools use this and Node's ESM is no longer experimental.
Comment 8 Quentin Grimaud 2021-10-09 22:16:13 UTC
A few more links in favour of .mjs extension:

- https://v8.dev/features/modules#mjs
- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules#aside_%E2%80%94_.mjs_versus_.js

As a proof of adoption, this last link mentions "Servers that already serve .mjs files correctly include GitHub Pages and http-server for Node.js."
Comment 9 Mathias Bynens 2022-03-09 08:07:27 UTC
(In reply to Eric Covener from comment #4)
> IIUC the bar for httpd to list a type is registration in IANA, but the bar
> for adding an extension to an existing type is to show it in common use
> (assuming it's not already in use elsewhere) or present in some standard.
> 
> https://www.iana.org/assignments/media-types/media-types.xml
> 
> Where we'd normally look to confirm an extension:
> https://www.iana.org/assignments/media-types/application/javascript
> 
> I didn't find the specific references here too compelling but someone else
> might be more familiar/comfortable with it.

The media type registry at https://www.iana.org/assignments/media-types/media-types.xhtml has been updated and now explicitly includes the .mjs extension for the text/javascript media type.

The link you referenced, https://www.iana.org/assignments/media-types/application/javascript, now shows that application/javascript is OBSOLETE (in favor of text/javascript).

The relevant entry to look at is https://www.iana.org/assignments/media-types/text/javascript, which now explicitly lists both the .js and .mjs extensions.
Comment 10 Mathias Bynens 2022-03-09 08:44:03 UTC
I’ve prepared a patch here: https://github.com/apache/httpd/compare/trunk...mathiasbynens:fix-js-mime-and-extensions?expand=1

I’ll hold off on sending a PR until the RFC has officially been published (which should be soon).
Comment 11 Mathias Bynens 2022-05-08 07:57:23 UTC
RFC 9239 is now published, making this official: https://www.rfc-editor.org/rfc/rfc9239

Pull request is up: https://github.com/apache/httpd/pull/318 Please take a look.
Comment 12 Mathias Bynens 2022-05-23 08:58:26 UTC
Created attachment 38299 [details]
Attaching patch from https://github.com/apache/httpd/pull/318
Comment 13 Mathias Bynens 2022-07-07 12:32:57 UTC
The PR has been merged. I guess this issue can be closed now?