Make WordPress Core

Opened 11 months ago

Closed 10 months ago

Last modified 10 months ago

#61262 closed enhancement (fixed)

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 (16)

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


11 months 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
11 months ago

  • Milestone changed from Awaiting Review to 6.6

@swissspidy commented on PR #6596:


11 months 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:


11 months 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:


11 months 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:


11 months 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:


11 months 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:


11 months ago
#8

LGTM

#9 @gziolo
11 months 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:


11 months 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
11 months ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

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


10 months ago
#12

https://github.com/WordPress/gutenberg/pull/61486 changed the variables
compiled into Gutenberg packages via the webpack DefinePlugin.

https://core.trac.wordpress.org/changeset/58193 added the new
DefinePlugin configuration, but did not remove the legacy configuration
in order to be compatible with new and old Gutenberg versions before the
packages were updated.

Now that packages have been update, the legacy configuration should be
removed.

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

Follow-up to https://core.trac.wordpress.org/changeset/58193.

Trac ticket:

@jonsurrell commented on PR #6596:


10 months ago
#14

https://github.com/WordPress/wordpress-develop/pull/6904 is the follow-up to remove the legacy configuration.

#15 @gziolo
10 months ago

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

In 58577:

Build: Remove legacy webpack DefinePlugin configuration

Follow-up [58193].
Fixes #61262.
Props jonsurrell.

Note: See TracTickets for help on using tickets.