Skip to content

Add MJS and sourceType: module support#5

Merged
westonruter merged 3 commits intowestonruter:replace-esprima-with-espreefrom
sirreal:javascript-support-mjs
Feb 10, 2026
Merged

Add MJS and sourceType: module support#5
westonruter merged 3 commits intowestonruter:replace-esprima-with-espreefrom
sirreal:javascript-support-mjs

Conversation

@sirreal
Copy link

@sirreal sirreal commented Feb 10, 2026

Builds on WordPress#10806 to add .mjs module support.

Checking the extension for module grammar aligns with IANA media type definition:

Restrictions on usage: 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].

This can be merged into the existing PR or considered on its own.

@gemini-code-assist
Copy link

Summary of Changes

Hello @sirreal, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces comprehensive support for JavaScript module files (.mjs) across WordPress's file handling and code editing functionalities. By recognizing .mjs as an editable extension, configuring JSHint for module grammar, and correctly assigning its MIME type, the changes align WordPress with modern JavaScript module standards, improving developer experience when working with modular JavaScript.

Highlights

  • .mjs File Support: The '.mjs' file extension has been added to the list of editable file types within the WordPress admin, allowing these files to be edited directly.
  • JSHint Module Recognition: JSHint configuration in the code editor now correctly identifies '.mjs' files as JavaScript modules, enabling proper linting for module-specific grammar.
  • MIME Type Assignment: The code editor's MIME type detection has been updated to assign 'text/javascript' to '.mjs' files, ensuring they are treated as standard JavaScript modules.
Changelog
  • src/wp-admin/includes/file.php
    • Added 'mjs' to the list of editable file extensions.
  • src/wp-includes/general-template.php
    • Configured JSHint to set the 'module' option to true if the file ends with '.mjs'.
    • Added 'mjs' to the case statement for 'js' to ensure it gets the 'text/javascript' MIME type.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds support for .mjs files, allowing them to be recognized as editable files and correctly handled as JavaScript modules by the code editor's linter. The changes are generally good, but I've found a couple of areas for improvement. There's an inconsistency where .mjs support is added for plugins but not for themes. Additionally, there's a minor code simplification that can be made in one of the new conditions.

@sirreal
Copy link
Author

sirreal commented Feb 10, 2026

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for .mjs (JavaScript module) files within the WordPress file editor. The changes correctly add the .mjs extension to the list of editable file types for both plugins and themes. Additionally, it configures the code editor to handle .mjs files appropriately by setting the JSHint module option to true for these files and assigning the correct text/javascript MIME type for CodeMirror syntax highlighting. The implementation is clean, targeted, and effectively achieves the goal of adding .mjs support. The changes look good.

Copy link
Owner

@westonruter westonruter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good suggestion!

@westonruter westonruter merged commit fbf63ef into westonruter:replace-esprima-with-espree Feb 10, 2026
@sirreal sirreal deleted the javascript-support-mjs branch February 12, 2026 20:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments