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

Scripts: Problem with build command when using multiple blocks scaffolded with create block #27969

Closed
S-Blank opened this issue Jan 4, 2021 · 5 comments · Fixed by #27985
Closed
Labels
[Status] Needs More Info Follow-up required in order to be actionable. [Tool] WP Scripts /packages/scripts [Type] Bug An existing feature does not function as intended

Comments

@S-Blank
Copy link

S-Blank commented Jan 4, 2021

Good day,

I have been having problems developing Gutenberg blocks for days.

I use ‘@wordpress/create-block’ to build my blocks. As long as I build the blocks with ‘npm start’, the blocks work fine and without any error messages, but as soon as I use ‘npm run build’ for building, I get problems, especially if other custom blocks of mine are already installed (the new block or other blocks can no longer be found in the editor, or throw an error message: ‘Object(…) is not a function at anonymus’). Sometimes renaming the new block and clearing the browser cache / website cache helps, sometimes not.
If I then build the block again via ‘npm start’, everything works again.

Does anyone have an idea what this could be?

Many thanks in advance for your help.

Many greetings
Simon

@bph bph added [Tool] Create Block /packages/create-block [Type] Help Request Help with setup, implementation, or "How do I?" questions. labels Jan 4, 2021
@skorasaurus
Copy link
Member

Could you describe more 'Object' error by including its entire content of the error message?

This sounds similar to #23607 and #24321 but I don't know if they're a duplicate of what you're experiencing.

@gziolo
Copy link
Member

gziolo commented Jan 4, 2021

@skorasaurus, thank you for cross linking with existing issues.

It's very likely it's the same bug with webpack v4 that was fixed in webpack v5. I tried today to upgrade @wordpress/scripts that Create Block uses to the latest version of webpack but it looks like the plugin ecosystem needs some more time to upgrade. I plan to propose a fix similar to what @ocean90 shared in comments and include it in the next npm release hopefully later this week.

@timnolte
Copy link
Contributor

timnolte commented Jan 5, 2021

@S-Blank have you tried the solution as explained here: #23607 (comment)

@gziolo gziolo added [Tool] WP Scripts /packages/scripts [Status] Needs More Info Follow-up required in order to be actionable. and removed [Tool] Create Block /packages/create-block [Type] Help Request Help with setup, implementation, or "How do I?" questions. labels Jan 5, 2021
@gziolo gziolo changed the title Problem with @wordpress/create-block build function Scripts: Problem with build command when using multiple blocks scaffolded with create block Jan 5, 2021
@gziolo gziolo added the [Type] Bug An existing feature does not function as intended label Jan 5, 2021
@S-Blank
Copy link
Author

S-Blank commented Jan 5, 2021

I have, as described in #23607 (comment), added a webpack.config.js with the following code in all my blocks.

image

Now it works for me. Thank you very much for your help.

@gziolo
Copy link
Member

gziolo commented Jan 5, 2021

The fix is almost ready to land in #27985, thank you for confirming that it solve the issue for you :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Status] Needs More Info Follow-up required in order to be actionable. [Tool] WP Scripts /packages/scripts [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants