Skip to content

[code-infra] Allow specifying a custom error formatter module for error minifcation#45291

Merged
Janpot merged 28 commits intomui:masterfrom
Janpot:add-custom-runtime-module
Mar 17, 2025
Merged

[code-infra] Allow specifying a custom error formatter module for error minifcation#45291
Janpot merged 28 commits intomui:masterfrom
Janpot:add-custom-runtime-module

Conversation

@Janpot
Copy link
Member

@Janpot Janpot commented Feb 11, 2025

This allows us to bring this plugin to other projects and let them use their own formatter. This is necessary to be able to create links to their own docs. Also making this option mandatory

  • Add runtimeModule option you can specify for the error formatter, Make sure it can resolve import specifiers in package.json.
  • Add detection option to specify whether you want 'opt-in' or 'opt-out' behavior. Over time we'll move to opt-out behavior for all packages.

@Janpot Janpot added the scope: code-infra Involves the code-infra product (https://www.notion.so/mui-org/5562c14178aa42af97bc1fa5114000cd). label Feb 11, 2025
@mui-bot
Copy link

mui-bot commented Feb 11, 2025

Netlify deploy preview

https://deploy-preview-45291--material-ui.netlify.app/

Bundle size report

No bundle size changes (Toolpad)
No bundle size changes

Generated by 🚫 dangerJS against e1e182d

@Janpot Janpot changed the title Allow specifying a custom error formatter module for error minifcation [code-infra] Allow specifying a custom error formatter module for error minifcation Feb 11, 2025
@Janpot Janpot marked this pull request as ready for review February 26, 2025 14:30
@Janpot Janpot requested a review from a team February 26, 2025 14:31
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged. label Mar 3, 2025
Copy link
Member

@michaldudak michaldudak left a comment

Choose a reason for hiding this comment

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

It looks solid. I'm going to test it with Base UI implementation.

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged. label Mar 13, 2025
@michaldudak
Copy link
Member

I'm wondering if we have a way to clean up the extracted codes from stale entries

@Janpot
Copy link
Member Author

Janpot commented Mar 13, 2025

By "stale entries", do you mean errors that have been in older versions of @mui/material?

I think in general the rule should be that the error codes file is mostly append-only. Error messages can only be updated if their semantic meaning is unchanged, and the amount of parameters remains unchanged. Error messages can't be deleted, even if the latest version of @mui/material doesn't contain the error anymore. If a parameter is added, removed, or changed meaning, a new message must be generated. Messages can only be deleted if they haven't been npm published yet.
This is important because the urls must retain their meaning for every version of @mui/material that exists.

@michaldudak
Copy link
Member

I meant messages that we rephrased or edited typos. I suppose we can still do it manually in both the call site and extracted errors json.

@Janpot
Copy link
Member Author

Janpot commented Mar 13, 2025

I suppose we can still do it manually in both the call site and extracted errors json.

Yes, at the moment it's a manual process. With the current setup it can't be automatic because when a message is changed in the code, the error extractor doesn't know how to match it up with an existing message. The current method is quite safe though, there isn't much harm if a new error code is create for an existing message.

@Janpot Janpot merged commit ce3386d into mui:master Mar 17, 2025
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: code-infra Involves the code-infra product (https://www.notion.so/mui-org/5562c14178aa42af97bc1fa5114000cd).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants