liip / bootstrap-blocks-wordpress-plugin

Bootstrap Gutenberg Blocks for WordPress
https://wordpress.org/plugins/wp-bootstrap-blocks/
280 stars 60 forks source link

Row and Button blocks go missing when importing style.scss files on my own plugin #48

Closed npmDude closed 4 years ago

npmDude commented 4 years ago

I created a plugin that has custom blocks for a certain website. But when I import a style.scss file and enqueue it. The Row and Button blocks from this plugin goes missing.

This is the error I get: Uncaught TypeError: Cannot read property 'call' of undefined at c (index.js?ver=130d186358a29f9f3f810962654c962a:1) at Module. (index.js?ver=130d186358a29f9f3f810962654c962a:1) at c (index.js?ver=130d186358a29f9f3f810962654c962a:1) at o (index.js?ver=130d186358a29f9f3f810962654c962a:1) at index.js?ver=130d186358a29f9f3f810962654c962a:1 at index.js?ver=130d186358a29f9f3f810962654c962a:1

This happens only when I do wp-scripts build command.

tschortsch commented 4 years ago

How did you register your blocks? Maybe they are using the same name as our blocks? And does your plugin have any relations to this plugin (like depending on it or something similar)?

npmDude commented 4 years ago

I just did what was stated on the documentation on wordpress. I am using block name 'button' but my plugin name is different from yours. No relation at all.

npmDude commented 4 years ago

Here is a sample `$asset_file = include(plugin_dir_path(FILE) . 'build/index.asset.php');

wp_register_script(
    'trt-blocks',
    plugins_url('build/index.js', __FILE__),
    $asset_file['dependencies'],
    $asset_file['version']
);

wp_register_style(
    'trt-blocks-editor',
    plugins_url('build/index.css', __FILE__),
    array('wp-edit-blocks', 'trt-blocks'),
    $asset_file['version']
);

wp_register_style(
    'trt-blocks',
    plugins_url('build/style-index.css', __FILE__),
    array(),
    $asset_file['version']
);

register_block_type('trt-blocks/button', array(
    'editor_style' => 'trt-blocks-editor',
    'editor_script' => 'trt-blocks',
));

register_block_type('trt-blocks/location', array(
    'style' => 'trt-blocks',
    'editor_style' => 'trt-blocks-editor',
    'editor_script' => 'trt-blocks',
));`
tschortsch commented 4 years ago

And does it also happen when you do not register your trt-blocks/button block? Could you maybe also show me the code where you register this block in JavaScript?

npmDude commented 4 years ago

It is not the trt-blocks/button that is making the error. After a few more testing it seems that if two plugins that uses the latest version of wp-scripts both used the css import feature provided particularly the style.scss file. Then the error will occur,

tschortsch commented 4 years ago

Ah now I get it. You're totally right, I could reproduce the described issue with another plugin which bases on @wordpress/scripts. This seems to be an issue of the @wordpress/scripts package itself. I've seen that you already created an issue in the Gutenberg repository (https://github.com/WordPress/gutenberg/issues/23498) for that.

npmDude commented 4 years ago

Yes, and I guess I can close this one and wait for the outcome on that issue. Thanks for helping though.

tschortsch commented 4 years ago

This issue should be solved with v2.3.1 (https://github.com/liip/bootstrap-blocks-wordpress-plugin/releases/tag/2.3.1) of the plugin.