Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mimetype for extension .mjs #75896

Closed
bmeck mannequin opened this issue Oct 6, 2017 · 14 comments
Closed

Add mimetype for extension .mjs #75896

bmeck mannequin opened this issue Oct 6, 2017 · 14 comments
Labels
3.7 (EOL) end of life 3.8 (EOL) end of life stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@bmeck
Copy link
Mannequin

bmeck mannequin commented Oct 6, 2017

BPO 31715
Nosy @warsaw, @tiran, @benjaminp, @ned-deily, @bitdancer, @asvetlov, @di, @bmeck, @MylesBorins
PRs
  • bpo-31715 Add mimetype for extension .mjs #3908
  • [3.6] bpo-31715 Add mimetype for extension .mjs (GH-3908) #10976
  • [3.7] bpo-31715 Add mimetype for extension .mjs (GH-3908) #10977
  • [2.7] bpo-31715 Add mimetype for extension .mjs (GH-3908) #10978
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2018-10-08.20:05:22.661>
    created_at = <Date 2017-10-06.15:06:33.818>
    labels = ['3.7', '3.8', 'type-feature', 'library']
    title = 'Add mimetype for extension .mjs'
    updated_at = <Date 2018-12-24.16:31:53.897>
    user = 'https://github.com/bmeck'

    bugs.python.org fields:

    activity = <Date 2018-12-24.16:31:53.897>
    actor = 'ned.deily'
    assignee = 'none'
    closed = True
    closed_date = <Date 2018-10-08.20:05:22.661>
    closer = 'asvetlov'
    components = ['Library (Lib)']
    creation = <Date 2017-10-06.15:06:33.818>
    creator = 'bradleymeck'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 31715
    keywords = ['patch']
    message_count = 14.0
    messages = ['303824', '327369', '331143', '331144', '331157', '331164', '331165', '331169', '331182', '331204', '332254', '332255', '332256', '332485']
    nosy_count = 9.0
    nosy_names = ['barry', 'christian.heimes', 'benjamin.peterson', 'ned.deily', 'r.david.murray', 'asvetlov', 'di', 'bradleymeck', 'mylesborins']
    pr_nums = ['3908', '10976', '10977', '10978']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue31715'
    versions = ['Python 2.7', 'Python 3.6', 'Python 3.7', 'Python 3.8']

    @bmeck
    Copy link
    Mannequin Author

    bmeck mannequin commented Oct 6, 2017

    I propose to add a mapping of file extension .mjs to mime type "text/javascript".
    The "text/javascript" MIME is registered in https://www.iana.org/assignments/media-types, was moved to *should* as the MIME in HTML ( whatwg/html#3096), and is being updated by https://datatracker.ietf.org/doc/draft-bfarias-javascript-mjs/

    This extension is being used by Node.js for support of ECMAScript Modules (ESM).

    @bmeck bmeck mannequin added 3.7 (EOL) end of life 3.8 (EOL) end of life stdlib Python modules in the Lib dir type-feature A feature request or enhancement labels Oct 6, 2017
    @asvetlov
    Copy link
    Contributor

    asvetlov commented Oct 8, 2018

    New changeset 0854b92 by Andrew Svetlov (Bradley Meck) in branch 'master':
    bpo-31715 Add mimetype for extension .mjs (bpo-3908)
    0854b92

    @asvetlov asvetlov removed the 3.7 (EOL) end of life label Oct 8, 2018
    @asvetlov asvetlov closed this as completed Oct 8, 2018
    @MylesBorins
    Copy link
    Mannequin

    MylesBorins mannequin commented Dec 5, 2018

    I see that when this landed it appears that it was removed from landing on "Python 2.7, Python 3.6, Python 3.7".

    Is there any chance to revisit this decision? I dug into the mimetype code and it doesn't appear that there is a way to rely on operating system mimetypes for systems aside from Windows... as such this is going to be a fairly large experience gap for people developing front-end applications that utilize the file extension on any version other than 3.8, which will likely take quite a while to be distributed as a default in various OS distributions.

    @tiran
    Copy link
    Member

    tiran commented Dec 5, 2018

    It's technically a new feature. New features are not added to existing releases unless there is a very compelling reason.

    @MylesBorins
    Copy link
    Mannequin

    MylesBorins mannequin commented Dec 5, 2018

    There are a number of tutorials that suggest using the .mjs extension for working with ESM modules for front end development.

    https://developers.google.com/web/fundamentals/primers/modules <https://developers.google.com/web/fundamentals/primers/modules\>
    https://hacks.mozilla.org/2018/03/es-modules-a-cartoon-deep-dive/ <https://hacks.mozilla.org/2018/03/es-modules-a-cartoon-deep-dive/\>

    There are many tutorials that suggest web developers use python -m SimpleHTTPServer as a way to spin up a quick development server. If a .mjs file is not served with the correct mime type https://html.spec.whatwg.org/multipage/infrastructure.html#javascript-mime-type the browser will throw when trying to load the module, and the error is not the most obvious if developers are not aware of what mime types even are.

    As such I would like propose that this is a bug fix, rather than a feature, as popular browser workflow is going to be broken without an obvious way to fix it for anyone using python right now.

    On Dec 5, 2018, at 2:23 PM, Christian Heimes <report@bugs.python.org> wrote:

    Christian Heimes <lists@cheimes.de> added the comment:

    It's technically a new feature. New features are not added to existing releases unless there is a very compelling reason.

    ----------
    nosy: +christian.heimes


    Python tracker <report@bugs.python.org>
    <https://bugs.python.org/issue31715\>


    @asvetlov
    Copy link
    Contributor

    asvetlov commented Dec 5, 2018

    Christian Heimes is right: it is a new feature, not a bug fix.
    I regret too often when I cannot backport a brilliant patch to old Python version but this is the price of API stability.

    You can try to convince release managers (Benjamin and Ned, I've added you to nosy list) but I suspect you'll get a rejection.

    @MylesBorins
    Copy link
    Mannequin

    MylesBorins mannequin commented Dec 5, 2018

    Thanks for cc'ing the other folks. I help run the Node.js release + LTS team... so I 100% understand the balance necessary to keep a stable API. In this particular case I would gauge that this has a near 0 case for breakage, but leaving it unpatched has a high risk of breaking user expectations

    https://github.com/search?q=extension%3Amjs+function&type=Code

    This is a really heavy handed search against github showing 13k+ files with the .mjs extension that include the word "function"

    @MylesBorins
    Copy link
    Mannequin

    MylesBorins mannequin commented Dec 5, 2018

    Also wanted to point out some prior art of a mimetype (json) being backported to all active runtimes

    https://bugs.python.org/issue30824#msg297527

    @bitdancer
    Copy link
    Member

    We have generally made an exception to the "new feature" rule for mimetypes. That is, we don't really consider a mimetype addition to be a new feature in the sense that our backward compatibility rules mean. It is true that an application could work on x.y.z and break on x.y.z-1, but this isn't because an *API* present in x.y.z is not there in x.y.z-1. is more akin to a bugfix (it threw an exception before, now it works). Think of the absence of the mimetype rule as a bug, rather than its presence as a feature.

    And yes, this is a policy evolution. This way of looking at mimetypes changes has been in effect for....maybe five years now?...and before that we treated them as features. But then, too, before that we required there be an actual IANA accepted RFC, but that requirement too has had to evolve as mimetype management became more decentralized.

    @MylesBorins
    Copy link
    Mannequin

    MylesBorins mannequin commented Dec 6, 2018

    Thanks for chiming in R. David Murray

    Think of the absence of the mimetype rule as a bug, rather than its presence as a feature.

    Very much appreciate this sentiment.

    I've opened backports to simplify the process if y'all decide to approve.

    2.7: #10978
    3.6: #10976
    3.7: #10977

    @ned-deily
    Copy link
    Member

    New changeset c7b7a43 by Ned Deily (Myles Borins) in branch '3.7':
    [3.7] bpo-31715 Add mimetype for extension .mjs (GH-3908) (GH-10977)
    c7b7a43

    @ned-deily
    Copy link
    Member

    New changeset 70db385 by Ned Deily (Myles Borins) in branch '3.6':
    [3.6] bpo-31715 Add mimetype for extension .mjs (GH-3908) (GH-10976)
    70db385

    @ned-deily
    Copy link
    Member

    New changeset d9a2aca by Ned Deily (Myles Borins) in branch '2.7':
    [2.7] bpo-31715 Add mimetype for extension .mjs (GH-3908) (GH-10978)
    d9a2aca

    @ned-deily ned-deily added the 3.7 (EOL) end of life label Dec 20, 2018
    @ned-deily
    Copy link
    Member

    New changeset 25ee15a by Ned Deily (Myles Borins) in branch '3.7':
    [3.7] bpo-31715 Add mimetype for extension .mjs (GH-3908) (GH-10977)
    25ee15a

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.7 (EOL) end of life 3.8 (EOL) end of life stdlib Python modules in the Lib dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants