-
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
wp-scripts production builds with name conflicts #55442
Comments
Can you share more details about your configuration and structure of the project, the errors you see printed? Do you have two The issues you referenced was about the lack of support for unique names for variables generated by webpack. The way it works with webpack 5 is through
|
I have only one package.json and node_modules and run wp-scripts twice, for generate a build folder inside the plugin and theme. So you think that is the reason why conflicts can happen? Because |
@chimok, have you tried using two entry points with a single {
"scripts": {
"build": "wp-scripts build entry-one.js entry-two.js"
}
} It's also possible to create a custom webpack config like as covered in https://github.com/WordPress/gutenberg/tree/trunk/packages/scripts#extending-the-webpack-config. In this case, maybe it even makes sense to export two configurations from a single file: https://webpack.js.org/configuration/configuration-types/#exporting-multiple-configurations. |
@gziolo If I take your suggestion, how can I configure the destination of my build folder? Update: I saw now the second link in your answer and it answers the question. I will try it and report back. The plugin build folder ( The theme ( Of course I could move everything from the plugin into my theme or setup a independent build for theme and plugin (the later is the common choice). If you believe that will certainly fix the issue I'll try it. I use the plugin mostly for real backend stuff and theme independent code. Have only one package.json / node_modules is faster and less work for my git pipeline, that's why I choose this setup. |
I hear you and can only say that both Gutenberg and WordPress core took the same approach to orchestrating everything from one place: There is single config file for webpack with multiple different configurations 😀 |
Everything worked well. However, it was a lot work because I want the auto. block.json parsing and this part wasn't easy to reuse because it requires to set gutenberg/packages/scripts/utils/config.js Line 191 in ea2230d
I close the ticket since it's possible with the custom webpack.config.js |
Description
I use @wordpress/scripts for my plugin and for the theme and run regularly into trouble my production builds do behave/work very different compared to the non-minified dev build.
Because it generates functions like
a()
orb()
it's possible it conflicts with other minified code. I saw such problems occur in the past and should be fixed: #27985But I still have it. @gziolo Let me know if you need more information.
Step-by-step reproduction instructions
npm run start
- everything should work as expected.npm run build
Screenshots, screen recording, code snippet
No response
Environment info
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes
The text was updated successfully, but these errors were encountered: