Ensure WP Dependencies correctly generated. #132
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of the Change
This updated the JavaScript file to add WordPress dependencies using the
import
syntax rather then the exposed functions within thewp
namespace.This change allows wp-scripts to pick detect the dependencies correctly and include them in the generated file
build/index.asset.php
.Closes #131
Alternate Designs
Alternative considered: manually adding the dependencies in the PHP file.
I chose this approach as it maintains automation while working around the error we were seeing in the last configuration.
Possible Drawbacks
None that I am aware of.
Verification Process
npm i; npm run build;
build/index.asset.php
fileChecklist:
Changelog Entry
Fixed: Ensure required WordPress libraries were included as dependencies.
Credits
Props @peterwilsoncc