From e285d53709a6e58c2512637e5fc4134c9c1533e4 Mon Sep 17 00:00:00 2001
From: Alexandra Zota <zota@adobe.com>
Date: Thu, 5 Mar 2026 13:16:52 +0200
Subject: [PATCH] ACP2E-4626: [Cloud] RequireJS mixins.js causes duplicate
 script loading for all deps modules.

Strip 'deps' and 'callback' from the cfg object before forwarding to the
unbundled ($) RequireJS context. RequireJS internally calls
context.require(cfg.deps) when deps is present, so forwarding the full
cfg caused every module in any requirejs-config.js deps array
(mage/common, mage/dataPost, mage/bootstrap, Magento_Ui/js/core/app,
Magento_Theme/js/theme, etc.) to be loaded twice -- once in the default
'_' context (correctly minified) and once in the '$' unbundled context
(without the min-resolver, producing 404s for non-existent .js files).

Upstream: https://github.com/magento/magento2/commit/e285d53709a6e58c2512637e5fc4134c9c1533e4
Issue:    https://github.com/magento/magento2/issues/40527
---
 lib/web/mage/requirejs/mixins.js | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/lib/web/mage/requirejs/mixins.js b/lib/web/mage/requirejs/mixins.js
--- a/lib/web/mage/requirejs/mixins.js
+++ b/lib/web/mage/requirejs/mixins.js
@@ -227,8 +227,17 @@ require([
      * that way it is able to respect any changes done after mixins module has initialized.
      */
     defContext.configure = function (cfg) {
+        var unbundledCfg = {};
+
         originalContextConfigure(cfg);
-        unbundledContext.configure(cfg);
+
+        Object.keys(cfg || {}).forEach(function (key) {
+            if (key !== 'deps' && key !== 'callback') {
+                unbundledCfg[key] = cfg[key];
+            }
+        });
+
+        unbundledContext.configure(unbundledCfg);
     };

     /**
