jshttp / mime-db

Media Type Database
MIT License
1.11k stars 256 forks source link

Correct JavaScript MIME types + extensions per RFC 9239 #262

Closed mathiasbynens closed 2 years ago

mathiasbynens commented 2 years ago

This patch updates the MIME type configuration per RFC 9239. https://www.rfc-editor.org/rfc/rfc9239

First, the recommended MIME type is now text/javascript:

The most widely supported media type in use is text/javascript; all others are considered historical and obsolete aliases of text/javascript.

Second, the .mjs extension is now explicitly registered:

The .mjs file extension signals that the file represents a JavaScript module. Execution environments that rely on file extensions to determine how to process inputs parse .mjs files using the Module grammar of [ECMA-262].

(mime-db already included the .mjs extension prior to this patch, so no change needed here.)

IANA template: https://www.iana.org/assignments/media-types/text/javascript

mathiasbynens commented 2 years ago

Related PRs:

mathiasbynens commented 2 years ago

@dougwilson Thanks. It looks like it’s been a while since the scripts have been run, since there are a bunch of changes unrelated to this new RFC. I also noticed that some tweaks to the scripts are required in order to even pick up the new RFC.

Here’s what I think we should do, in order:

dougwilson commented 2 years ago

So the npm run build script just takes the contents from src/ and puts them in to db.json. This is the only script I was mentioning above, and no matter how long between runs, it will still always produce the same db.json for the same src/ contents. That said, I think you are talking about the npm run update script instead of the one I mentioned. You're right -- it seems like the automated job I had for it stopped committed because the GH token I had for it was deleted by me by accident. I just created a new one and it's back up and running 🎉 .

mathiasbynens commented 2 years ago

Thanks @dougwilson! It looks like https://github.com/jshttp/mime-db/commit/c8e4e30da4571d55003f7d582ce4cd7080ab26b0 picks up the upstream text/javascript changes 🎉 What’s still missing is the extensions property set to [".js", ".mjs"] (even though both extensions are explicitly listed in the IANA registrations). I’ve updated this PR to fix that by adding it to custom-types.json.