WordPress.org

Make WordPress Core

Opened 3 weeks ago

Last modified 3 weeks ago

#48154 assigned enhancement

Build Tools: Integrate DependencyExtractionWebpackPlugin in the JS build

Reported by: gziolo Owned by: gziolo
Milestone: Awaiting Review Priority: normal
Severity: normal Version: trunk
Component: Build/Test Tools Keywords: has-patch dev-feedback
Focuses: javascript Cc:
PR Number:

Description

This is a try to integrate DependencyExtractionWebpackPlugin which we battle-tested in Gutenberg.

This webpack plugin serves two purposes:

  • Externalize dependencies that are available as script dependencies on modern WordPress sites.
  • Add an asset file for each entry point that declares an object with the list of WordPress script dependencies for the entry point. The asset file also contains the current version calculated for the current source code.

This will greatly simplify the process of upgrading npm packages which change after every Gutenberg release. It might even useful during the WordPress release cycle as we might need to publish more often as we discover critical bugs and regressions.

Code also available at https://github.com/WordPress/wordpress-develop/pull/102 where I test its integration with Travis.

Attachments (2)

49154.diff (14.6 KB) - added by gziolo 3 weeks ago.
Screen Shot 2019-09-24 at 17.27.29.png (67.9 KB) - added by gziolo 3 weeks ago.
The structure of the js folders with asset files generated

Download all attachments as: .zip

Change History (6)

@gziolo
3 weeks ago

#1 @gziolo
3 weeks ago

  • Owner set to gziolo
  • Version set to trunk

@gziolo
3 weeks ago

The structure of the js folders with asset files generated

#2 @gziolo
3 weeks ago

@adamsilverstein @omarreiss this adds several PHP files for each JS script. Is it fine to keep them next to distribution version of JS files as presented on the screenshot above?

@schlessera raised it as a potential issue in the comment under original PR on GitHub related to Gutenberg integration:

In a plugin I'm working on, for example, this now causes PHP files to reside under assets/js, which is totally misleading. This is the type of folder that is usually sent to a CDN, not executed on the server.

#3 @adamsilverstein
3 weeks ago

Hey @gziolo thanks for working on this. Can you explain a bit more how will/are these PHP files be used?

The CDN concern does seem valid. Also, it feels generally confusing/wrong to store PHP files in a folder named js explicitly because it is full of JavaScript files.

I checked the generated php files and see they return the dependencies and a version key. Can we store them in a separate location?

This ticket was mentioned in Slack in #core-js by gziolo. View the logs.


3 weeks ago

Note: See TracTickets for help on using tickets.