From 00558b5d0714eb7c357efa569f8868244330becf Mon Sep 17 00:00:00 2001 From: John Franey <1728528+johnfraney@users.noreply.github.com> Date: Mon, 3 Nov 2025 04:36:51 -0400 Subject: [PATCH 1/5] Add .cjs mimetype to common_types Adds .cjs mimetype of `text/javascript` for CommonJS modules to common_types. See here for more information: https://nodejs.org/api/modules.html#enabling --- Lib/mimetypes.py | 1 + .../2025-11-04-12-18-06.gh-issue-140942.GYns6n.rst | 2 ++ 2 files changed, 3 insertions(+) create mode 100644 Misc/NEWS.d/next/Core_and_Builtins/2025-11-04-12-18-06.gh-issue-140942.GYns6n.rst diff --git a/Lib/mimetypes.py b/Lib/mimetypes.py index 48a9f430d45262..b155b0964f52f2 100644 --- a/Lib/mimetypes.py +++ b/Lib/mimetypes.py @@ -681,6 +681,7 @@ def _default_mime_types(): # Please sort these too common_types = _common_types_default = { + '.cjs' : 'application/node', '.rtf' : 'application/rtf', '.apk' : 'application/vnd.android.package-archive', '.midi': 'audio/midi', diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2025-11-04-12-18-06.gh-issue-140942.GYns6n.rst b/Misc/NEWS.d/next/Core_and_Builtins/2025-11-04-12-18-06.gh-issue-140942.GYns6n.rst new file mode 100644 index 00000000000000..f35423802e94bd --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2025-11-04-12-18-06.gh-issue-140942.GYns6n.rst @@ -0,0 +1,2 @@ +Add .cjs extension to common_types to give CommonJS modules a mimetype of +"application/node" From 71266e9f642822cf4c058d85f6f588b20a82a7a0 Mon Sep 17 00:00:00 2001 From: John Franey <1728528+johnfraney@users.noreply.github.com> Date: Fri, 7 Nov 2025 19:13:32 +0700 Subject: [PATCH 2/5] fix: move .cjs to default mimetypes --- Lib/mimetypes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/mimetypes.py b/Lib/mimetypes.py index b155b0964f52f2..d6896fc4042cb4 100644 --- a/Lib/mimetypes.py +++ b/Lib/mimetypes.py @@ -486,6 +486,7 @@ def _default_mime_types(): '.wiz' : 'application/msword', '.nq' : 'application/n-quads', '.nt' : 'application/n-triples', + '.cjs' : 'application/node', '.bin' : 'application/octet-stream', '.a' : 'application/octet-stream', '.dll' : 'application/octet-stream', @@ -681,7 +682,6 @@ def _default_mime_types(): # Please sort these too common_types = _common_types_default = { - '.cjs' : 'application/node', '.rtf' : 'application/rtf', '.apk' : 'application/vnd.android.package-archive', '.midi': 'audio/midi', From 03c1f8a8e654c082f8e5e32ece7ee624310b5598 Mon Sep 17 00:00:00 2001 From: John Franey <1728528+johnfraney@users.noreply.github.com> Date: Fri, 7 Nov 2025 19:15:57 +0700 Subject: [PATCH 3/5] chore: update news entry --- .../2025-11-04-12-18-06.gh-issue-140942.GYns6n.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2025-11-04-12-18-06.gh-issue-140942.GYns6n.rst b/Misc/NEWS.d/next/Core_and_Builtins/2025-11-04-12-18-06.gh-issue-140942.GYns6n.rst index f35423802e94bd..4ea6686ac73202 100644 --- a/Misc/NEWS.d/next/Core_and_Builtins/2025-11-04-12-18-06.gh-issue-140942.GYns6n.rst +++ b/Misc/NEWS.d/next/Core_and_Builtins/2025-11-04-12-18-06.gh-issue-140942.GYns6n.rst @@ -1,2 +1,2 @@ -Add .cjs extension to common_types to give CommonJS modules a mimetype of +Add .cjs to mimetypes to give CommonJS modules a mimetype of "application/node" From 8691cee055996b0cf57158d54fef1a67da297198 Mon Sep 17 00:00:00 2001 From: John Franey <1728528+johnfraney@users.noreply.github.com> Date: Sat, 8 Nov 2025 03:35:15 -0400 Subject: [PATCH 4/5] Update Misc/NEWS.d/next/Core_and_Builtins/2025-11-04-12-18-06.gh-issue-140942.GYns6n.rst Add changes to news entry from code review Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> --- .../2025-11-04-12-18-06.gh-issue-140942.GYns6n.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2025-11-04-12-18-06.gh-issue-140942.GYns6n.rst b/Misc/NEWS.d/next/Core_and_Builtins/2025-11-04-12-18-06.gh-issue-140942.GYns6n.rst index 4ea6686ac73202..20cfeca1e71dca 100644 --- a/Misc/NEWS.d/next/Core_and_Builtins/2025-11-04-12-18-06.gh-issue-140942.GYns6n.rst +++ b/Misc/NEWS.d/next/Core_and_Builtins/2025-11-04-12-18-06.gh-issue-140942.GYns6n.rst @@ -1,2 +1,2 @@ -Add .cjs to mimetypes to give CommonJS modules a mimetype of -"application/node" +Add ``.cjs`` to :mod:`mimetypes` to give CommonJS modules a MIME type of +``application/node``. From 956763c54f097c781bb43b4d6932ed7893d5ab02 Mon Sep 17 00:00:00 2001 From: John Franey <1728528+johnfraney@users.noreply.github.com> Date: Sat, 8 Nov 2025 14:37:49 +0700 Subject: [PATCH 5/5] chore: update whatsnew docs --- Doc/whatsnew/3.15.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/Doc/whatsnew/3.15.rst b/Doc/whatsnew/3.15.rst index 5379ac3abba227..7a8e747cb4e563 100644 --- a/Doc/whatsnew/3.15.rst +++ b/Doc/whatsnew/3.15.rst @@ -443,6 +443,7 @@ math mimetypes --------- +* Add ``application/node`` MIME type for ``.cjs`` extension. (Contributed by John Franey in :gh:`140937`.) * Add ``application/toml``. (Contributed by Gil Forcada in :gh:`139959`.) * Rename ``application/x-texinfo`` to ``application/texinfo``. (Contributed by Charlie Lin in :gh:`140165`)