Skip to content

warning package is not compatible with webpack 5 #44950

@tomalec

Description

@tomalec

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

Metadata

Metadata

Assignees

Labels

[Package] Warning/packages/warning[Status] In ProgressTracking issues with work in progress[Type] BugAn existing feature does not function as intended[Type] Build ToolingIssues or PRs related to build tooling

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions