WebDevStudios / wds-block-starter

A block starter for projects.
15 stars 3 forks source link

Using import in rich-text-demo block #28

Closed donmhico closed 4 years ago

donmhico commented 4 years ago

Observation

Right now the wp dependencies used in src/block/rich-text/edit.js is coded as

const {
    blockEditor: {
        RichText,
    },
    i18n: {
        __,
    },
} = wp;

and with this code, the generated build/index.asset.php contains the code

<?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.

Proposal

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.

What are your thoughts?

@michealengland

michealengland commented 4 years ago

I think we can make this happen. I am interested in seeing if this makes a difference in bundle-file size.