-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
[code-infra] Move MuiError babel macro to babel plugin #43904
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Netlify deploy previewhttps://deploy-preview-43904--material-ui.netlify.app/ Bundle size reportDetails of bundle changes (Toolpad) |
Janpot
changed the title
[code-infra] Move MuiError babel macros to babel plugin
[code-infra] Move MuiError babel macro to babel plugin
Sep 29, 2024
github-actions
bot
added
the
PR: out-of-date
The pull request has merge conflicts and can't be merged
label
Sep 30, 2024
github-actions
bot
removed
the
PR: out-of-date
The pull request has merge conflicts and can't be merged
label
Sep 30, 2024
github-actions
bot
added
the
PR: out-of-date
The pull request has merge conflicts and can't be merged
label
Oct 2, 2024
github-actions
bot
removed
the
PR: out-of-date
The pull request has merge conflicts and can't be merged
label
Oct 3, 2024
@michaldudak I renamed to just |
JCQuintas
approved these changes
Oct 7, 2024
This was referenced Oct 31, 2024
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This plugin replaces code of the form
with
It replaces the former
Same functionality in terms of error extraction as the
MuiError
babel macro, but the code is still runnable without thebabel-plugin-macros
plugin (just with unminified errors).Also moved the check that guards against calling
Error(...)
withoutnew
toeslint
Also refactored the
formatMuiErrorMessage
as it looks like the optimizations don't make sense anymore, babel doesn't transform them anymore. Looks like it shaved off 16B 😄Initially minified every error instance, which resulted in the following bundle sizes:
@mui/code-infra What are your thoughts. I don't want to refactor the whole setup, the main goal is to remove
babel-macros
, but I'm on the fence on what to use as a marker for deciding which errors to minify. Alternatives to consider:Tagged template literal exported from
'@mui/internal-babel-plugin-minify-error'
Error
constructor, can assign them to a variable and share with multiple Errors, e.g.material-ui/docs/src/modules/components/ApiPage/definitions/classes.ts
Lines 45 to 46 in 5cee5bd
Just minify every error of the pattern
new Error(
MUI: invalid ${foo} on ${bar})
formatMuiErrorMessage
will be included one way or the other. The individual bundle size may give a wring impression.Main advantage of the
/* minify-error */
is the fact that it doesn't require an import. The code is exactly the code that would execute when unminified. This makes the plugin a pure optimization.