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

warning package is not compatible with webpack 5 #44950

Closed
tomalec opened this issue Oct 13, 2022 · 3 comments · Fixed by #50122
Closed

warning package is not compatible with webpack 5 #44950

tomalec opened this issue Oct 13, 2022 · 3 comments · Fixed by #50122
Assignees
Labels
[Package] Warning /packages/warning [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended [Type] Build Tooling Issues or PRs related to build tooling

Comments

@tomalec
Copy link
Contributor

tomalec commented Oct 13, 2022

Description

@wordpress/warning and its babel-plugin rely on process.env. So for env == 'production' it's supposed not to show the warning.

The problem is webpack 5 removed process variable completely:

So, the typeof process !== 'undefined' && process.env !=== 'production' is always false, which prevents warning to be called for any kind of environment.

Step-by-step reproduction instructions

Follow the package's README

  1. Put @wordpress/warning/babel-plugin into your babel config or use @wordpress/babel-preset-default, which already includes the babel plugin.
  2. import warning from '@wordpress/warning';
    warning( 'You should see me' );
  3. Build your bundle with webpack 5

Screenshots, screen recording, code snippet

No response

Environment info

   "@wordpress/warning": "2.19.0",
   "webpack": "^5.74.0",

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

@gziolo gziolo added [Package] Warning /packages/warning [Type] Build Tooling Issues or PRs related to build tooling [Type] Bug An existing feature does not function as intended labels Oct 13, 2022
@tomalec
Copy link
Contributor Author

tomalec commented Oct 14, 2022

One workaround if to add new webpack.ProvidePlugin( { process: 'process/browser' } ) to the plugins of webpack config.

However, it increases the bundle size, and @wordpress/warning/babel-plugin was meant to reduce it.

@gziolo
Copy link
Member

gziolo commented Apr 12, 2023

What is the new pattern for marking a code block as intended only for development purposes? We could simplify the check to verify if something like SCRIPT_DEBIG (mirroring WordPress core) is set to true.

@gziolo
Copy link
Member

gziolo commented Apr 27, 2023

I started to #50122 to see if we can fix the bug by reworking how we approach feature flagging for development-related tooling.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Warning /packages/warning [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended [Type] Build Tooling Issues or PRs related to build tooling
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants