javascript - Gutenberg dependencies in package.json

Seeing as @wordpressscripts will magic my development versions of @wordpress* dependencies, should any of them be pres

Seeing as @wordpress/scripts will magic my development versions of @wordpress/* dependencies, should any of them be present in the package.json for my own block development?

Gutenberg examples package.json refers exclusively to @wordpress/scripts despite the entrypoint file referring to @wordpress/i18n and @wordpress/blocks. Should I do the same?

Seeing as @wordpress/scripts will magic my development versions of @wordpress/* dependencies, should any of them be present in the package.json for my own block development?

Gutenberg examples package.json refers exclusively to @wordpress/scripts despite the entrypoint file referring to @wordpress/i18n and @wordpress/blocks. Should I do the same?

Share Improve this question asked Feb 28, 2020 at 13:37 Capi EtherielCapi Etheriel 1235 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

Yes and no, it depends...

The WP Scripts package depends on the @wordpress/dependency-extraction-webpack-plugin package at:

https://github/WordPress/gutenberg/tree/master/packages/dependency-extraction-webpack-plugin

What this will do is search for packages from @wordpress and list them in a file to make it easy for you to load the list of dependencies when enqueuing. It also adjusts webpack so that it knows not to compile in those dependencies, but instead rely on WordPress to provide them at runtime via enqueuing. As a result, the packages aren't needed, and you don't end up with 20 copies of @wordpress/element loaded on the page from every extra block installed.

So, you don't need to put @wordpress/element in your package.json requirements when using wp scripts to build the assets. This only applies to WordPress packages though. Other libraries on the other hand get included the normal way.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744707668a4589151.html

相关推荐

  • javascript - Gutenberg dependencies in package.json

    Seeing as @wordpressscripts will magic my development versions of @wordpress* dependencies, should any of them be pres

    1天前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信