Open khromov opened 4 years ago
What I discovered was, that the final package coming out from CGB Scripts is way smaller (ca. 50k) than the WP-CLI script (about 150k). I guess it comes from NOT importing all packages. ServerSideRenderer is a not recommended and not oftenly used package (I use it, though), so I guess tha's the reason why they droped it. As you wrote, you can opt it in with npm i @wordpress/server-side-render
@gollenia I don't think you are supposed to actually install the @wordpress/server-side-render
package for your custom blocks. It's already included in Gutenberg!
You might get a different incompatible version than Gutenberg is actually running and it bloats your bundle size.
Instead what should happen is that the bundler should resolve the dependency to the global wp
object.
When using the official @wordpress/scripts
build environment instead of CGB and running import ServerSideRender from '@wordpress/server-side-render';
it actually gets transpiled down to the following in the finished build:
/***/ "@wordpress/server-side-render":
/*!***************************************************!*\
!*** external {"this":["wp","serverSideRender"]} ***!
\***************************************************/
/***/ (function(module, exports) {
(function() { module.exports = this["wp"]["serverSideRender"]; }());
/***/ }),
Can't get any smaller than that! 😄
CGB also does this for some classes correctly, but not for @wordpress/server-side-render
which is what this issue is about.
OK, I get the point. So I did it all wrong, since I also manually imported api-fetch and compose, both packages seemed to be missing. However, on the official Wordpress Developer page I just found that both cgb-scripts AND wp-cli are deprecated
https://developer.wordpress.org/block-editor/tutorials/block-tutorial/generate-blocks-with-wp-cli/
Feature Request
Is your feature request related to a problem? Please describe. It appears that the
@wordpress/server-side-render
dependency is not included by default in CGB, which makes it impossible to import theServerSideRender
component.Describe the solution you'd like It would be good if all packages that are published for the block editor would be included in Gutenberg. See full list: https://developer.wordpress.org/block-editor/packages/
Describe alternatives you've considered You can import it manually using
npm i @wordpress/server-side-render dependency
.Teachability, Documentation, Adoption, Migration Strategy N/A