question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Mixins are not applied for bundled modules

See original GitHub issue

Hey! 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:

  1. 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.
  2. Make mixins.js bundling-aware by reimplementing whole toUrl to nameToUrl chain so that it doesn’t have if (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:open
  • Created 4 years ago
  • Reactions:6
  • Comments:13 (5 by maintainers)

github_iconTop GitHub Comments

11reactions
wigmancommented, Dec 17, 2019

I have turned the above PR into a patch here: https://github.com/integer-net/magento2-requirejs-bundling

4reactions
DrewMLcommented, Oct 30, 2019

Spoke a bit offline, and @krzksz is going to take a stab at fixing this 🎉

Read more comments on GitHub >

github_iconTop Results From Across the Web

Magento 2 - advanced JS bundling mixins
The problem is that mixin module is not fully required in the browser when all the other modules (in shared.js) are being defined...
Read more >
Sass mixin not being imported or compiled - Stack Overflow
Everything seems to be working fine, however a mixin that is located in an imported scss file will not work and I get...
Read more >
7. Package Description — Cabal 3.4.0.0 User's Guide
The value of this field is not used by Cabal and is rather intended as extra metadata for use ... so we only...
Read more >
Modular Object-Oriented Programming with Units and Mixins z
its superclass, so it can be applied multiple times to create different derived classes from different base classes. The ad- vantages of units...
Read more >
sass-loader - webpack - JS.ORG
webpack is a module bundler. Its main purpose is to bundle JavaScript files for usage in a browser, yet it is also capable...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found