admin管理员组文章数量:1395381
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?
1 Answer
Reset to default 1Yes 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.
本文标签: javascriptGutenberg dependencies in packagejson
版权声明:本文标题:javascript - Gutenberg dependencies in package.json 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744707668a2620937.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论