├── README.md ├── patches └── composer │ ├── M231 │ ├── github-pr-25587-base.diff │ ├── github-pr-4721-base.diff │ ├── github-pr-4721-braintree.diff │ ├── github-pr-4721-catalog.diff │ ├── github-pr-4721-customer.diff │ ├── github-pr-4721-msrp.diff │ ├── github-pr-4721-paypal.diff │ └── github-pr-4721-theme.diff │ ├── M232 │ ├── github-pr-25587-base.diff │ ├── github-pr-4721-base.diff │ ├── github-pr-4721-braintree.diff │ ├── github-pr-4721-catalog.diff │ ├── github-pr-4721-customer.diff │ ├── github-pr-4721-msrp.diff │ ├── github-pr-4721-paypal.diff │ └── github-pr-4721-theme.diff │ ├── M233 │ ├── github-pr-25587-base.diff │ ├── github-pr-27690-base.diff │ ├── github-pr-4721-base.diff │ ├── github-pr-4721-braintree.diff │ ├── github-pr-4721-catalog.diff │ ├── github-pr-4721-customer.diff │ ├── github-pr-4721-msrp.diff │ ├── github-pr-4721-paypal.diff │ └── github-pr-4721-theme.diff │ └── M234 │ └── github-pr-25587-base.diff └── requirejs-bundle-configuration └── requirejs-bundle-config.js /README.md: -------------------------------------------------------------------------------- 1 | # magento2-requirejs-bundling 2 | Tools, patches and snippets for Magento 2 RequireJS Bundling 3 | 4 | This repository will accompanies our "Ultimate guide to Magento 2 JavaScript bundling" blog post on https://www.integer-net.com/ultimate-guide-magento-2-javascript-bundling/. 5 | 6 | ## RequireJS bundling config 7 | There's an example `requirejs-bundle-config.js` file here [/requirejs-bundle-configuration](/requirejs-bundle-configuration) 8 | 9 | If you look at the diff of the last commit, you can see the changes we made to the default bundle confuration generated by the [M2 DevTools extension](https://github.com/magento/m2-devtools/) 10 | 11 | ## Patches 12 | 13 | ! Starting version 2.3.6 patches are no longer needed. 14 | 15 | To use RequireJS bundling in Magento 2 (up to version 2.3.5) you need a few patches: 16 | 17 | - https://github.com/magento/magento2/pull/25587 18 | - https://github.com/magento/magento2/commit/db43c11c6830465b764ede32abb7262258e5f574 19 | 20 | You can download them from this repository and place them in the root of your Magento project. 21 | Next install `cweagans/composerpatches`. 22 | ```bash 23 | composer require cweagans/composer-patches 24 | ``` 25 | 26 | Then add this to your `composer.json` file under `extra`. 27 | 28 | For Magento 2.3.1: 29 | ```json 30 | "extra": { 31 | "magento-force": "override", 32 | "composer-exit-on-patch-failure": true, 33 | "patches": { 34 | "magento/magento2-base": { 35 | "[Performance] Fix missing shims and phtml files with mage-init directives (https://github.com/magento/magento2/commit/db43c11c6830465b764ede32abb7262258e5f574)": "patches/composer/M231/github-pr-4721-base.diff", 36 | "Refactor JavaScript mixins module https://github.com/magento/magento2/pull/25587": "patches/composer/M231/github-pr-25587-base.diff" 37 | }, 38 | "magento/module-braintree": { 39 | "[Performance] Fix missing shims and phtml files with mage-init directives (https://github.com/magento/magento2/commit/db43c11c6830465b764ede32abb7262258e5f574)": "patches/composer/M231/github-pr-4721-braintree.diff" 40 | }, 41 | "magento/module-catalog": { 42 | "[Performance] Fix missing shims and phtml files with mage-init directives (https://github.com/magento/magento2/commit/db43c11c6830465b764ede32abb7262258e5f574)": "patches/composer/M231/github-pr-4721-catalog.diff" 43 | }, 44 | "magento/module-customer": { 45 | "[Performance] Fix missing shims and phtml files with mage-init directives (https://github.com/magento/magento2/commit/db43c11c6830465b764ede32abb7262258e5f574)": "patches/composer/M231/github-pr-4721-customer.diff" 46 | }, 47 | "magento/module-msrp": { 48 | "[Performance] Fix missing shims and phtml files with mage-init directives (https://github.com/magento/magento2/commit/db43c11c6830465b764ede32abb7262258e5f574)": "patches/composer/M231/github-pr-4721-msrp.diff" 49 | }, 50 | "magento/module-paypal": { 51 | "[Performance] Fix missing shims and phtml files with mage-init directives (https://github.com/magento/magento2/commit/db43c11c6830465b764ede32abb7262258e5f574)": "patches/composer/M231/github-pr-4721-paypal.diff" 52 | }, 53 | "magento/module-theme": { 54 | "[Performance] Fix missing shims and phtml files with mage-init directives (https://github.com/magento/magento2/commit/db43c11c6830465b764ede32abb7262258e5f574)": "patches/composer/M231/github-pr-4721-theme.diff" 55 | } 56 | } 57 | } 58 | ``` 59 | For Magento 2.3.2: 60 | ```json 61 | "extra": { 62 | "magento-force": "override", 63 | "composer-exit-on-patch-failure": true, 64 | "patches": { 65 | "magento/magento2-base": { 66 | "[Performance] Fix missing shims and phtml files with mage-init directives (https://github.com/magento/magento2/commit/db43c11c6830465b764ede32abb7262258e5f574)": "patches/composer/M232/github-pr-4721-base.diff", 67 | "Refactor JavaScript mixins module https://github.com/magento/magento2/pull/25587": "patches/composer/M232/github-pr-25587-base.diff" 68 | }, 69 | "magento/module-braintree": { 70 | "[Performance] Fix missing shims and phtml files with mage-init directives (https://github.com/magento/magento2/commit/db43c11c6830465b764ede32abb7262258e5f574)": "patches/composer/M232/github-pr-4721-braintree.diff" 71 | }, 72 | "magento/module-catalog": { 73 | "[Performance] Fix missing shims and phtml files with mage-init directives (https://github.com/magento/magento2/commit/db43c11c6830465b764ede32abb7262258e5f574)": "patches/composer/M232/github-pr-4721-catalog.diff" 74 | }, 75 | "magento/module-customer": { 76 | "[Performance] Fix missing shims and phtml files with mage-init directives (https://github.com/magento/magento2/commit/db43c11c6830465b764ede32abb7262258e5f574)": "patches/composer/M232/github-pr-4721-customer.diff" 77 | }, 78 | "magento/module-msrp": { 79 | "[Performance] Fix missing shims and phtml files with mage-init directives (https://github.com/magento/magento2/commit/db43c11c6830465b764ede32abb7262258e5f574)": "patches/composer/M232/github-pr-4721-msrp.diff" 80 | }, 81 | "magento/module-paypal": { 82 | "[Performance] Fix missing shims and phtml files with mage-init directives (https://github.com/magento/magento2/commit/db43c11c6830465b764ede32abb7262258e5f574)": "patches/composer/M232/github-pr-4721-paypal.diff" 83 | }, 84 | "magento/module-theme": { 85 | "[Performance] Fix missing shims and phtml files with mage-init directives (https://github.com/magento/magento2/commit/db43c11c6830465b764ede32abb7262258e5f574)": "patches/composer/M232/github-pr-4721-theme.diff" 86 | } 87 | } 88 | } 89 | ``` 90 | 91 | For Magento 2.3.3: 92 | ```json 93 | "extra": { 94 | "magento-force": "override", 95 | "composer-exit-on-patch-failure": true, 96 | "patches": { 97 | "magento/magento2-base": { 98 | "[Performance] Fix missing shims and phtml files with mage-init directives (https://github.com/magento/magento2/commit/db43c11c6830465b764ede32abb7262258e5f574)": "patches/composer/M233/github-pr-4721-base.diff", 99 | "Refactor JavaScript mixins module https://github.com/magento/magento2/pull/25587": "patches/composer/M233/github-pr-25587-base.diff", 100 | "Fix handling of mixins for modules with no dependencies defined (https://github.com/magento/magento2/pull/27690/commits/97f0a1f34efc7c40c97014800cc876e9aedcdc0f)": "patches/composer/M233/github-pr-27690-base.diff" 101 | }, 102 | "magento/module-braintree": { 103 | "[Performance] Fix missing shims and phtml files with mage-init directives (https://github.com/magento/magento2/commit/db43c11c6830465b764ede32abb7262258e5f574)": "patches/composer/M233/github-pr-4721-braintree.diff" 104 | }, 105 | "magento/module-catalog": { 106 | "[Performance] Fix missing shims and phtml files with mage-init directives (https://github.com/magento/magento2/commit/db43c11c6830465b764ede32abb7262258e5f574)": "patches/composer/M233/github-pr-4721-catalog.diff" 107 | }, 108 | "magento/module-customer": { 109 | "[Performance] Fix missing shims and phtml files with mage-init directives (https://github.com/magento/magento2/commit/db43c11c6830465b764ede32abb7262258e5f574)": "patches/composer/M233/github-pr-4721-customer.diff" 110 | }, 111 | "magento/module-msrp": { 112 | "[Performance] Fix missing shims and phtml files with mage-init directives (https://github.com/magento/magento2/commit/db43c11c6830465b764ede32abb7262258e5f574)": "patches/composer/M233/github-pr-4721-msrp.diff" 113 | }, 114 | "magento/module-paypal": { 115 | "[Performance] Fix missing shims and phtml files with mage-init directives (https://github.com/magento/magento2/commit/db43c11c6830465b764ede32abb7262258e5f574)": "patches/composer/M233/github-pr-4721-paypal.diff" 116 | }, 117 | "magento/module-theme": { 118 | "[Performance] Fix missing shims and phtml files with mage-init directives (https://github.com/magento/magento2/commit/db43c11c6830465b764ede32abb7262258e5f574)": "patches/composer/M233/github-pr-4721-theme.diff" 119 | } 120 | } 121 | } 122 | ``` 123 | 124 | For Magento 2.3.4 abd 2.3.5: 125 | ```json 126 | "extra": { 127 | "magento-force": "override", 128 | "composer-exit-on-patch-failure": true, 129 | "patches": { 130 | "magento/magento2-base": { 131 | "Refactor JavaScript mixins module https://github.com/magento/magento2/pull/25587": "patches/composer/M234/github-pr-25587-base.diff" 132 | } 133 | } 134 | } 135 | ``` 136 | 137 | For Magento 2.3.4 abd 2.3.6: 138 | NO PATCHES NEEDED 139 | -------------------------------------------------------------------------------- /patches/composer/M231/github-pr-25587-base.diff: -------------------------------------------------------------------------------- 1 | From 540b1340275b001aca44ce3d889a039614167a8e Mon Sep 17 00:00:00 2001 2 | From: Mateusz Krzeszowiak 3 | Date: Wed, 13 Nov 2019 18:10:05 +0100 4 | Subject: [PATCH] Refactor JavaScript mixins module 5 | 6 | Fixes https://github.com/magento/magento2/issues/25586. 7 | --- 8 | lib/web/mage/requirejs/mixins.js | 152 ++++++++++++------------------- 9 | 1 file changed, 57 insertions(+), 95 deletions(-) 10 | 11 | diff --git a/lib/web/mage/requirejs/mixins.js b/lib/web/mage/requirejs/mixins.js 12 | index 77d98e0f8139..acda3ebf467d 100644 13 | --- a/lib/web/mage/requirejs/mixins.js 14 | +++ b/lib/web/mage/requirejs/mixins.js 15 | @@ -7,7 +7,25 @@ define('mixins', [ 16 | ], function (module) { 17 | 'use strict'; 18 | 19 | - var rjsMixins; 20 | + var contexts = require.s.contexts, 21 | + defContextName = '_', 22 | + defContext = contexts[defContextName], 23 | + unbundledContext = require.s.newContext('$'), 24 | + defaultConfig = defContext.config, 25 | + unbundledConfig = { 26 | + baseUrl: defaultConfig.baseUrl, 27 | + paths: defaultConfig.paths, 28 | + shim: defaultConfig.shim, 29 | + config: defaultConfig.config, 30 | + map: defaultConfig.map 31 | + }, 32 | + rjsMixins; 33 | + 34 | + /** 35 | + * Prepare a separate context where modules are not assigned to bundles 36 | + * so we are able to get their true path and corresponding mixins. 37 | + */ 38 | + unbundledContext.configure(unbundledConfig); 39 | 40 | /** 41 | * Checks if specified string contains 42 | @@ -50,14 +68,14 @@ define('mixins', [ 43 | 44 | /** 45 | * Extracts url (without baseUrl prefix) 46 | - * from a modules' name. 47 | + * from a module name ignoring the fact that it may be bundled. 48 | * 49 | * @param {String} name - Name, path or alias of a module. 50 | - * @param {Object} config - Contexts' configuartion. 51 | + * @param {Object} config - Context's configuartion. 52 | * @returns {String} 53 | */ 54 | function getPath(name, config) { 55 | - var url = require.toUrl(name); 56 | + var url = unbundledContext.require.toUrl(name); 57 | 58 | return removeBaseUrl(url, config); 59 | } 60 | @@ -73,11 +91,11 @@ define('mixins', [ 61 | } 62 | 63 | /** 64 | - * Iterativly calls mixins passing to them 65 | + * Iteratively calls mixins passing to them 66 | * current value of a 'target' parameter. 67 | * 68 | * @param {*} target - Value to be modified. 69 | - * @param {...Function} mixins 70 | + * @param {...Function} mixins - List of mixins to apply. 71 | * @returns {*} Modified 'target' value. 72 | */ 73 | function applyMixins(target) { 74 | @@ -94,8 +112,13 @@ define('mixins', [ 75 | 76 | /** 77 | * Loads specified module along with its' mixins. 78 | + * This method is called for each module defined with "mixins!" prefix 79 | + * in its name that was added by processNames method. 80 | * 81 | * @param {String} name - Module to be loaded. 82 | + * @param {Function} req - Local "require" function to use to load other modules. 83 | + * @param {Function} onLoad - A function to call with the value for name. 84 | + * @param {Object} config - RequireJS configuration object. 85 | */ 86 | load: function (name, req, onLoad, config) { 87 | var path = getPath(name, config), 88 | @@ -110,14 +133,14 @@ define('mixins', [ 89 | /** 90 | * Retrieves list of mixins associated with a specified module. 91 | * 92 | - * @param {String} path - Path to the module (without base url). 93 | + * @param {String} path - Path to the module (without base URL). 94 | * @returns {Array} An array of paths to mixins. 95 | */ 96 | getMixins: function (path) { 97 | var config = module.config() || {}, 98 | - mixins; 99 | + mixins; 100 | 101 | - // fix for when urlArgs is set 102 | + // Fix for when urlArgs is set. 103 | if (path.indexOf('?') !== -1) { 104 | path = path.substring(0, path.indexOf('?')); 105 | } 106 | @@ -131,7 +154,7 @@ define('mixins', [ 107 | /** 108 | * Checks if specified module has associated with it mixins. 109 | * 110 | - * @param {String} path - Path to the module (without base url). 111 | + * @param {String} path - Path to the module (without base URL). 112 | * @returns {Boolean} 113 | */ 114 | hasMixins: function (path) { 115 | @@ -139,11 +162,11 @@ define('mixins', [ 116 | }, 117 | 118 | /** 119 | - * Modifies provided names perpending to them 120 | + * Modifies provided names prepending to them 121 | * the 'mixins!' plugin prefix if it's necessary. 122 | * 123 | * @param {(Array|String)} names - Module names, paths or aliases. 124 | - * @param {Object} context - Current requirejs context. 125 | + * @param {Object} context - Current RequireJS context. 126 | * @returns {Array|String} 127 | */ 128 | processNames: function (names, context) { 129 | @@ -179,101 +202,40 @@ require([ 130 | ], function (mixins) { 131 | 'use strict'; 132 | 133 | - var originalRequire = window.require, 134 | - originalDefine = window.define, 135 | - contexts = originalRequire.s.contexts, 136 | - defContextName = '_', 137 | - hasOwn = Object.prototype.hasOwnProperty, 138 | - getLastInQueue; 139 | - 140 | - getLastInQueue = 141 | - '(function () {' + 142 | - 'var queue = globalDefQueue,' + 143 | - 'item = queue[queue.length - 1];' + 144 | - '' + 145 | - 'return item;' + 146 | - '})();'; 147 | - 148 | - /** 149 | - * Returns property of an object if 150 | - * it's not defined in it's prototype. 151 | - * 152 | - * @param {Object} obj - Object whose property should be retrieved. 153 | - * @param {String} prop - Name of the property. 154 | - * @returns {*} Value of the property or false. 155 | - */ 156 | - function getOwn(obj, prop) { 157 | - return hasOwn.call(obj, prop) && obj[prop]; 158 | - } 159 | - 160 | - /** 161 | - * Overrides global 'require' method adding to it dependencies modfication. 162 | - */ 163 | - window.require = function (deps, callback, errback, optional) { 164 | - var contextName = defContextName, 165 | - context, 166 | - config; 167 | - 168 | - if (!Array.isArray(deps) && typeof deps !== 'string') { 169 | - config = deps; 170 | - 171 | - if (Array.isArray(callback)) { 172 | - deps = callback; 173 | - callback = errback; 174 | - errback = optional; 175 | - } else { 176 | - deps = []; 177 | - } 178 | - } 179 | - 180 | - if (config && config.context) { 181 | - contextName = config.context; 182 | - } 183 | - 184 | - context = getOwn(contexts, contextName); 185 | - 186 | - if (!context) { 187 | - context = contexts[contextName] = require.s.newContext(contextName); 188 | - } 189 | - 190 | - if (config) { 191 | - context.configure(config); 192 | - } 193 | - 194 | - deps = mixins.processNames(deps, context); 195 | - 196 | - return context.require(deps, callback, errback); 197 | - }; 198 | + var contexts = require.s.contexts, 199 | + defContextName = '_', 200 | + defContext = contexts[defContextName], 201 | + originalContextRequire = defContext.require, 202 | + processNames = mixins.processNames; 203 | 204 | /** 205 | - * Overrides global 'define' method adding to it dependencies modfication. 206 | + * Wrap default context's require function which gets called every time 207 | + * module is requested using require call. The upside of this approach 208 | + * is that deps parameter is already normalized and guaranteed to be an array. 209 | */ 210 | - window.define = function (name, deps, callback) { // eslint-disable-line no-unused-vars 211 | - var context = getOwn(contexts, defContextName), 212 | - result = originalDefine.apply(this, arguments), 213 | - queueItem = require.exec(getLastInQueue), 214 | - lastDeps = queueItem && queueItem[1]; 215 | - 216 | - if (Array.isArray(lastDeps)) { 217 | - queueItem[1] = mixins.processNames(lastDeps, context); 218 | - } 219 | + defContext.require = function (deps, callback, errback) { 220 | + deps = processNames(deps, defContext); 221 | 222 | - return result; 223 | + return originalContextRequire(deps, callback, errback); 224 | }; 225 | 226 | /** 227 | * Copy properties of original 'require' method. 228 | */ 229 | - Object.keys(originalRequire).forEach(function (key) { 230 | - require[key] = originalRequire[key]; 231 | + Object.keys(originalContextRequire).forEach(function (key) { 232 | + defContext.require[key] = originalContextRequire[key]; 233 | }); 234 | 235 | /** 236 | - * Copy properties of original 'define' method. 237 | + * Wrap shift method from context's definitions queue. 238 | + * Items are added to the queue when a new module is defined and taken 239 | + * from it every time require call happens. 240 | */ 241 | - Object.keys(originalDefine).forEach(function (key) { 242 | - define[key] = originalDefine[key]; 243 | - }); 244 | + defContext.defQueue.shift = function () { 245 | + var queueItem = Array.prototype.shift.call(this); 246 | + 247 | + queueItem[1] = processNames(queueItem[1], defContext); 248 | 249 | - window.requirejs = window.require; 250 | + return queueItem; 251 | + }; 252 | }); 253 | -------------------------------------------------------------------------------- /patches/composer/M231/github-pr-4721-base.diff: -------------------------------------------------------------------------------- 1 | diff --git a/lib/web/jquery/jquery.storageapi.min.js b/lib/web/jquery/jquery.storageapi.min.js 2 | index e196b0678934..886c3d847ed3 100644 3 | --- a/lib/web/jquery/jquery.storageapi.min.js 4 | +++ b/lib/web/jquery/jquery.storageapi.min.js 5 | @@ -1,2 +1,2 @@ 6 | /* jQuery Storage API Plugin 1.7.3 https://github.com/julien-maurel/jQuery-Storage-API */ 7 | -!function(e){"function"==typeof define&&define.amd?define(["jquery"],e):e("object"==typeof exports?require("jquery"):jQuery)}(function(e){function t(t){var r,i,n,o=arguments.length,s=window[t],a=arguments,u=a[1];if(2>o)throw Error("Minimum 2 arguments must be given");if(e.isArray(u)){i={};for(var f in u){r=u[f];try{i[r]=JSON.parse(s.getItem(r))}catch(c){i[r]=s.getItem(r)}}return i}if(2!=o){try{i=JSON.parse(s.getItem(u))}catch(c){throw new ReferenceError(u+" is not defined in this storage")}for(var f=2;o-1>f;f++)if(i=i[a[f]],void 0===i)throw new ReferenceError([].slice.call(a,1,f+1).join(".")+" is not defined in this storage");if(e.isArray(a[f])){n=i,i={};for(var m in a[f])i[a[f][m]]=n[a[f][m]];return i}return i[a[f]]}try{return JSON.parse(s.getItem(u))}catch(c){return s.getItem(u)}}function r(t){var r,i,n=arguments.length,o=window[t],s=arguments,a=s[1],u=s[2],f={};if(2>n||!e.isPlainObject(a)&&3>n)throw Error("Minimum 3 arguments must be given or second parameter must be an object");if(e.isPlainObject(a)){for(var c in a)r=a[c],e.isPlainObject(r)?o.setItem(c,JSON.stringify(r)):o.setItem(c,r);return a}if(3==n)return"object"==typeof u?o.setItem(a,JSON.stringify(u)):o.setItem(a,u),u;try{i=o.getItem(a),null!=i&&(f=JSON.parse(i))}catch(m){}i=f;for(var c=2;n-2>c;c++)r=s[c],i[r]&&e.isPlainObject(i[r])||(i[r]={}),i=i[r];return i[s[c]]=s[c+1],o.setItem(a,JSON.stringify(f)),f}function i(t){var r,i,n=arguments.length,o=window[t],s=arguments,a=s[1];if(2>n)throw Error("Minimum 2 arguments must be given");if(e.isArray(a)){for(var u in a)o.removeItem(a[u]);return!0}if(2==n)return o.removeItem(a),!0;try{r=i=JSON.parse(o.getItem(a))}catch(f){throw new ReferenceError(a+" is not defined in this storage")}for(var u=2;n-1>u;u++)if(i=i[s[u]],void 0===i)throw new ReferenceError([].slice.call(s,1,u).join(".")+" is not defined in this storage");if(e.isArray(s[u]))for(var c in s[u])delete i[s[u][c]];else delete i[s[u]];return o.setItem(a,JSON.stringify(r)),!0}function n(t,r){var n=a(t);for(var o in n)i(t,n[o]);if(r)for(var o in e.namespaceStorages)u(o)}function o(r){var i=arguments.length,n=arguments,s=(window[r],n[1]);if(1==i)return 0==a(r).length;if(e.isArray(s)){for(var u=0;ui)throw Error("Minimum 2 arguments must be given");if(e.isArray(o)){for(var a=0;a1?t.apply(this,o):n,a._cookie)for(var u in e.cookie())""!=u&&s.push(u.replace(a._prefix,""));else for(var f in a)s.push(f);return s}function u(t){if(!t||"string"!=typeof t)throw Error("First parameter must be a string");g?(window.localStorage.getItem(t)||window.localStorage.setItem(t,"{}"),window.sessionStorage.getItem(t)||window.sessionStorage.setItem(t,"{}")):(window.localCookieStorage.getItem(t)||window.localCookieStorage.setItem(t,"{}"),window.sessionCookieStorage.getItem(t)||window.sessionCookieStorage.setItem(t,"{}"));var r={localStorage:e.extend({},e.localStorage,{_ns:t}),sessionStorage:e.extend({},e.sessionStorage,{_ns:t})};return e.cookie&&(window.cookieStorage.getItem(t)||window.cookieStorage.setItem(t,"{}"),r.cookieStorage=e.extend({},e.cookieStorage,{_ns:t})),e.namespaceStorages[t]=r,r}function f(e){if(!window[e])return!1;var t="jsapi";try{return window[e].setItem(t,t),window[e].removeItem(t),!0}catch(r){return!1}}var c="ls_",m="ss_",g=f("localStorage"),h={_type:"",_ns:"",_callMethod:function(e,t){var r=[this._type],t=Array.prototype.slice.call(t),i=t[0];return this._ns&&r.push(this._ns),"string"==typeof i&&-1!==i.indexOf(".")&&(t.shift(),[].unshift.apply(t,i.split("."))),[].push.apply(r,t),e.apply(this,r)},get:function(){return this._callMethod(t,arguments)},set:function(){var t=arguments.length,i=arguments,n=i[0];if(1>t||!e.isPlainObject(n)&&2>t)throw Error("Minimum 2 arguments must be given or first parameter must be an object");if(e.isPlainObject(n)&&this._ns){for(var o in n)r(this._type,this._ns,o,n[o]);return n}var s=this._callMethod(r,i);return this._ns?s[n.split(".")[0]]:s},remove:function(){if(arguments.length<1)throw Error("Minimum 1 argument must be given");return this._callMethod(i,arguments)},removeAll:function(e){return this._ns?(r(this._type,this._ns,{}),!0):n(this._type,e)},isEmpty:function(){return this._callMethod(o,arguments)},isSet:function(){if(arguments.length<1)throw Error("Minimum 1 argument must be given");return this._callMethod(s,arguments)},keys:function(){return this._callMethod(a,arguments)}};if(e.cookie){window.name||(window.name=Math.floor(1e8*Math.random()));var l={_cookie:!0,_prefix:"",_expires:null,_path:null,_domain:null,setItem:function(t,r){e.cookie(this._prefix+t,r,{expires:this._expires,path:this._path,domain:this._domain})},getItem:function(t){return e.cookie(this._prefix+t)},removeItem:function(t){return e.removeCookie(this._prefix+t)},clear:function(){for(var t in e.cookie())""!=t&&(!this._prefix&&-1===t.indexOf(c)&&-1===t.indexOf(m)||this._prefix&&0===t.indexOf(this._prefix))&&e.removeCookie(t)},setExpires:function(e){return this._expires=e,this},setPath:function(e){return this._path=e,this},setDomain:function(e){return this._domain=e,this},setConf:function(e){return e.path&&(this._path=e.path),e.domain&&(this._domain=e.domain),e.expires&&(this._expires=e.expires),this},setDefaultConf:function(){this._path=this._domain=this._expires=null}};g||(window.localCookieStorage=e.extend({},l,{_prefix:c,_expires:3650}),window.sessionCookieStorage=e.extend({},l,{_prefix:m+window.name+"_"})),window.cookieStorage=e.extend({},l),e.cookieStorage=e.extend({},h,{_type:"cookieStorage",setExpires:function(e){return window.cookieStorage.setExpires(e),this},setPath:function(e){return window.cookieStorage.setPath(e),this},setDomain:function(e){return window.cookieStorage.setDomain(e),this},setConf:function(e){return window.cookieStorage.setConf(e),this},setDefaultConf:function(){return window.cookieStorage.setDefaultConf(),this}})}e.initNamespaceStorage=function(e){return u(e)},g?(e.localStorage=e.extend({},h,{_type:"localStorage"}),e.sessionStorage=e.extend({},h,{_type:"sessionStorage"})):(e.localStorage=e.extend({},h,{_type:"localCookieStorage"}),e.sessionStorage=e.extend({},h,{_type:"sessionCookieStorage"})),e.namespaceStorages={},e.removeAllStorages=function(t){e.localStorage.removeAll(t),e.sessionStorage.removeAll(t),e.cookieStorage&&e.cookieStorage.removeAll(t),t||(e.namespaceStorages={})}}); 8 | \ No newline at end of file 9 | +!function(e){"function"==typeof define&&define.amd?define(["jquery", "jquery/jquery.cookie"],e):e("object"==typeof exports?require("jquery"):jQuery)}(function(e){function t(t){var r,i,n,o=arguments.length,s=window[t],a=arguments,u=a[1];if(2>o)throw Error("Minimum 2 arguments must be given");if(e.isArray(u)){i={};for(var f in u){r=u[f];try{i[r]=JSON.parse(s.getItem(r))}catch(c){i[r]=s.getItem(r)}}return i}if(2!=o){try{i=JSON.parse(s.getItem(u))}catch(c){throw new ReferenceError(u+" is not defined in this storage")}for(var f=2;o-1>f;f++)if(i=i[a[f]],void 0===i)throw new ReferenceError([].slice.call(a,1,f+1).join(".")+" is not defined in this storage");if(e.isArray(a[f])){n=i,i={};for(var m in a[f])i[a[f][m]]=n[a[f][m]];return i}return i[a[f]]}try{return JSON.parse(s.getItem(u))}catch(c){return s.getItem(u)}}function r(t){var r,i,n=arguments.length,o=window[t],s=arguments,a=s[1],u=s[2],f={};if(2>n||!e.isPlainObject(a)&&3>n)throw Error("Minimum 3 arguments must be given or second parameter must be an object");if(e.isPlainObject(a)){for(var c in a)r=a[c],e.isPlainObject(r)?o.setItem(c,JSON.stringify(r)):o.setItem(c,r);return a}if(3==n)return"object"==typeof u?o.setItem(a,JSON.stringify(u)):o.setItem(a,u),u;try{i=o.getItem(a),null!=i&&(f=JSON.parse(i))}catch(m){}i=f;for(var c=2;n-2>c;c++)r=s[c],i[r]&&e.isPlainObject(i[r])||(i[r]={}),i=i[r];return i[s[c]]=s[c+1],o.setItem(a,JSON.stringify(f)),f}function i(t){var r,i,n=arguments.length,o=window[t],s=arguments,a=s[1];if(2>n)throw Error("Minimum 2 arguments must be given");if(e.isArray(a)){for(var u in a)o.removeItem(a[u]);return!0}if(2==n)return o.removeItem(a),!0;try{r=i=JSON.parse(o.getItem(a))}catch(f){throw new ReferenceError(a+" is not defined in this storage")}for(var u=2;n-1>u;u++)if(i=i[s[u]],void 0===i)throw new ReferenceError([].slice.call(s,1,u).join(".")+" is not defined in this storage");if(e.isArray(s[u]))for(var c in s[u])delete i[s[u][c]];else delete i[s[u]];return o.setItem(a,JSON.stringify(r)),!0}function n(t,r){var n=a(t);for(var o in n)i(t,n[o]);if(r)for(var o in e.namespaceStorages)u(o)}function o(r){var i=arguments.length,n=arguments,s=(window[r],n[1]);if(1==i)return 0==a(r).length;if(e.isArray(s)){for(var u=0;ui)throw Error("Minimum 2 arguments must be given");if(e.isArray(o)){for(var a=0;a1?t.apply(this,o):n,a._cookie)for(var u in e.cookie())""!=u&&s.push(u.replace(a._prefix,""));else for(var f in a)s.push(f);return s}function u(t){if(!t||"string"!=typeof t)throw Error("First parameter must be a string");g?(window.localStorage.getItem(t)||window.localStorage.setItem(t,"{}"),window.sessionStorage.getItem(t)||window.sessionStorage.setItem(t,"{}")):(window.localCookieStorage.getItem(t)||window.localCookieStorage.setItem(t,"{}"),window.sessionCookieStorage.getItem(t)||window.sessionCookieStorage.setItem(t,"{}"));var r={localStorage:e.extend({},e.localStorage,{_ns:t}),sessionStorage:e.extend({},e.sessionStorage,{_ns:t})};return e.cookie&&(window.cookieStorage.getItem(t)||window.cookieStorage.setItem(t,"{}"),r.cookieStorage=e.extend({},e.cookieStorage,{_ns:t})),e.namespaceStorages[t]=r,r}function f(e){if(!window[e])return!1;var t="jsapi";try{return window[e].setItem(t,t),window[e].removeItem(t),!0}catch(r){return!1}}var c="ls_",m="ss_",g=f("localStorage"),h={_type:"",_ns:"",_callMethod:function(e,t){var r=[this._type],t=Array.prototype.slice.call(t),i=t[0];return this._ns&&r.push(this._ns),"string"==typeof i&&-1!==i.indexOf(".")&&(t.shift(),[].unshift.apply(t,i.split("."))),[].push.apply(r,t),e.apply(this,r)},get:function(){return this._callMethod(t,arguments)},set:function(){var t=arguments.length,i=arguments,n=i[0];if(1>t||!e.isPlainObject(n)&&2>t)throw Error("Minimum 2 arguments must be given or first parameter must be an object");if(e.isPlainObject(n)&&this._ns){for(var o in n)r(this._type,this._ns,o,n[o]);return n}var s=this._callMethod(r,i);return this._ns?s[n.split(".")[0]]:s},remove:function(){if(arguments.length<1)throw Error("Minimum 1 argument must be given");return this._callMethod(i,arguments)},removeAll:function(e){return this._ns?(r(this._type,this._ns,{}),!0):n(this._type,e)},isEmpty:function(){return this._callMethod(o,arguments)},isSet:function(){if(arguments.length<1)throw Error("Minimum 1 argument must be given");return this._callMethod(s,arguments)},keys:function(){return this._callMethod(a,arguments)}};if(e.cookie){window.name||(window.name=Math.floor(1e8*Math.random()));var l={_cookie:!0,_prefix:"",_expires:null,_path:null,_domain:null,setItem:function(t,r){e.cookie(this._prefix+t,r,{expires:this._expires,path:this._path,domain:this._domain})},getItem:function(t){return e.cookie(this._prefix+t)},removeItem:function(t){return e.removeCookie(this._prefix+t)},clear:function(){for(var t in e.cookie())""!=t&&(!this._prefix&&-1===t.indexOf(c)&&-1===t.indexOf(m)||this._prefix&&0===t.indexOf(this._prefix))&&e.removeCookie(t)},setExpires:function(e){return this._expires=e,this},setPath:function(e){return this._path=e,this},setDomain:function(e){return this._domain=e,this},setConf:function(e){return e.path&&(this._path=e.path),e.domain&&(this._domain=e.domain),e.expires&&(this._expires=e.expires),this},setDefaultConf:function(){this._path=this._domain=this._expires=null}};g||(window.localCookieStorage=e.extend({},l,{_prefix:c,_expires:3650}),window.sessionCookieStorage=e.extend({},l,{_prefix:m+window.name+"_"})),window.cookieStorage=e.extend({},l),e.cookieStorage=e.extend({},h,{_type:"cookieStorage",setExpires:function(e){return window.cookieStorage.setExpires(e),this},setPath:function(e){return window.cookieStorage.setPath(e),this},setDomain:function(e){return window.cookieStorage.setDomain(e),this},setConf:function(e){return window.cookieStorage.setConf(e),this},setDefaultConf:function(){return window.cookieStorage.setDefaultConf(),this}})}e.initNamespaceStorage=function(e){return u(e)},g?(e.localStorage=e.extend({},h,{_type:"localStorage"}),e.sessionStorage=e.extend({},h,{_type:"sessionStorage"})):(e.localStorage=e.extend({},h,{_type:"localCookieStorage"}),e.sessionStorage=e.extend({},h,{_type:"sessionCookieStorage"})),e.namespaceStorages={},e.removeAllStorages=function(t){e.localStorage.removeAll(t),e.sessionStorage.removeAll(t),e.cookieStorage&&e.cookieStorage.removeAll(t),t||(e.namespaceStorages={})}}); 10 | \ No newline at end of file 11 | diff --git a/lib/web/jquery/patches/jquery-ui.js b/lib/web/jquery/patches/jquery-ui.js 12 | index ae2d8da7ece6..cb67fab8030b 100644 13 | --- a/lib/web/jquery/patches/jquery-ui.js 14 | +++ b/lib/web/jquery/patches/jquery-ui.js 15 | @@ -4,7 +4,9 @@ 16 | */ 17 | 18 | define([ 19 | - 'jquery' 20 | + 'jquery', 21 | + 'jquery-ui-modules/widget' 22 | + // 'jquery-ui-modules/dialog' - do not enable this dependency because this is already a mixin for the dialog ui component 23 | ], function ($) { 24 | 'use strict'; -------------------------------------------------------------------------------- /patches/composer/M231/github-pr-4721-braintree.diff: -------------------------------------------------------------------------------- 1 | diff --git a/view/frontend/templates/paypal/button.phtml b/view/frontend/templates/paypal/button.phtml 2 | index 36eddcf5819d..19dfed025508 100644 3 | --- a/view/frontend/templates/paypal/button.phtml 4 | +++ b/view/frontend/templates/paypal/button.phtml 5 | @@ -11,17 +11,14 @@ 6 | $id = $block->getContainerId() . mt_rand(); 7 | 8 | $config = [ 9 | - 'Magento_Braintree/js/paypal/button' => [ 10 | - 'id' => $id, 11 | - 'clientToken' => $block->getClientToken(), 12 | - 'displayName' => $block->getMerchantName(), 13 | - 'actionSuccess' => $block->getActionSuccess() 14 | - ] 15 | + 'id' => $id, 16 | + 'clientToken' => $block->getClientToken(), 17 | + 'displayName' => $block->getMerchantName(), 18 | + 'actionSuccess' => $block->getActionSuccess() 19 | ]; 20 | - 21 | ?> 22 | -