Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Framework: Specify missing wp-url dependencies #8362

Merged
merged 1 commit into from
Aug 1, 2018
Merged

Conversation

aduth
Copy link
Member

@aduth aduth commented Aug 1, 2018

Related: #8300

This pull request seeks to resolve an issue where the Archives block produces an error. This was caused by #8300, where new dependencies were introduced on the @wordpress/url module, but not specified in client-assets.php. The changes here add this dependency to wp-core-blocks and wp-components script handles. While I was here, I also re-alphabetized the dependency list for these handles (and for wp-editor, which was touched in #8300 but already defined wp-url as a dependency).

In the future, we might consider how to automate or validate this process, so that it's not manually curated. I had taken an attempt here, first with a plain PHP script, then with a custom PHPCS Sniff. Ultimately, gutenberg_register_scripts_and_styles touches many core functions which need to be defined, meaning that it's most likely needed to load most of the WordPress context to do programatically. Another alternative is to run validate at runtime (at least in SCRIPT_DEBUG) to check that, for any package defined in packages/, its corresponding script registration includes all the same dependencies as listed in its package.json dependencies object.

Testing instructions:

  1. Navigate to Posts > Add New
  2. Insert an Archives block
  3. Verify there are no errors

@aduth aduth added [Type] Bug An existing feature does not function as intended Framework Issues related to broader framework topics, especially as it relates to javascript [Feature] Blocks Overall functionality of blocks labels Aug 1, 2018
@aduth aduth requested a review from youknowriad August 1, 2018 14:57
@youknowriad
Copy link
Contributor

At some point, I attempted to generate a php file for the script registration in the package folder directly. It was a first step towards automation. I still think it's more valuable than having a unique client-assets.php file where we register all scripts together.

The reasons for closing that PR was that these things will change when we merge to Core anyway.

@aduth
Copy link
Member Author

aduth commented Aug 1, 2018

The reasons for closing that PR was that these things will change when we merge to Core anyway.

Yeah, eventually this is why I stopped spending time on it, as it seemed like effort which would quickly become largely irrelevant come merge. Though I imagine core could benefit from something like this as well, at least with continued adoption of JS packages.

Copy link
Contributor

@youknowriad youknowriad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@aduth aduth merged commit 25f364b into master Aug 1, 2018
@aduth aduth deleted the fix/url-dependencies branch August 1, 2018 15:21
@danielbachhuber danielbachhuber added this to the 3.5 milestone Aug 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Blocks Overall functionality of blocks Framework Issues related to broader framework topics, especially as it relates to javascript [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants