Make WordPress Core

Opened 4 weeks ago

Last modified 4 weeks ago

#61262 reopened enhancement

Build: Update JavaScript build variables for Gutenberg PR 61486

Reported by: jonsurrell's profile jonsurrell Owned by: jonsurrell's profile jonsurrell
Milestone: 6.6 Priority: normal
Severity: normal Version:
Component: Build/Test Tools Keywords: has-patch
Focuses: javascript Cc:

Description

PR 61486 updates the variables replaced at compile time in Gutenberg packages.

The Webpack DefinePlugin configuration should be updated accordingly.

Change History (11)

This ticket was mentioned in PR #6596 on WordPress/wordpress-develop by @jonsurrell.


4 weeks ago
#1

  • Keywords has-patch added

This updates the build to account for the following PR:

https://github.com/WordPress/gutenberg/pull/61486

Trac ticket: https://core.trac.wordpress.org/ticket/61262

#2 @youknowriad
4 weeks ago

  • Milestone changed from Awaiting Review to 6.6

@swissspidy commented on PR #6596:


4 weeks ago
#3

I‘m confused, why does this require a core change?

Does this mean any other projects using these packages also need to update their configs?

I thought those variables in the GB packages are replaced during compile time for dead code elimination and shouldn‘t be present in the distributed packages.

@youknowriad commented on PR #6596:


4 weeks ago
#4

Does this mean any other projects using these packages also need to update their configs?

I think it's not mandatory and these values would act as "false" by default but if you want to tree-shake them out of the code base, it's better to update the config.

@youknowriad commented on PR #6596:


4 weeks ago
#5

The variables are present in the packages (just like the previous ones were) to allow the folks importing the packages (Gutenberg or Core) to decide whether to enable something or not (disabled by default)

@jonsurrell commented on PR #6596:


4 weeks ago
#6

The variables are replaced when they're compiled as Core Scripts or Script Modules. They're shipped in the npm packages (that has not changed at all with https://github.com/WordPress/gutenberg/pull/61486)

Gutenberg does that here:

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

This PR is updating Core's build configuration accordingly.

@jonsurrell commented on PR #6596:


4 weeks ago
#7

Does this mean any other projects using these packages also need to update their configs?

Yes and no. If folks are actually compiling projects with the npm packages (bundled, not provided by WordPress) and had configured their bundler to perform replacements then they'd need to update. I believe those are very exceptional conditions.

There shouldn't be anything harmful about this change for most projects, in fact it's safer as it should remove some of the problems that process.env has.

@youknowriad commented on PR #6596:


4 weeks ago
#8

LGTM

#9 @gziolo
4 weeks ago

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

In 58193:

Build: Add globalThis DefinePlugin config to webpack

This updates the build to account for related changes in WordPress packages. More details in https://github.com/WordPress/gutenberg/pull/61486.

Props jonsurrell, youknowriad, swissspidy, gziolo.
Fixes #61262.

@gziolo commented on PR #6596:


4 weeks ago
#10

Committed with https://core.trac.wordpress.org/changeset/58193. We will have to follow up with the removal of old replacements when the next version of WP packages gets published to npm.

#11 @gziolo
4 weeks ago

  • Resolution fixed deleted
  • Status changed from closed to reopened
Note: See TracTickets for help on using tickets.