Mixins are not applied for bundled modules
See original GitHub issueHey! First of all I need to say that I’m really impressed with the performance of this solution an ease of use in relation to other tools which take advantage of headless browsers etc., great work!
Unfortunately, when I gave baler for a spin it seems like we hit the same obstacle that I did and documented under https://github.com/magesuite/magepack#modules-with-mixins-defined-cannot-be-included-in-a-bundle
The issue comes from mixins.js file and its processNames
method which is (as far as I understand) responsible for prepending given modules’ names with mixins!
prefix in case certain module has any mixins defined for it so that they can be applied when it is loaded. The problem is that in order to get a path for said module, getPath
is called, which then calls require.toUrl
. Multiple calls later we land inside require’s nameToUrl
method:
nameToUrl: function (moduleName, ext, skipExt) {
var paths, syms, i, parentModule, url,
parentPath, bundleId,
pkgMain = getOwn(config.pkgs, moduleName);
if (pkgMain) {
moduleName = pkgMain;
}
bundleId = getOwn(bundlesMap, moduleName); // OH NO
if (bundleId) { // NO NO NO PLEASE NO
return context.nameToUrl(bundleId, ext, skipExt);
}
As you may have figured out, for each of our modules that were included in core bundle we are getting balerbundles/core-bundle
instead of the actual name. Because of the fact that stock Magento makes use of mixins, even for providing jquery security patches I would say this issue is critical and should be addressed ASAP before anyone uses this solution in production.
There are 2 possible ways this can be solved:
- Don’t include modules which have any mixins defined in the bundle, which will hurt performance and I’m not sure if it is even possible to determine that 100% statically.
- Make
mixins.js
bundling-aware by reimplementing wholetoUrl
tonameToUrl
chain so that it doesn’t haveif (bundleId) {
check in it.
That’s all that I can see right now, I’ll try to hack around a bit to see what the simplest route would be.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:6
- Comments:13 (5 by maintainers)
Top GitHub Comments
I have turned the above PR into a patch here: https://github.com/integer-net/magento2-requirejs-bundling
Spoke a bit offline, and @krzksz is going to take a stab at fixing this 🎉