Skip to content

perf: replace mime-types with mrmime#22

Merged
chenjiahan merged 3 commits intomainfrom
mrmime_0315
Mar 15, 2026
Merged

perf: replace mime-types with mrmime#22
chenjiahan merged 3 commits intomainfrom
mrmime_0315

Conversation

@chenjiahan
Copy link
Copy Markdown
Member

The mime-types package was replaced with mrmime which offers better performance. This change includes:

  • Updating dependencies in package.json
  • Modifying mime type handling logic in source files
  • Updating documentation references
  • Adjusting test cases to work with the new package

https://npmx.dev/compare?packages=mime-types,mrmime

Copilot AI review requested due to automatic review settings March 15, 2026 01:32
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, 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 focuses on a significant performance optimization by swapping out the existing 'mime-types' library for 'mrmime'. This change streamlines how mime types are identified and managed throughout the application, leading to more efficient operations. The update involved a comprehensive refactor across dependencies, core logic, documentation, and testing to ensure a seamless transition and maintain robust functionality.

Highlights

  • Performance Improvement: The 'mime-types' package has been replaced with 'mrmime' to enhance performance, as 'mrmime' offers a faster alternative for mime type handling.
  • Dependency Updates: The 'package.json' and 'pnpm-lock.yaml' files were updated to reflect the removal of 'mime-types' and the addition of 'mrmime' as a dependency.
  • Mime Type Handling Logic: Core logic in 'src/index.js' and 'src/middleware.js' was modified to integrate with the 'mrmime' library, including a new utility function for content type determination and custom mime type registration.
  • Documentation and Tests: Documentation in 'README.md' was updated to reference 'mrmime', and test cases in 'test/middleware.test.js' were adjusted to ensure compatibility and correct functionality with the new package.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • README.md
    • Updated the documentation link for mime type information from 'mime-types' to 'mrmime'.
  • package.json
    • Replaced 'mime-types' with 'mrmime' in production dependencies.
    • Removed '@types/mime-types' from development dependencies.
  • pnpm-lock.yaml
    • Updated the lockfile to reflect the removal of 'mime-types' and its types.
    • Added 'mrmime' and its associated resolution to the lockfile.
  • src/index.js
    • Changed the import statement from 'mime-types' to destructure 'mimes' from 'mrmime'.
    • Modified the custom mime type registration logic to directly update the 'mimes' object from 'mrmime'.
  • src/middleware.js
    • Replaced the 'mime-types' import with 'lookup' and 'mimes' from 'mrmime'.
    • Introduced a new 'getContentType' function to handle mime type lookups and charset appending.
    • Added 'usdz' as a custom mime type to the 'mimes' object.
    • Updated the content type header setting logic to use the new 'getContentType' function.
  • test/middleware.test.js
    • Updated the import statement to use 'lookup' and 'mimes' from 'mrmime'.
    • Defined 'UTF8_CHARSET_MIME_TYPES' set for consistent charset handling in tests.
    • Added 'usdz' as a custom mime type to the 'mimes' object for testing.
    • Refactored the 'getContentTypeHeader' helper function to utilize 'mrmime.lookup' and apply charset logic.
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
Copy Markdown

@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 replaces the mime-types package with the more performant mrmime. The changes are well-implemented across the codebase, including dependency updates in package.json, logic adjustments in the source files, and documentation updates. My main feedback concerns some code duplication that was introduced between the middleware source and its test file. Consolidating the duplicated logic would improve the long-term maintainability of the code. Overall, this is a solid performance improvement.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Replaces the mime-types dependency with mrmime to improve MIME lookup performance while preserving expected Content-Type header behavior (including charset=utf-8 for common text/UTF-8 types) and keeping the mimeTypes override option working.

Changes:

  • Swap runtime dependency from mime-types to mrmime and update lockfile.
  • Introduce getContentType() in middleware to compute Content-Type values (including UTF-8 charset handling) using mrmime.lookup.
  • Update tests and README references to align with mrmime, including custom mapping for .usdz.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/middleware.js Replaces mime.contentType usage with a mrmime-based getContentType() helper and adds UTF-8 charset handling + .usdz mapping.
src/index.js Updates mimeTypes option handling to override mrmime mappings in-place via mimes.
test/middleware.test.js Updates test expectations and helper logic to match mrmime lookup behavior and charset rules.
package.json Replaces mime-types with mrmime and removes @types/mime-types.
pnpm-lock.yaml Locks mrmime@2.0.1 and removes direct mime-types importer dependency and @types/mime-types.
README.md Updates documentation link from mime-types to mrmime.
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported
Comments suppressed due to low confidence (1)

src/middleware.js:723

  • The inline comment says the content type can be "... or false", but getContentType() returns string | undefined and never returns false. Please update the comment to match the actual return type (or adjust the function to return false if that's a deliberate contract).

        // Only set content-type header if media type is known
        // https://tools.ietf.org/html/rfc7231#section-3.1.1.5
        if (contentType) {

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 14fa324413

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chenjiahan chenjiahan merged commit 88b0ec7 into main Mar 15, 2026
5 checks passed
@chenjiahan chenjiahan deleted the mrmime_0315 branch March 15, 2026 01:39
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