Skip to content
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

Interactivity: Warn texts should be eliminated from production builds #61765

Open
sirreal opened this issue May 17, 2024 · 1 comment
Open

Interactivity: Warn texts should be eliminated from production builds #61765

sirreal opened this issue May 17, 2024 · 1 comment
Labels
[Packages] Interactivity /packages/interactivity

Comments

@sirreal
Copy link
Member

sirreal commented May 17, 2024

Flagging that all warning messages end up being included in the production bundle when using the warn util. They are never printed on production because the body of the helper method goes through the tree-shaking step.

Screenshot 2024-05-17 at 11 47 34 Screenshot 2024-05-17 at 11 49 21 Screenshot 2024-05-17 at 11 48 32

@wordpress/warning package uses this Babel plugin: https://github.com/WordPress/gutenberg/blob/trunk/packages/warning/babel-plugin.js to ensure that all usage also gets automatically wrapped with the check against SCRIPT_DEBUG, similar to how it is implemented in the util.

Originally posted by @gziolo in #61409 (comment)

@sirreal
Copy link
Member Author

sirreal commented May 17, 2024

If we come up with a more unique name that's unlikely to collide, we could remove this via terser with the following option and not require the babel transform.

This is an idea, not a recommendation.

{
  compress: {
    pure_funcs: ['warn']
  },
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Packages] Interactivity /packages/interactivity
Projects
None yet
Development

No branches or pull requests

1 participant