Maybe you would know why after advanced bundling product gallery script is not executed?
It might be solved in another way (simple and stupid). Both Magento and Requirejs text.js files might be merged into one, but split by
if (typeof window === 'undefined')
So on backend side correct Requirejs file will do the magic, while there will be Magento file executed on frontend
I have fixed this problem by replacing in my build.js paths section following line
This solution works for me (magento version is 2.4.4-p2).
I also got the same error.
And follow your guide to fix it.