Make WordPress Core

Opened 7 months ago

Closed 7 months ago

Last modified 7 months ago

#59407 closed enhancement (fixed)

Build: Introduce SCRIPT_DEBUG global in webpack processing

Reported by: gziolo's profile gziolo Owned by: gziolo's profile gziolo
Milestone: 6.4 Priority: normal
Severity: normal Version: 6.4
Component: Build/Test Tools Keywords: has-patch gutenberg-merge
Focuses: Cc:

Description (last modified by gziolo)

Backports the same changes to the webpack config in the Gutenberg plugin with https://github.com/WordPress/gutenberg/pull/50122.

The warning from @wordpress/warning no longer worked correctly with webpack 5. In practice, it no longer called console.warn. To fix it, the usage of process.env.NODE_ENV check got replaced with another optional global: SCRIPT_DEBUG. All the tools used in the Gutenberg, get updated to work with this new constant, including @wordpress/scripts. This way, developers are able to guard code that should be run only in development mode. In WordPress core, the same constant needs to be added mostly to ensure that the code behind the check gets completely removed in production mode.

It's an enhancement on top of #59411 and can be tested after WordPress packages get backported from the Gutenberg plugin.

Change History (10)

#1 @gziolo
7 months ago

  • Keywords has-patch added
  • Owner set to gziolo

#2 @gziolo
7 months ago

  • Keywords gutenberg-merge added

#3 @gziolo
7 months ago

@youknowriad, do you know if we can remove process.env.FORCE_REDUCED_MOTION? I don't see it in the Gutenberg plugin anymore:

https://github.com/WordPress/gutenberg/blob/trunk/tools/webpack/shared.js#L65-L74

@gziolo commented on PR #5258:


7 months ago
#5

I can confirm that webpack still builds correctly and the block editor loads as expected.

#6 @gziolo
7 months ago

  • Description modified (diff)

@gziolo commented on PR #5258:


7 months ago
#7

It looks like process.env.FORCE_REDUCED_MOTION is no longer used with WordPress packages, so I'm going to remove that global. It got removed with this commit: https://github.com/WordPress/gutenberg/commit/914f543e1e50d8c65c05a417efbdf539ef0d7a63.

#8 @gziolo
7 months ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 56699:

Build: Introduce SCRIPT_DEBUG global in webpack processing

Backports the same changes to the webpack config in the Gutenberg plugin with https://github.com/WordPress/gutenberg/pull/50122.

The warning function from @wordpress/warning no longer worked correctly with webpack 5. In practice, it no longer called console.warn. To fix it, the usage of process.env.NODE_ENV check got replaced with another optional global: SCRIPT_DEBUG. All the tools used in the Gutenberg, get updated to work with this new constant, including @wordpress/scripts. This way, developers are able to guard code that should be run only in development mode. In WordPress core, the same constant needs to be added mostly to ensure that the code behind the check gets completely removed in production mode.

Fixes #59407.

#10 @gziolo
7 months ago

I can confirm that warning messages are correctly removed from production builds in WordPress 6.4 Beta 1.

Note: See TracTickets for help on using tickets.