-
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
Scripts: Breakage of multiple entry points of the same filename in separate folders #36497
Comments
The build creates two entry points: It makes me wonder whether you started using Related PR: #34264. If you want to bundle all the passed scripts together then |
Thanks taking time to test this @gziolo 🙇 . I apologize that I missed the crucial point to reproduce this and that is using |
Thank you for providing more details. I will give it a spin tomorrow and report back on what I discovered. As far as I can tell the fact that both entry points use the same name |
I can confirm that the issue is coming from the exact same name used for the file. One way to go around it looks as follows: npx wp-scripts build ./src/index.js timeslot=./src/timeslot/index.js It will create two entry points in the build folder:
So the difference is that |
Thanks again @gziolo. The projects in which I ran into this are all parent/child blocks so I prefer the single bundle and using I'm thinking it'd be a good idea to update the docs by changing the custom
As I've since learned that webpack will use the directory name as the name for the entry point. Though, if it's better to be more explicit:
That may prevent new projects getting hung up on this. |
In #25188, we discuss several options to make the support for multiple blocks more automated. Maybe the best way to move forward is to settle on a few basic patterns for detecting entry points. It looks like webpack has changed the opinion too drastically on handling multiple paths provided between webpack v4 and v5. It's tough to come up with a good recommendation now. @stokesman, have you tested? "build:custom": "wp-scripts build ./src/one/ ./src/two/ --output-path=custom" Does it produce two entry points |
Yes, I've tested and the output is as you wrote— |
@stokesman, should we update the docs in |
It seems related. I'm using a custom webpack config file that looks like this:
You could possibly do some magic to the filename in output to add sub folder name to the output etc? |
I’m closing this as water under the bridge. |
Description
The documentation for
build
andstart
demonstrates space separated paths for multiple entry points:In a couple projects I used that approach but with each entry point in a separate folder:
After upgrading @wordpress/scripts from 17 to 19 running either
build
orstart
would build/bundle only the last of the files listed. After reading through #34264 I found that using--entry
is a way to get it working again:So this could be seen as a documentation issue and expounding in the docs to cover this nuance may be the easiest "fix". An important note being that using
--entry
the built JS and CSS filenames will change (to main.*). At present, there doesn't seem to be an easy way to preserve theindex
filenames (noted: #34264 (comment)).I think ideally scripts could fixed to preserve how things worked with v17. Though maybe it's more effort than what the seemingly uncommon breakage is worth and the better approach is updating the docs (and ideally the changelog to mention the specific breakage around multiple entry points that have the same filename).
Step-by-step reproduction instructions
build
command like the following:npm run build
Screenshots, screen recording, code snippet
@wordpress/scripts 17.1.0 and webpack 4
In an project I haven't bothered to upgrade I tested the build
wordpress/scripts 19.1.0 and webpack 5
In a separate project created for testing, it can be seen that only the latter entry is actually built:
Environment info
No response
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
No
The text was updated successfully, but these errors were encountered: