Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
npmDude opened this issue Jun 23, 2020 · 8 comments
Assignees

Comments

@npmDude
Copy link

npmDude commented Jun 23, 2020

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 tschortsch self-assigned this Jun 23, 2020
@tschortsch
Copy link
Member

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 npmDude closed this as completed Jun 24, 2020
@npmDude npmDude reopened this Jun 24, 2020
@npmDude
Copy link
Author

npmDude commented Jun 24, 2020

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
Copy link
Author

npmDude commented Jun 24, 2020

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
Copy link
Member

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
Copy link
Author

npmDude commented Jun 29, 2020

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
Copy link
Member

tschortsch commented Jun 30, 2020

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 (WordPress/gutenberg#23498) for that.

@npmDude
Copy link
Author

npmDude commented Jul 1, 2020

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

@npmDude npmDude closed this as completed Jul 1, 2020
@tschortsch
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants