Skip to content

Why are there PHP files in the JS packages on npm? #33241

@azaozz

Description

@azaozz

Been wondering about this for a while. Seems these PHP files were added as a "quick fix" during the first merge of Gutenberg to WP 5.0, but not sue anybody has ever looked at "how to" and "why" since.

As far as I see it is not a good idea to (auto)add PHP code from the Gutenberg plugin to core as some of that code serves a bit different purpose in the plugin. There are certain, sometimes significant differences when a function or a class is included in core compared to when it is added by a plugin. For example a plugin may want to be backwards compatible with previous versions of WordPress, etc. Such code would be "dead" in core.

I understand some of that PHP code is generic and may be needed by third parties. Perhaps those files are okay to include in the packages, as long as they are not WP specific. On the other hand WP specific PHP code, especially code that is needed for the plugin to work in older WP versions, should not be part of the npm packages. It is useless for third parties and not suitable for core. Seems such "compatibility" PHP code should be in /lib and loaded conditionally on the WP version or function_exists(), etc.

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Type] EnhancementA suggestion for improvement.[Type] Plugin InteroperabilityIncompatibilities between a specific plugin and the block editor. Close with workaround notes.[Type] QuestionQuestions about the design or development of the editor.[Type] WP Core TicketRequires an upstream change from WordPress. Core Trac ticket should be linked.npm PackagesRelated to npm packages

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions