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

Try canonical block plugins using the Time to Read block #61504

Closed
wants to merge 29 commits into from

Conversation

creativecoder
Copy link
Contributor

@creativecoder creativecoder commented May 8, 2024

What?

Experiment to try creating a canonical block plugin, using the existing Time to Read block.

Part of #58773

Why?

Canonical Block Plugin?

From the #58773 description:

There's a growing subset of blocks that we may contemplate creating that are either more niche or—for various reasons—not necessarily an immediate fit for the bundled library in core...

I propose we look at a mechanism where such blocks can be designed, developed, published, and maintained by core contributors in this repository (benefits from collocation and testing infrastructure) but for them to be published as standalone blocks in the directory instead of bundled in the default library. These blocks would show up as authored by [WordPress.org]. It'd allow themes and patterns in the directory to leverage them with certainty.

Time to Read Block

The block already exists in Gutenberg, but has been punted from WP releases twice, over concerns it's not a good fit for the default block library (#53776). But it still seems to be a popular block, so would be useful to have available in a stand-alone block plugin for easy installation from the editor (for those who don't run the Gutenberg plugin on their site).

How?

Time to Read block

  • Copies the existing time-to-read block into it's own directory.
  • Adds readme, screenshots, etc so that the block can be released as a standalone plugin and added to the block directory.
  • This PR doesn't modify the existing behavior of the block in any way, only adding what's needed to make it work as a standalone plugin, based on create-block-plugin scaffolding.

Canonical plugins infrastructure

  • Adds configuration for linting, automated tests, wp-env, etc to use the new plugins/ folder in the repo.
  • Updates npm scripts to build and lint plugins.
  • Uses the npm workspaces feature to enable running individual plugin scripts from the repo root (e.g. npm run build -w plugins/time-to-read-block).

See the plugins/README.md file in this PR for more details and documentation.

Testing Instructions

  • Disable the Gutenberg plugin in your development environment, to make sure the block plugin works independently.
  • Build the project: npm run build
  • If not using the included wp-env development environment, symlink the plugin folder to wp-content/plugins/time-to-read-block in your development environment
  • Activate the plugin
  • Search for the "Time to Read" block in the editor and insert it into a post or page
  • Save and check the front-end of the site

Future work

This PR does not include scripts and workflows for the following:

  • Generating new plugin releases and bumping versions
  • Deploying plugin updates to the plugins repo
  • Automatically updating Requires at least: and Requires PHP: plugin headers when new versions of WordPress are released

@creativecoder creativecoder added [Type] Enhancement A suggestion for improvement. [Feature] Blocks Overall functionality of blocks labels May 8, 2024
@creativecoder creativecoder changed the title Try canonical block plugin using time-to-read block Try canonical block plugins using the Time to Read block May 8, 2024
Copy link

github-actions bot commented May 8, 2024

Size Change: +389 B (+0.02%)

Total Size: 1.75 MB

Filename Size Change
build/block-editor/index.min.js 252 kB +299 B (+0.12%)
build/block-editor/style-rtl.css 15.9 kB +255 B (+1.63%)
build/block-editor/style.css 15.9 kB +253 B (+1.61%)
build/block-library/blocks/social-links/style-rtl.css 1.51 kB +7 B (+0.47%)
build/block-library/blocks/social-links/style.css 1.5 kB +7 B (+0.47%)
build/block-library/index.min.js 219 kB +29 B (+0.01%)
build/block-library/style-rtl.css 14.6 kB +11 B (+0.08%)
build/block-library/style.css 14.6 kB +12 B (+0.08%)
build/components/index.min.js 223 kB +6 B (0%)
build/edit-site/index.min.js 208 kB -206 B (-0.1%)
build/edit-site/posts-rtl.css 6.54 kB -6 B (-0.09%)
build/edit-site/posts.css 6.54 kB -6 B (-0.09%)
build/edit-site/style-rtl.css 11.7 kB -42 B (-0.36%)
build/edit-site/style.css 11.7 kB -42 B (-0.36%)
build/editor/index.min.js 98.2 kB -12 B (-0.01%)
build/editor/style-rtl.css 9.15 kB -87 B (-0.94%)
build/editor/style.css 9.15 kB -89 B (-0.96%)
ℹ️ View Unchanged
Filename Size
build/a11y/index.min.js 951 B
build/annotations/index.min.js 2.26 kB
build/api-fetch/index.min.js 2.31 kB
build/autop/index.min.js 2.12 kB
build/blob/index.min.js 579 B
build/block-directory/index.min.js 7.31 kB
build/block-directory/style-rtl.css 1.01 kB
build/block-directory/style.css 1.01 kB
build/block-editor/content-rtl.css 4.58 kB
build/block-editor/content.css 4.58 kB
build/block-editor/default-editor-styles-rtl.css 394 B
build/block-editor/default-editor-styles.css 394 B
build/block-library/blocks/archives/editor-rtl.css 61 B
build/block-library/blocks/archives/editor.css 60 B
build/block-library/blocks/archives/style-rtl.css 90 B
build/block-library/blocks/archives/style.css 90 B
build/block-library/blocks/audio/editor-rtl.css 149 B
build/block-library/blocks/audio/editor.css 151 B
build/block-library/blocks/audio/style-rtl.css 132 B
build/block-library/blocks/audio/style.css 132 B
build/block-library/blocks/audio/theme-rtl.css 134 B
build/block-library/blocks/audio/theme.css 134 B
build/block-library/blocks/avatar/editor-rtl.css 115 B
build/block-library/blocks/avatar/editor.css 115 B
build/block-library/blocks/avatar/style-rtl.css 104 B
build/block-library/blocks/avatar/style.css 104 B
build/block-library/blocks/button/editor-rtl.css 310 B
build/block-library/blocks/button/editor.css 310 B
build/block-library/blocks/button/style-rtl.css 538 B
build/block-library/blocks/button/style.css 538 B
build/block-library/blocks/buttons/editor-rtl.css 336 B
build/block-library/blocks/buttons/editor.css 336 B
build/block-library/blocks/buttons/style-rtl.css 328 B
build/block-library/blocks/buttons/style.css 328 B
build/block-library/blocks/calendar/style-rtl.css 240 B
build/block-library/blocks/calendar/style.css 240 B
build/block-library/blocks/categories/editor-rtl.css 113 B
build/block-library/blocks/categories/editor.css 112 B
build/block-library/blocks/categories/style-rtl.css 124 B
build/block-library/blocks/categories/style.css 124 B
build/block-library/blocks/code/editor-rtl.css 53 B
build/block-library/blocks/code/editor.css 53 B
build/block-library/blocks/code/style-rtl.css 121 B
build/block-library/blocks/code/style.css 121 B
build/block-library/blocks/code/theme-rtl.css 122 B
build/block-library/blocks/code/theme.css 122 B
build/block-library/blocks/columns/editor-rtl.css 108 B
build/block-library/blocks/columns/editor.css 108 B
build/block-library/blocks/columns/style-rtl.css 420 B
build/block-library/blocks/columns/style.css 420 B
build/block-library/blocks/comment-author-avatar/editor-rtl.css 124 B
build/block-library/blocks/comment-author-avatar/editor.css 124 B
build/block-library/blocks/comment-content/style-rtl.css 90 B
build/block-library/blocks/comment-content/style.css 90 B
build/block-library/blocks/comment-template/style-rtl.css 200 B
build/block-library/blocks/comment-template/style.css 199 B
build/block-library/blocks/comments-pagination-numbers/editor-rtl.css 122 B
build/block-library/blocks/comments-pagination-numbers/editor.css 121 B
build/block-library/blocks/comments-pagination/editor-rtl.css 221 B
build/block-library/blocks/comments-pagination/editor.css 211 B
build/block-library/blocks/comments-pagination/style-rtl.css 234 B
build/block-library/blocks/comments-pagination/style.css 231 B
build/block-library/blocks/comments-title/editor-rtl.css 75 B
build/block-library/blocks/comments-title/editor.css 75 B
build/block-library/blocks/comments/editor-rtl.css 832 B
build/block-library/blocks/comments/editor.css 832 B
build/block-library/blocks/comments/style-rtl.css 632 B
build/block-library/blocks/comments/style.css 631 B
build/block-library/blocks/cover/editor-rtl.css 668 B
build/block-library/blocks/cover/editor.css 669 B
build/block-library/blocks/cover/style-rtl.css 1.62 kB
build/block-library/blocks/cover/style.css 1.6 kB
build/block-library/blocks/details/editor-rtl.css 65 B
build/block-library/blocks/details/editor.css 65 B
build/block-library/blocks/details/style-rtl.css 86 B
build/block-library/blocks/details/style.css 86 B
build/block-library/blocks/embed/editor-rtl.css 314 B
build/block-library/blocks/embed/editor.css 314 B
build/block-library/blocks/embed/style-rtl.css 419 B
build/block-library/blocks/embed/style.css 419 B
build/block-library/blocks/embed/theme-rtl.css 133 B
build/block-library/blocks/embed/theme.css 133 B
build/block-library/blocks/file/editor-rtl.css 326 B
build/block-library/blocks/file/editor.css 326 B
build/block-library/blocks/file/style-rtl.css 278 B
build/block-library/blocks/file/style.css 279 B
build/block-library/blocks/file/view.min.js 324 B
build/block-library/blocks/footnotes/style-rtl.css 198 B
build/block-library/blocks/footnotes/style.css 197 B
build/block-library/blocks/form-input/editor-rtl.css 229 B
build/block-library/blocks/form-input/editor.css 229 B
build/block-library/blocks/form-input/style-rtl.css 342 B
build/block-library/blocks/form-input/style.css 342 B
build/block-library/blocks/form-submission-notification/editor-rtl.css 344 B
build/block-library/blocks/form-submission-notification/editor.css 341 B
build/block-library/blocks/form-submit-button/style-rtl.css 69 B
build/block-library/blocks/form-submit-button/style.css 69 B
build/block-library/blocks/form/view.min.js 470 B
build/block-library/blocks/freeform/editor-rtl.css 2.6 kB
build/block-library/blocks/freeform/editor.css 2.6 kB
build/block-library/blocks/gallery/editor-rtl.css 958 B
build/block-library/blocks/gallery/editor.css 962 B
build/block-library/blocks/gallery/style-rtl.css 1.71 kB
build/block-library/blocks/gallery/style.css 1.71 kB
build/block-library/blocks/gallery/theme-rtl.css 108 B
build/block-library/blocks/gallery/theme.css 108 B
build/block-library/blocks/group/editor-rtl.css 402 B
build/block-library/blocks/group/editor.css 402 B
build/block-library/blocks/group/style-rtl.css 103 B
build/block-library/blocks/group/style.css 103 B
build/block-library/blocks/group/theme-rtl.css 79 B
build/block-library/blocks/group/theme.css 79 B
build/block-library/blocks/heading/style-rtl.css 188 B
build/block-library/blocks/heading/style.css 188 B
build/block-library/blocks/html/editor-rtl.css 346 B
build/block-library/blocks/html/editor.css 347 B
build/block-library/blocks/image/editor-rtl.css 845 B
build/block-library/blocks/image/editor.css 843 B
build/block-library/blocks/image/style-rtl.css 1.54 kB
build/block-library/blocks/image/style.css 1.54 kB
build/block-library/blocks/image/theme-rtl.css 137 B
build/block-library/blocks/image/theme.css 137 B
build/block-library/blocks/image/view.min.js 1.54 kB
build/block-library/blocks/latest-comments/style-rtl.css 355 B
build/block-library/blocks/latest-comments/style.css 354 B
build/block-library/blocks/latest-posts/editor-rtl.css 204 B
build/block-library/blocks/latest-posts/editor.css 204 B
build/block-library/blocks/latest-posts/style-rtl.css 509 B
build/block-library/blocks/latest-posts/style.css 510 B
build/block-library/blocks/list/style-rtl.css 104 B
build/block-library/blocks/list/style.css 104 B
build/block-library/blocks/media-text/editor-rtl.css 304 B
build/block-library/blocks/media-text/editor.css 303 B
build/block-library/blocks/media-text/style-rtl.css 516 B
build/block-library/blocks/media-text/style.css 515 B
build/block-library/blocks/more/editor-rtl.css 427 B
build/block-library/blocks/more/editor.css 427 B
build/block-library/blocks/navigation-link/editor-rtl.css 663 B
build/block-library/blocks/navigation-link/editor.css 664 B
build/block-library/blocks/navigation-link/style-rtl.css 192 B
build/block-library/blocks/navigation-link/style.css 191 B
build/block-library/blocks/navigation-submenu/editor-rtl.css 295 B
build/block-library/blocks/navigation-submenu/editor.css 294 B
build/block-library/blocks/navigation/editor-rtl.css 2.2 kB
build/block-library/blocks/navigation/editor.css 2.21 kB
build/block-library/blocks/navigation/style-rtl.css 2.26 kB
build/block-library/blocks/navigation/style.css 2.25 kB
build/block-library/blocks/navigation/view.min.js 1.03 kB
build/block-library/blocks/nextpage/editor-rtl.css 392 B
build/block-library/blocks/nextpage/editor.css 392 B
build/block-library/blocks/page-list/editor-rtl.css 378 B
build/block-library/blocks/page-list/editor.css 378 B
build/block-library/blocks/page-list/style-rtl.css 175 B
build/block-library/blocks/page-list/style.css 175 B
build/block-library/blocks/paragraph/editor-rtl.css 236 B
build/block-library/blocks/paragraph/editor.css 236 B
build/block-library/blocks/paragraph/style-rtl.css 341 B
build/block-library/blocks/paragraph/style.css 340 B
build/block-library/blocks/post-author/style-rtl.css 175 B
build/block-library/blocks/post-author/style.css 176 B
build/block-library/blocks/post-comments-form/editor-rtl.css 96 B
build/block-library/blocks/post-comments-form/editor.css 96 B
build/block-library/blocks/post-comments-form/style-rtl.css 506 B
build/block-library/blocks/post-comments-form/style.css 506 B
build/block-library/blocks/post-content/editor-rtl.css 74 B
build/block-library/blocks/post-content/editor.css 74 B
build/block-library/blocks/post-date/style-rtl.css 62 B
build/block-library/blocks/post-date/style.css 62 B
build/block-library/blocks/post-excerpt/editor-rtl.css 71 B
build/block-library/blocks/post-excerpt/editor.css 71 B
build/block-library/blocks/post-excerpt/style-rtl.css 141 B
build/block-library/blocks/post-excerpt/style.css 141 B
build/block-library/blocks/post-featured-image/editor-rtl.css 729 B
build/block-library/blocks/post-featured-image/editor.css 726 B
build/block-library/blocks/post-featured-image/style-rtl.css 341 B
build/block-library/blocks/post-featured-image/style.css 341 B
build/block-library/blocks/post-navigation-link/style-rtl.css 215 B
build/block-library/blocks/post-navigation-link/style.css 214 B
build/block-library/blocks/post-template/editor-rtl.css 99 B
build/block-library/blocks/post-template/editor.css 98 B
build/block-library/blocks/post-template/style-rtl.css 399 B
build/block-library/blocks/post-template/style.css 398 B
build/block-library/blocks/post-terms/style-rtl.css 96 B
build/block-library/blocks/post-terms/style.css 96 B
build/block-library/blocks/post-time-to-read/style-rtl.css 70 B
build/block-library/blocks/post-time-to-read/style.css 70 B
build/block-library/blocks/post-title/style-rtl.css 100 B
build/block-library/blocks/post-title/style.css 100 B
build/block-library/blocks/preformatted/style-rtl.css 125 B
build/block-library/blocks/preformatted/style.css 125 B
build/block-library/blocks/pullquote/editor-rtl.css 134 B
build/block-library/blocks/pullquote/editor.css 134 B
build/block-library/blocks/pullquote/style-rtl.css 342 B
build/block-library/blocks/pullquote/style.css 342 B
build/block-library/blocks/pullquote/theme-rtl.css 167 B
build/block-library/blocks/pullquote/theme.css 167 B
build/block-library/blocks/query-pagination-numbers/editor-rtl.css 121 B
build/block-library/blocks/query-pagination-numbers/editor.css 118 B
build/block-library/blocks/query-pagination/editor-rtl.css 220 B
build/block-library/blocks/query-pagination/editor.css 208 B
build/block-library/blocks/query-pagination/style-rtl.css 287 B
build/block-library/blocks/query-pagination/style.css 283 B
build/block-library/blocks/query-title/style-rtl.css 64 B
build/block-library/blocks/query-title/style.css 64 B
build/block-library/blocks/query/editor-rtl.css 502 B
build/block-library/blocks/query/editor.css 502 B
build/block-library/blocks/query/view.min.js 958 B
build/block-library/blocks/quote/style-rtl.css 238 B
build/block-library/blocks/quote/style.css 238 B
build/block-library/blocks/quote/theme-rtl.css 221 B
build/block-library/blocks/quote/theme.css 225 B
build/block-library/blocks/read-more/style-rtl.css 138 B
build/block-library/blocks/read-more/style.css 138 B
build/block-library/blocks/rss/editor-rtl.css 101 B
build/block-library/blocks/rss/editor.css 101 B
build/block-library/blocks/rss/style-rtl.css 288 B
build/block-library/blocks/rss/style.css 287 B
build/block-library/blocks/search/editor-rtl.css 183 B
build/block-library/blocks/search/editor.css 183 B
build/block-library/blocks/search/style-rtl.css 672 B
build/block-library/blocks/search/style.css 671 B
build/block-library/blocks/search/theme-rtl.css 113 B
build/block-library/blocks/search/theme.css 113 B
build/block-library/blocks/search/view.min.js 475 B
build/block-library/blocks/separator/editor-rtl.css 100 B
build/block-library/blocks/separator/editor.css 100 B
build/block-library/blocks/separator/style-rtl.css 248 B
build/block-library/blocks/separator/style.css 248 B
build/block-library/blocks/separator/theme-rtl.css 195 B
build/block-library/blocks/separator/theme.css 195 B
build/block-library/blocks/shortcode/editor-rtl.css 286 B
build/block-library/blocks/shortcode/editor.css 286 B
build/block-library/blocks/site-logo/editor-rtl.css 806 B
build/block-library/blocks/site-logo/editor.css 803 B
build/block-library/blocks/site-logo/style-rtl.css 218 B
build/block-library/blocks/site-logo/style.css 218 B
build/block-library/blocks/site-tagline/editor-rtl.css 87 B
build/block-library/blocks/site-tagline/editor.css 87 B
build/block-library/blocks/site-title/editor-rtl.css 123 B
build/block-library/blocks/site-title/editor.css 123 B
build/block-library/blocks/site-title/style-rtl.css 71 B
build/block-library/blocks/site-title/style.css 71 B
build/block-library/blocks/social-link/editor-rtl.css 338 B
build/block-library/blocks/social-link/editor.css 338 B
build/block-library/blocks/social-links/editor-rtl.css 676 B
build/block-library/blocks/social-links/editor.css 675 B
build/block-library/blocks/spacer/editor-rtl.css 346 B
build/block-library/blocks/spacer/editor.css 346 B
build/block-library/blocks/spacer/style-rtl.css 48 B
build/block-library/blocks/spacer/style.css 48 B
build/block-library/blocks/table/editor-rtl.css 394 B
build/block-library/blocks/table/editor.css 394 B
build/block-library/blocks/table/style-rtl.css 640 B
build/block-library/blocks/table/style.css 639 B
build/block-library/blocks/table/theme-rtl.css 152 B
build/block-library/blocks/table/theme.css 152 B
build/block-library/blocks/tag-cloud/style-rtl.css 266 B
build/block-library/blocks/tag-cloud/style.css 265 B
build/block-library/blocks/template-part/editor-rtl.css 393 B
build/block-library/blocks/template-part/editor.css 393 B
build/block-library/blocks/template-part/theme-rtl.css 113 B
build/block-library/blocks/template-part/theme.css 113 B
build/block-library/blocks/term-description/style-rtl.css 108 B
build/block-library/blocks/term-description/style.css 108 B
build/block-library/blocks/text-columns/editor-rtl.css 95 B
build/block-library/blocks/text-columns/editor.css 95 B
build/block-library/blocks/text-columns/style-rtl.css 165 B
build/block-library/blocks/text-columns/style.css 165 B
build/block-library/blocks/verse/style-rtl.css 98 B
build/block-library/blocks/verse/style.css 98 B
build/block-library/blocks/video/editor-rtl.css 553 B
build/block-library/blocks/video/editor.css 554 B
build/block-library/blocks/video/style-rtl.css 192 B
build/block-library/blocks/video/style.css 192 B
build/block-library/blocks/video/theme-rtl.css 134 B
build/block-library/blocks/video/theme.css 134 B
build/block-library/classic-rtl.css 179 B
build/block-library/classic.css 179 B
build/block-library/common-rtl.css 1.1 kB
build/block-library/common.css 1.1 kB
build/block-library/editor-elements-rtl.css 75 B
build/block-library/editor-elements.css 75 B
build/block-library/editor-rtl.css 11.9 kB
build/block-library/editor.css 11.9 kB
build/block-library/elements-rtl.css 54 B
build/block-library/elements.css 54 B
build/block-library/reset-rtl.css 472 B
build/block-library/reset.css 472 B
build/block-library/theme-rtl.css 702 B
build/block-library/theme.css 707 B
build/block-serialization-default-parser/index.min.js 1.12 kB
build/block-serialization-spec-parser/index.min.js 2.87 kB
build/blocks/index.min.js 52.2 kB
build/commands/index.min.js 15.2 kB
build/commands/style-rtl.css 955 B
build/commands/style.css 952 B
build/components/style-rtl.css 12.1 kB
build/components/style.css 12.1 kB
build/compose/index.min.js 12.9 kB
build/core-commands/index.min.js 2.77 kB
build/core-data/index.min.js 72.6 kB
build/customize-widgets/index.min.js 10.9 kB
build/customize-widgets/style-rtl.css 1.35 kB
build/customize-widgets/style.css 1.35 kB
build/data-controls/index.min.js 641 B
build/data/index.min.js 8.98 kB
build/date/index.min.js 18 kB
build/deprecated/index.min.js 458 B
build/dom-ready/index.min.js 325 B
build/dom/index.min.js 4.65 kB
build/edit-post/classic-rtl.css 578 B
build/edit-post/classic.css 580 B
build/edit-post/index.min.js 12.5 kB
build/edit-post/style-rtl.css 2.34 kB
build/edit-post/style.css 2.33 kB
build/edit-widgets/index.min.js 17.6 kB
build/edit-widgets/style-rtl.css 4.18 kB
build/edit-widgets/style.css 4.18 kB
build/element/index.min.js 4.83 kB
build/escape-html/index.min.js 537 B
build/format-library/index.min.js 8.07 kB
build/format-library/style-rtl.css 494 B
build/format-library/style.css 493 B
build/hooks/index.min.js 1.54 kB
build/html-entities/index.min.js 445 B
build/i18n/index.min.js 3.58 kB
build/interactivity/debug.min.js 16.5 kB
build/interactivity/file.min.js 447 B
build/interactivity/image.min.js 1.68 kB
build/interactivity/index.min.js 13.4 kB
build/interactivity/navigation.min.js 1.16 kB
build/interactivity/query.min.js 742 B
build/interactivity/router.min.js 2.8 kB
build/interactivity/search.min.js 615 B
build/is-shallow-equal/index.min.js 526 B
build/keyboard-shortcuts/index.min.js 1.31 kB
build/keycodes/index.min.js 1.46 kB
build/list-reusable-blocks/index.min.js 2.17 kB
build/list-reusable-blocks/style-rtl.css 846 B
build/list-reusable-blocks/style.css 846 B
build/media-utils/index.min.js 2.92 kB
build/modules/importmap-polyfill.min.js 12.3 kB
build/notices/index.min.js 946 B
build/nux/index.min.js 1.58 kB
build/nux/style-rtl.css 749 B
build/nux/style.css 745 B
build/patterns/index.min.js 7.35 kB
build/patterns/style-rtl.css 687 B
build/patterns/style.css 685 B
build/plugins/index.min.js 1.81 kB
build/preferences-persistence/index.min.js 2.06 kB
build/preferences/index.min.js 2.9 kB
build/preferences/style-rtl.css 578 B
build/preferences/style.css 578 B
build/primitives/index.min.js 829 B
build/priority-queue/index.min.js 1.54 kB
build/private-apis/index.min.js 1.01 kB
build/react-i18n/index.min.js 630 B
build/react-refresh-entry/index.min.js 9.47 kB
build/react-refresh-runtime/index.min.js 6.76 kB
build/redux-routine/index.min.js 2.69 kB
build/reusable-blocks/index.min.js 2.73 kB
build/reusable-blocks/style-rtl.css 256 B
build/reusable-blocks/style.css 256 B
build/rich-text/index.min.js 10.1 kB
build/router/index.min.js 1.96 kB
build/server-side-render/index.min.js 1.94 kB
build/shortcode/index.min.js 1.4 kB
build/style-engine/index.min.js 2.01 kB
build/token-list/index.min.js 581 B
build/url/index.min.js 3.85 kB
build/vendors/react-dom.min.js 42.8 kB
build/vendors/react-jsx-runtime.min.js 560 B
build/vendors/react.min.js 2.65 kB
build/viewport/index.min.js 965 B
build/warning/index.min.js 250 B
build/widgets/index.min.js 7.19 kB
build/widgets/style-rtl.css 1.16 kB
build/widgets/style.css 1.16 kB
build/wordcount/index.min.js 1.03 kB

compressed-size-action

@gziolo
Copy link
Member

gziolo commented May 9, 2024

This is a great start. Do you want it to be more tightly integrated with the monorepo? I could offer a few hints on moving some of the configurations to the root of the projects. In the long run, we could also explore improving linting overrides related to textdinaub so plugin authors can benefit from it and avoid the need to maintain their own customizations.

@creativecoder
Copy link
Contributor Author

This is a great start. Do you want it to be more tightly integrated with the monorepo? I could offer a few hints on moving some of the configurations to the root of the projects.

@gziolo , thanks for taking a look! Yes, that would be great--any hints you have would be appreciated. I'd like to use this PR to experiment with monorepo integration, CI configuration, and the like. We can always break it out into more granular changes before merging, if needed.

Copy link
Member

@gziolo gziolo left a comment

Choose a reason for hiding this comment

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

I left a bunch of suggestions on how to move some control to the top of the repository so that whenever we add a new block, we will be updating existing files. I think, the most impactful thing would be getting rid of maintaining the local package lock file since all the packages in most of the cases will be installed in the root node_modules folder. By the way, to keep the lock file from the project, you can use the following setting in the .npmrc file:

package-lock=false

I'm also sure we can figure out a way to be able to build these block from the root of the project, similar to how we run additional build steps for some WP packages using Learn:

"prebuild:packages": "npm run clean:packages && lerna run build",

We shouldn't reuse Lerna here for a new script, because we don't need to publish anything to npm, but we could start using npm workspaces to achieve the same goal.

@@ -0,0 +1,15 @@
{
Copy link
Member

Choose a reason for hiding this comment

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

All these changes can be moved to root config file, similar to:

gutenberg/.eslintrc.js

Lines 433 to 438 in 4d1c083

{
files: [ 'packages/interactivity*/src/**' ],
rules: {
'react/react-in-jsx-scope': 'error',
},
},

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice, done in 30cab7a.

plugins/time-to-read-block/package.json Show resolved Hide resolved
"start": "wp-scripts start"
},
"devDependencies": {
"@wordpress/scripts": "27.7.0"
Copy link
Member

Choose a reason for hiding this comment

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

Can we drop it from here? We can use the same script installed in the root of the project. The same applies to some of the script like linting and formatting that are handled for the entire repository already.

"@wordpress/scripts": "27.7.0"
},
"dependencies": {
"@wordpress/block-editor": "^12.24.0",
Copy link
Member

@gziolo gziolo May 10, 2024

Choose a reason for hiding this comment

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

I think we should reference the local packages that are present in the project, like in other places, example:

"@babel/runtime": "^7.16.0",
"@wordpress/a11y": "file:../a11y",
"@wordpress/api-fetch": "file:../api-fetch",
"@wordpress/autop": "file:../autop",
"@wordpress/blob": "file:../blob",
"@wordpress/block-editor": "file:../block-editor",
"@wordpress/blocks": "file:../blocks",
"@wordpress/components": "file:../components",
"@wordpress/compose": "file:../compose",
"@wordpress/core-data": "file:../core-data",
"@wordpress/data": "file:../data",
"@wordpress/date": "file:../date",
"@wordpress/deprecated": "file:../deprecated",
"@wordpress/dom": "file:../dom",
"@wordpress/element": "file:../element",
"@wordpress/escape-html": "file:../escape-html",
"@wordpress/hooks": "file:../hooks",
"@wordpress/html-entities": "file:../html-entities",
"@wordpress/i18n": "file:../i18n",
"@wordpress/icons": "file:../icons",
"@wordpress/interactivity": "file:../interactivity",
"@wordpress/interactivity-router": "file:../interactivity-router",
"@wordpress/keyboard-shortcuts": "file:../keyboard-shortcuts",
"@wordpress/keycodes": "file:../keycodes",
"@wordpress/notices": "file:../notices",
"@wordpress/patterns": "file:../patterns",
"@wordpress/primitives": "file:../primitives",
"@wordpress/private-apis": "file:../private-apis",
"@wordpress/reusable-blocks": "file:../reusable-blocks",
"@wordpress/rich-text": "file:../rich-text",
"@wordpress/server-side-render": "file:../server-side-render",
"@wordpress/url": "file:../url",
"@wordpress/viewport": "file:../viewport",
"@wordpress/wordcount": "file:../wordcount",

Here, the path will be a bit different:

Suggested change
"@wordpress/block-editor": "^12.24.0",
"@wordpress/block-editor": "file:../../packages/block-editor",

When using explicit version, these quickly will get outdated. By referencing the same packages from the repository, we will always use the latest version. I'm not entirely sure if that is necessary outside of unit tests, but at least we won't have to install these packages from npm.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that seemed to work as expected. Also done in 30cab7a.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@gziolo Thinking through this a bit more, I think we would need to specify the latest version of packages shipped in WordPress, to ensure compatibility.

Block plugins should work without Gutenberg active. Since @wordpress packages are transformed to reference window.wp as part of the js build process, I believe that production block code could end up using older package versions and unexpectedly break if newer APIs were not available in those older versions.

Does that seem accurate? What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Then again, it doesn't really seem to matter what package versions are specified here, as either way the actual code in the browser is going to use whatever window.wp provides, independent of the packages here in the repo.

The important thing will be running e2e tests without Gutenberg active to ensure the block plugin works with the latest WordPress release even when the Gutenberg plugin is disabled.

@@ -0,0 +1,13 @@
<?xml version="1.0"?>
Copy link
Member

Choose a reason for hiding this comment

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

Here, I hope we could also should be able to update the shared config by setting override for the entire folder:

https://github.com/WordPress/gutenberg/blob/trunk/phpcs.xml.dist

Although, I'm not sure how to do it myself. @anton-vlasenko might be able to help.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I looked through the phpcs configuration docs and can't see a way to apply different rule attributes to different paths in a single command (to use different translation domains for block plugins and the main plugin in the same phpcs check under the WordPress.WP.I18n rule). It seems that whenever you redeclare the same ruleset, it overrides any previous instances of the same rule. I believe we could add extra domains to the list, but that doesn't seem like enough, as it wouldn't catch 'gutenberg' being used in block plugins.

So the best I could come up with so far

  • Move most of the rules to a phpcs.xml.shared file
  • Import the shared rules into the main phpcs.xml.dist, and into a separate file for each block plugin
  • Use a script when running the lint:php command that does a separate run of phpcs for each phpcs.xml.dist config

But let me know if I'm missing something or there's a better way to organize this.

@creativecoder
Copy link
Contributor Author

I've updated this PR so that all plugin commands (like npm run build) can be run from the root of the repo.

  • For linting/formatting css and js, the root commands already cover the plugin files, so no changes were needed
  • For PHP linting/formatting, I added scripts that loop through the plugin directories to run phpcs and phpcbf triggered by the same composer run-script commands we're already using
  • For building and plugin-zip generation, the plugin package.json still has separate commands, but they can be run from the root of the repo with npm workspace configuration (e.g. npm run build --workspace plugins/ to build all plugins). The regular npm run build from the repo root has also been updated to trigger this, so that Gutenberg, packages, and plugins can all be built with one command.

Copy link

github-actions bot commented Jun 12, 2024

This pull request has changed or added PHP files. Please confirm whether these changes need to be synced to WordPress Core, and therefore featured in the next release of WordPress.

If so, it is recommended to create a new Trac ticket and submit a pull request to the WordPress Core GitHub repository soon after this pull request is merged.

If you're unsure, you can always ask for help in the #core-editor channel in WordPress Slack.

Thank you! ❤️

View changed files
❔ phpunit/plugins/time-to-read-block/renderBlock.php
❔ phpunit/plugins/time-to-read-block/wordCount.php
❔ phpunit/bootstrap.php

Copy link

Flaky tests detected in 7d01afd.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/9557388463
📝 Reported issues:

Vicente Canales and others added 14 commits July 1, 2024 15:33
- Rename and move plugin as time-to-read-block
- Update readme.txt and plugin headers with appropriate values
- Add screenshots
- Add phpcs and eslint configuration overrides
- Update PHP function names to use the gutenberg_ namespace
- Resolve eslint error by installing the clsx package
- Add custom errors for assertions
- Activate/deactivate plugins in sequence, rather that in parallel, since parallel activation
  seems to cause block not found errors
- Sets up a phpunit/plugins directory for canonical block plugin tests
- Copies existing time to read block tests into plugins test dir
@creativecoder creativecoder added the No Core Sync Required Indicates that any changes do not need to be synced to WordPress Core label Jul 2, 2024
@creativecoder creativecoder marked this pull request as ready for review July 2, 2024 00:32
Copy link

github-actions bot commented Jul 2, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: vcanales <vcanales@git.wordpress.org>
Co-authored-by: creativecoder <grantmkin@git.wordpress.org>
Co-authored-by: gziolo <gziolo@git.wordpress.org>
Co-authored-by: youknowriad <youknowriad@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@creativecoder
Copy link
Contributor Author

I've marked this PR ready for review, as I believe all of the technical work needed to try out releasing the Time to Read block in a separate plugin is in place, and CI is all finally passing. (Though the canonical plugins concept likely needs more discussion and a core proposal is still planned.)

cc @gziolo @youknowriad @anton-vlasenko specifically for any more feedback on the monorepo integration, like how npm scripts and tests are set up.

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.

Nice work, looks well organized. Left a number of questions.

composer.json Outdated Show resolved Hide resolved
@@ -268,12 +271,14 @@
"jsdom": "22.1.0"
},
"scripts": {
"build": "npm run build:packages && wp-scripts build",
"build": "npm run build:packages && concurrently 'npm run build:plugins' 'wp-scripts build'",
Copy link
Contributor

Choose a reason for hiding this comment

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

The question to be asked is whether we want to build plugins when we're working on Gutenberg. Building plugins for now is probably very fast but I expect that as we increase the number of canonical blocks, it might become a burden and developers would want to focus on one thing in particular: Gutenberg, a specific block... An option to build everything, would be handy too but I wonder if it should be the default or not.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My personal expectation is that the primary build command will build the entire project, and that I shouldn't need to run any other commands for a complete build. That said, having a build:gutenberg or similar that only builds the main Gutenberg plugin (and packages) seems like a good idea.

package.json Show resolved Hide resolved
}
tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' );
tests_add_filter( 'muplugins_loaded', '_manually_load_plugins' );
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want to run all the tests of Gutenberg in the same CI job or we want to separate the CI jobs for plugins?

Copy link
Contributor

Choose a reason for hiding this comment

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

Same for JS and e2e tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good question: it would probably be better to have separate CI jobs, to help ensure all plugins work independently from Gutenberg (and from one another). Though I think all jobs should be run on all PRs, to catch any Gutenberg changes that accidentally break unrelated things in plugins.

@@ -0,0 +1,184 @@
<?php
Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting choice, should it be phpunit/plugins/time-to-read-block or plugins/time-to-read-block/phpunit?

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess, similar question for e2e tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Interesting choice, should it be phpunit/plugins/time-to-read-block or plugins/time-to-read-block/phpunit?

That seems reasonable and makes the tests easier to find when they're colocated with the plugins.

That said, I think it's important to be able to run all tests of a particular type using the same command, from the root of the repo, rather than needing to know about separate commands or switch directories to run a complete set of tests. Additionally I think we should avoid duplicating testing configuration as much as possible.

It would also be good to define a separate plugins suite for phpunit, and something similar for other test types, so it's trivial to run plugin tests separately, when desired.

Copy link
Contributor

Choose a reason for hiding this comment

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

Additionally I think we should avoid duplicating testing configuration as much as possible.

💯

In my mind the root level is basically plugins/gutenberg but for historic reasons it's in the root. In other words, I like when tests are collocated with the plugin I think, not sure how complex would it be to do that.

  • Leave the configuration in a root folder.
  • Collocate the plugin tests.
  • For Gutenberg it's a special case, maybe keep it root level for now.

plugins/README.md Outdated Show resolved Hide resolved
</ruleset>
```

#### ESLint
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this override be done in an .eslintrc.js within the plugin folder?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can be, and that's what I had at first, though I changed it on based on @gziolo 's feedback (#61504 (comment))

Copy link
Contributor

Choose a reason for hiding this comment

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

Personally I feel collocating is better as most people will just copy/paste a plugin folder and adapt it. Simpler than having to change files elsewhere.

That said, it's not a big deal either if it stays as is.

.wp-env.json Outdated Show resolved Hide resolved
@youknowriad
Copy link
Contributor

In terms of dev workflow and everything, this seems very good to me already. I'd prefer if we collocate as much as we can (tests, configs...) but it's a small thing. Other than that, I think we need to think about releases, timing, workflows... This is a tangent to the PR though and should happen separately.

@creativecoder
Copy link
Contributor Author

Given the new plan described here, I'm going to close this PR. But it's in a good state to serve as a reference if and when we return to wanting to use the Gutenberg monorepo for additional plugins.

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 No Core Sync Required Indicates that any changes do not need to be synced to WordPress Core [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants