Skip to content

Docs: add step for build and asset file#41511

Merged
ryanwelcher merged 1 commit intoWordPress:trunkfrom
tharsheblows:patch-1
Jun 2, 2022
Merged

Docs: add step for build and asset file#41511
ryanwelcher merged 1 commit intoWordPress:trunkfrom
tharsheblows:patch-1

Conversation

@tharsheblows
Copy link
Contributor

There was a missing step in the plain javascript documentation which missed out adding the asset file. Issue #40447

Done during WCEU 2022 Contributor day! 🎉

There was a missing step in the plain javascript documentation which missed out adding the asset file. Issue WordPress#40447
@github-actions github-actions bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Jun 2, 2022
@github-actions
Copy link

github-actions bot commented Jun 2, 2022

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @tharsheblows! In case you missed it, we'd love to have you join us in our Slack community, where we hold regularly weekly meetings open to anyone to coordinate with each other.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

@tharsheblows
Copy link
Contributor Author

Copy link
Contributor

@ryanwelcher ryanwelcher left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for putting this together!

@ryanwelcher ryanwelcher added [Type] Developer Documentation Documentation for developers Developer Experience Ideas about improving block and theme developer experience labels Jun 2, 2022
@ryanwelcher ryanwelcher merged commit 3323c84 into WordPress:trunk Jun 2, 2022
@tharsheblows tharsheblows deleted the patch-1 branch June 2, 2022 14:47
@github-actions
Copy link

github-actions bot commented Jun 2, 2022

Congratulations on your first merged pull request, @tharsheblows! We'd like to credit you for your contribution in the post announcing the next WordPress release, but we can't find a WordPress.org profile associated with your GitHub account. When you have a moment, visit the following URL and click "link your GitHub account" under "GitHub Username" to link your accounts:

https://profiles.wordpress.org/me/profile/edit/

And if you don't have a WordPress.org account, you can create one on this page:

https://login.wordpress.org/register

Kudos!

@github-actions github-actions bot added this to the Gutenberg 13.5 milestone Jun 2, 2022
@annezazu annezazu changed the title add step for build and asset file Jun 14, 2022
@chairmanbrando
Copy link

I'm not sure if this is the correct spot for this comment, but I landed here via Google, so here it goes...

The block.json docs are still confusing, IMO. I'm not sure I would've figured out why my block wasn't loading its JS file if I hadn't thought to check the WP_DEBUG_LOG file.

PHP Notice: Function register_block_script_handle was called incorrectly. The asset file ([...]/stock-ticker.asset.php) for the "script" defined in "dp/stock-ticker" block definition is missing.

The type definitions for both style and script are the same in the docs, WPDefinedAsset|WPDefinedAsset[], yet they don't fully act the same. Styles can be registered and loaded without a matching .asset.php file while scripts cannot. In fact, core's register_block_style_handle() seems to show that .asset.php isn't even looked for.

It makes sense; scripts loaded without their dependencies will break things. Yet despite showing "file:./script.js" in the example, it's not stated that your script will not be loaded without a matching .asset.php -- at least when using the "file:./[...]" method.

It was hard to find useful info via Google, so if I hadn't had debugging enabled to alert me to the problem, I likely would've soon set up my own block scripts loader in wp_enqueue_scripts using has_block(). D:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Developer Experience Ideas about improving block and theme developer experience First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository [Type] Developer Documentation Documentation for developers

3 participants