Closed donmhico closed 4 years ago
Right now the wp dependencies used in src/block/rich-text/edit.js is coded as
wp
src/block/rich-text/edit.js
const { blockEditor: { RichText, }, i18n: { __, }, } = wp;
and with this code, the generated build/index.asset.php contains the code
build/index.asset.php
<?php return array('dependencies' => array('wp-element', 'wp-polyfill'), 'version' => '6f6449156c890ee6d6dd7f0c20739f55');
While it works, from what I see, it is assuming that wp-i18n is loaded.
wp-i18n
I think using this code instead might be better
import { RichText } from '@wordpress/editor'; import { __ } from '@wordpress/i18n';
Produces this build/index.asset.php
<?php return array('dependencies' => array('wp-editor', 'wp-element', 'wp-i18n', 'wp-polyfill'), 'version' => 'd47ef22f22d9986de15adf6d119b60d6');
which in my opinion is safer since it explicitly adds both wp-editor and wp-i18n as dependencies.
wp-editor
What are your thoughts?
@michealengland
I think we can make this happen. I am interested in seeing if this makes a difference in bundle-file size.
Observation
Right now the
wp
dependencies used insrc/block/rich-text/edit.js
is coded asand with this code, the generated
build/index.asset.php
contains the codeWhile it works, from what I see, it is assuming that
wp-i18n
is loaded.Proposal
I think using this code instead might be better
Produces this
build/index.asset.php
which in my opinion is safer since it explicitly adds both
wp-editor
andwp-i18n
as dependencies.What are your thoughts?
@michealengland