Skip to content

[code-infra] Setup error message minification #1463

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

Open
wants to merge 24 commits into
base: master
Choose a base branch
from

Conversation

Janpot
Copy link
Member

@Janpot Janpot commented Feb 18, 2025

Port core error minification infrastructure:

Copy link

netlify bot commented Feb 19, 2025

Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 8fa10ed
🔍 Latest deploy log https://app.netlify.com/sites/base-ui/deploys/67dbe7a32851500008f625c4
😎 Deploy Preview https://deploy-preview-1463--base-ui.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 site configuration.

@Janpot Janpot changed the title [code-infra] Initial setup for minified error messages (WIP) [code-infra] Setup error message minification Feb 20, 2025
@Janpot Janpot marked this pull request as ready for review February 20, 2025 17:43
@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
@Janpot Janpot self-assigned this Mar 13, 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 good, aside from a typo I found.
@atomiks, do you see anything missing from this implementation?

In the future, we could create an error throw helper function to ensure consistency in our messages.
I'm wondering how big the bundle size savings will be and if the minification is really worth the hassle.

…isplay.tsx

Co-authored-by: Michał Dudak <[email protected]>
Signed-off-by: Jan Potoms <[email protected]>
@Janpot
Copy link
Member Author

Janpot commented Mar 20, 2025

I'm wondering how big the bundle size savings will be and if the minification is really worth the hassle.

Ideally we'd have the bundle size checker in base repo. I can fix that up and port next? We could also postpone merging this PR until then if you want,

Janpot and others added 2 commits March 20, 2025 03:01
@michaldudak
Copy link
Member

michaldudak commented Mar 20, 2025

I checked it manually and it turns out that this PR (with the lastest master merged in) produces a larger package than what's on master.

I ran pnpm build and pnpm pack in the package directory with the following results:

This PR:
package (tgz): 332555 bytes
esm directory (unpacked): 1315505 bytes

master:
package (tgz): 329511 bytes (3044 bytes less)
esm directory (unpacked): 1307340 bytes (8165 bytes less)

I expect it to look different when we add more components and have more error messages, but for now there seems to be no point in making this change (unless my methodology is wrong).

We can also have additional gains in the minifier-less implementation by creating the error helper I mentioned in #1463 (review)

@Janpot
Copy link
Member Author

Janpot commented Mar 20, 2025

(unless my methodology is wrong)

The installed size will indeed be larger as it contains a new function and the error codes alongside the dev messages. But that's not what ends up in user's applications. You need to bundle the package with process.env.NODE_ENV set to 'production' and check the result. That's why I proposed we clean up and port the bundle size checker from core.

@Janpot Janpot added the on hold There is a blocker; we need to wait label Mar 20, 2025
@Janpot
Copy link
Member Author

Janpot commented Mar 20, 2025

Putting this on hold until we've ported the bundle size checker and can assess the impact.

@michaldudak michaldudak added scope: infra Infrastructure work going on behind the scenes and removed scope: code-infra labels May 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
on hold There is a blocker; we need to wait PR: out-of-date The pull request has merge conflicts and can't be merged scope: infra Infrastructure work going on behind the scenes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants