-
Notifications
You must be signed in to change notification settings - Fork 90
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
List modules in a consistent order #166
base: master
Are you sure you want to change the base?
Conversation
@fredden Testing out an alternative approach to #120 - it doesn't require creating a new context or re-loading everything so it's a bit faster, for me it does give consistent results, but different than on the other MR for various reasons. I just used
A long time has passed but I'm not seeing this at all against M2.4.3. But, I've only tested with bundling and minification both disabled so maybe that has something to do with it? The dependencyMaps generated here seem more complete. Comparing the dependencyMaps from #120, I note that in that PR I also moved the code which re-ordered the dependency map into a new function orderModules which just takes objects as inputs and is not aware of any page context. That way we should be able to write some tests for that function - to make sure it will always output a working order, that it will deal with circular deps in a general way (I removed the whitelist as I didn't see any examples), maybe shuffling the inputs about and checking the order is always correct. Would be cool if you could run this against the same site and data you were using on #120, perhaps we could converge on something. For me, I don't think #120 can be merged whilst there's an unknown known issue with circular deps, or when the dependency map generation doesn't handle aliases. |
@maaarghk thanks for looking into this. I like the idea of separating out the different components; this will make it easier to add tests going forward. When I worked on #120, I was trying to keep the number of changed files to a minimum. I also like the idea of using Thanks for the code comments. These help a lot when reviewing and will be useful with future maintenance. Are you seeing consistent results when you run this multiple times? When I run From what I can tell, this does produce a consistent load order / result on the websites I've tested this on. I have some minor code style comments, but on the whole this looks good to me. 👍 |
Agreed with all style suggestions and updated accordingly,
I was against a local dev copy of my clients' sites, but didn't try any others yet - I'll try to find some time next week to test it against the site you suggested to see if I can work out why you might not be seeing consistent results. Could be the timeout is just a bit too flakey, I'll see if there's some way to wait for requests to finish too. Something that occurred to me for example is on slow sites, the shipping estimate ajax on /checkout/cart might not finish on time, which might cause any text elements required for that wee panel not to load. |
Fixes #23