Skip to content

[code-infra] Skip error minification inside dev-only branches#1069

Merged
Janpot merged 2 commits intomasterfrom
minify-errors-skip-dev-branches
Jan 27, 2026
Merged

[code-infra] Skip error minification inside dev-only branches#1069
Janpot merged 2 commits intomasterfrom
minify-errors-skip-dev-branches

Conversation

@Janpot
Copy link
Copy Markdown
Member

@Janpot Janpot commented Jan 26, 2026

Summary

  • Errors inside if (process.env.NODE_ENV !== 'production') blocks are already stripped in production, so minifying them is unnecessary
  • Avoids allocating error codes and injecting runtime imports for dead code

Testing in mui/base-ui#3869

- Errors inside `if (process.env.NODE_ENV !== 'production')` blocks are already stripped in production, so minifying them is unnecessary
- Avoids allocating error codes and injecting runtime imports for dead code
@netlify
Copy link
Copy Markdown

netlify Bot commented Jan 26, 2026

Deploy Preview for mui-internal ready!

Name Link
🔨 Latest commit 0866b68
🔍 Latest deploy log https://app.netlify.com/projects/mui-internal/deploys/697892c254ad55000865bd8b
😎 Deploy Preview https://deploy-preview-1069--mui-internal.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

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

mui-bot commented Jan 26, 2026

Bundle size report

Bundle Parsed size Gzip size
@base-ui-components/react 0B(0.00%) 0B(0.00%)
@mui/x-charts-pro 0B(0.00%) 0B(0.00%)

Details of bundle changes


Check out the code infra dashboard for more information about this PR.

Comment thread packages/babel-plugin-minify-errors/index.js
@oliviertassinari oliviertassinari changed the title Skip error minification inside dev-only branches [code-infra] Skip error minification inside dev-only branches Jan 26, 2026
output: readOutputFixtureSync('custom-runtime-imports-recursive', 'output.js'),
},
{
title: 'skips errors inside dev-only branches',
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

How about we implement the opposite behavior? We throw if an error is thrown in an dev-only branch, unless minify-error-disabled is set?

The idea would be that we should almost never change the control flow between environments. If we start to allow this pattern, people might face bugs that only happen in production.

Copy link
Copy Markdown
Member Author

@Janpot Janpot Jan 27, 2026

Choose a reason for hiding this comment

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

I'm thinking we could make a lint rule for this specific pattern. Linting and minification are two different things. If possible would like to avoid encoding hidden linting rules in a process that's meant for something entirely different.

Copy link
Copy Markdown
Member

@oliviertassinari oliviertassinari Jan 27, 2026

Choose a reason for hiding this comment

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

Linting is indeed the correct place to have the logic I'm proposing, but it's also more Ci time, more work to maintain, I saw this as a quick win 😁. But ok fair enough. We can have both.

@Janpot Janpot force-pushed the minify-errors-skip-dev-branches branch from 953e2d8 to 0866b68 Compare January 27, 2026 10:26
@Janpot Janpot merged commit a38e519 into master Jan 27, 2026
19 checks passed
@Janpot Janpot deleted the minify-errors-skip-dev-branches branch January 27, 2026 10:32
@oliviertassinari oliviertassinari added the type: enhancement It’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature. label Jan 27, 2026
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). type: enhancement It’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants