-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
@wordpress/scripts: React.createElement type is invalid when two single block plugins are built using npm run build
#24321
Comments
For ServerSideRender For InspectorControls
For Fragment As previously stated in Expected behavior, I don't actually know what to use. But this is what's currently documented. |
(*) for my plugins I'd had the above problems during development, but didn't realise the consequences. When the problem occurred I'd rebuilt the plugin using |
For the |
You should be able to fix this by using a plugin-specific webpack |
Thanks for the answer @ocean90 but I need a lot more explanation.
|
I have done some further work analysing the problem. To test, I modified my
The errors no longer occurred. The results are as expected:
|
After a short discussion with @ocean90 on Slack, where Dominik confirmed that it's a known/documented issue with multiple webpack apps, I copied the For the
WorkaroundI would suggest that this solution should be considered a viable workaround until a fix is developed. For each single block plugin add a Proposed solution
|
I hope that #27985 will fix it. |
Describe the bug
I've been attempting to develop a number of single block plugins.
I discovered that when all my plugins were built with
npm run build
then I got a variety of failures.The first problem was
which was accompanied by the following in the Console.
For more information see: bobbingwide/sb-children-block#6
At other times I also saw:
See bobbingwide/sb-prevnext-block#1
I have now reproduced the original problem with two very simple blocks
<InspectorControls>
- which also uses<Fragment>
.When sb-prevnext-block is built with
npm start
then it works.When sb-prevnext-block is built with
npm run build
then it doesn't work.I don't know if this is something that I am doing wrong, or something wrong with the build process.
I found similar problems had already been reported ( e.g. #23607 ) so I have developed the steps to reproduce the problem
Note: The problem is exacerbated by my ignorance of the build processes. In the two or so days I've spent battling this problem I have tried various alternative methods to perform the necessary imports. More often than not the solution worked when one of more of the plugins was built with
npm start
but failed when usingnpm run build
.I've tried to follow the instructions in the documentation, but still have many unanswered questions. I imagine that I have made a number of user errors along the way. If so, please can someone point them out so that I know what to do for the future.
To reproduce
Steps to reproduce the behavior:
esnext-example
plugin usingnpx @wordpress/create-block
create-block/esnext-example
block and Save.sb-prevnext-block
plugin - see Create an sb/prevnext block to display Previous and Next links bobbingwide/sb-prevnext-block#1 )sb/sb-prevnext-block
and Save.sb-prevnext-block
plugin usingnpm run build
.src/edit.js
file of the second plugin ( sb-prevnext-block in my case ) - see changes below.npm start
.npm run build
Step 12. Changes to src\edit.js
Step 16. Build output
Expected behavior
Assuming that the code I've changed is correct, since it worked when built with
npm start
, then I'd expect the results to be the same as for the development build.BUT, I have a number of questions
npm install @wordpress/package-name --save
?npm start
when I haven't installed these packages?All of the above seemed to be reasonable attempts to use the correct package name when referring to existing documentation.
References to be supplied.
Screenshots
Screenshot for step 8 - let's ignore the fact we can't see the text for now.
Screenshot for step 18.
Screenshot with WordPress 5.4.2 & Gutenberg 8.6.1
The text for the esnext-example block becomes visible with Gutenberg 8.6.1
Editor version (please complete the following information):
These are the results with the
sb/sb-prevnext-block
with the above modifications built usingnpm run build
.The block works when built with
npm start
.Desktop (please complete the following information):
Additional context
npm --version 6.14.5
node -v 10.13.0
From
package.json
The text was updated successfully, but these errors were encountered: