JS error after enable bundling functionality: Uncaught Error: Mismatched anonymous define() module: undefined

Comments

5 comments

  • Avatar
    Erolfes

    Hi,

    i have magento 2.4.5 and i got the same error, did you fix the problem?

    0
    Comment actions Permalink
  • Avatar
    Carr Liang

    Hi Pedro,

    Did you fix this issue? I got the same error in magento 2.4.4-p1

    0
    Comment actions Permalink
  • Avatar
    Koncz Szabocls

    Hi guys, 

    Issue seems to be from magento's  core file: https://github.com/magento/magento2/blob/2.4.5-p1/lib/web/jquery/ui-modules/core.js

    Affected versions seem to be 2.4.4 and 2.4.5 including all patched versions.


    Quick fix for this would be to apply a patch for this file in your Magento's instance and replace it with the following content:

    ( function() {
    "use strict";

    define('jquery/ui-modules/core', [
    "jquery",
    "./data",
    "./disable-selection",
    "./focusable",
    "./form",
    "./ie",
    "./keycode",
    "./labels",
    "./jquery-patch",
    "./plugin",
    "./safe-active-element",
    "./safe-blur",
    "./scroll-parent",
    "./tabbable",
    "./unique-id",
    "./version"
    ] );
    } )();

    Or in your bundling file, advancedbunlding_build.js replace  the following  last lines: 

        ]
    });

     

    with:

     

    ],

    onBuildRead: function (moduleName, path, contents) {
    if (moduleName == 'jquery/ui-modules/core') {
    if (
    contents.includes('"./disable-selection",') &&
    contents.includes('"./focusable",') &&
    contents.includes('"./keycode"') &&
    contents.includes('"./safe-active-element"')
    ) {
    contents = contents.replace("define( [", "define([");
    contents = contents.replace("define([", "define('jquery/ui-modules/core', [");
    }

    }
    return contents;
    }
    });

    In the new version of the module this fix will be included as well.

     

    Regards,

    Szabi

    1
    Comment actions Permalink
  • Avatar
    Muhamann

    THANK YOU Koncz Szabocls

    I have the same problem and luckily you answered exactly the right answer 2 days ago :))))

    This is definitly a bug in Weltpixel Speed Optimizing Modul!
    After bundling on all pages in Store the JS-error occurs "Uncaught Error: Mismatched anonymous define() module: undefined". The error links to a file which is not part of the bundling-file, so there is no solution.

    Thank you for yours, saved my day !!

    0
    Comment actions Permalink
  • Avatar
    Koncz Szabocls

    Hi,

    Actually it is an issue of magento’s core.js file as I mentioned, they define that module without a name, so this is causing tbe bundling to throw that error.
    But this fix will be included in the SpeedOptimization module as well.

    0
    Comment actions Permalink

Please sign in to leave a comment.