-
Notifications
You must be signed in to change notification settings - Fork 31
Try/add dependency extraction plugin webpack #109
base: master
Are you sure you want to change the base?
Conversation
@ryanwelcher Like we discussed I like the concept. But I'd really really want to see CSS files in the version numbers also. I've been using Webpack manifest plugin for the automated cache busting. It creates |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
@ryanwelcher can you fix the conflicts?
Do we need this in theme-scaffold as well or is it just for plugins? |
@timwright12 @ryanwelcher I feel like this can be useful for themes as well. I know for sure some projects ships custom blocks with themes |
Do we need this when 10up scripts might be on the horizon? |
10up scripts should abstract this away. |
@nicholasio @samikeijonen wondering if we can move this forward? @samikeijonen: This change will make using any |
Description of the Change
This PR introduces the DependencyExtractionWebpackPlugin plugin that is used as part of the @wordpress/scripts package.
This plugin will convert calls to dependencies via
import
statements to access them on the appropriate global.For example
import { registerPlugin } from '@wordpress/plugins
is converted to
var { registerPlugin } = wp.plugins
In addition, the plugin generates an assets.php file with dependencies and version number for each entry point.
The PR also makes changes to how the scaffold sets up the
wp_enqueue_script
calls to automate the process as much as possible.Benefits
This plugin will automate generating a list of script dependencies and version numbers for each entry point in the Webpack config. This means that once it's been set up by the scaffold, engineers won't need to manually add dependencies to the array or manually bump the plugin version number to break caching.
Possible Drawbacks
To use this functionality, engineers must use import statements instead of pulling items from the global.
For example,
const { registerPlugin } = wp.plugins
becomesimport { registerPlugin } from '@wordpress/plugins
.This may seem counter-intuitive as we don't install those packages with the project.
Checklist:
Applicable Issues
Changelog Entry