Opened 4 years ago
Last modified 3 weeks ago
#2216 new enhancement
Add .mjs to known JS MIME types
Reported by: | Bradley Meck | Owned by: | |
---|---|---|---|
Priority: | minor | Milestone: | |
Component: | other | Version: | 1.19.x |
Keywords: | mime js javascript | Cc: | |
uname -a: | Darwin LM-C02YV4YSLVDR 18.7.0 Darwin Kernel Version 18.7.0: Mon Feb 10 21:08:45 PST 2020; root:xnu-4903.278.28~1/RELEASE_X86_64 x86_64 | ||
nginx -V: | nginx version: nginx/1.19.5 |
Description
I was told to make a ticket here per the mailing list thread: http://mailman.nginx.org/pipermail/nginx-devel/2021-July/014176.html
.mjs is supported by Node.js, is in JS specification examples ( E.G. https://tc39.es/ecma262/#sec-hostresolveimportedmodule ), and WHATWG specification examples ( https://html.spec.whatwg.org/multipage/webappapis.html#integration-with-the-javascript-module-system ), and has an upcoming MIME update per IETF ( https://datatracker.ietf.org/doc/draft-ietf-dispatch-javascript-mjs/ ). It is also supported by various existing MIME databases and serves properly on various hosts like Github Pages without custom configuration.
Change History (6)
comment:1 by , 4 years ago
comment:2 by , 3 years ago
Component: | documentation → other |
---|
comment:3 by , 3 years ago
comment:4 by , 3 years ago
This is now defined by RFC 9239: https://www.rfc-editor.org/rfc/rfc9239 Two changes are needed in the nginx codebase:
- First, the recommended MIME type for JavaScript is now
text/javascript
. - Second, the
.mjs
extension is now explicitly registered.
The patch Maxim already pointed to addresses both points. What can we do to help get it reviewed + merged?
comment:5 by , 3 weeks ago
I recently had to troubleshoot an old nextcloud installation and traced the problem to nextcloud now requiring this mime type.
The apache patch was merged two years ago. Maybe it's time to revisit this issue?
comment:6 by , 3 weeks ago
I also ran into this, and honestly at first had no idea what an mjs
file was, but also found it listed at https://developer.mozilla.org/en-US/docs/Web/HTTP/MIME_types/Common_types and therefore added it to my docker container for my fix, but this would certainly be appreciated to have by default!
Note the project I'm using is not actually node (rather PHP) but it seems a module's authors have pre-built their module creating an mjs output file subsequently used by Drupal. I can't really comment on this approach, but there you have it :P
For the record, a few relevant links:
.mjs
.Overall seems to be only important in Node.js ecosystem, where the
.js
extension means project-default module type, while.mjs
and.cjs
mean ECMAScript and CommonJS modules, respectively. While it might be usable to distinguish modules from scripts in the web, there is no clear difference. It is also not clear if we need to provide support in the default mime.types.