Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Javascript "mixins" doesn't works if 'urlArgs' is in requirejs-config.js #8221

Closed
azanelli opened this issue Jan 20, 2017 · 8 comments
Closed
Labels
Area: Frontend bug report Fixed in 2.2.x The issue has been fixed in 2.2 release line Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development

Comments

@azanelli
Copy link
Contributor

azanelli commented Jan 20, 2017

Preconditions

  1. Magento 2.1

Steps to reproduce

  • Create a new module VendorName/MyModule
  • Add a requirejs-config.js file with this content:
// File: app/code/VendorName/MyModule/view/frontend/requirejs-config.js
var config = {
  'config':{
    'mixins': {
      'Magento_Checkout/js/view/shipping': {
         'VendorName_MyModule/hook':true
      }
    }
  },
  'urlArgs': "b=1"
};
  • Create the hook.js file:
// File: app/code/VendorName/MyModule/view/base/web/hook.js
define([], function(){
  'use strict';    

  console.log("This is hook.js");

  return function(targetModule){
    return targetModule;
  };
});
  • Go to the checkout page

Expected result

  • hook.js should be loaded and we should se the string "This is hook.js" printed in the javascript's console

Actual result

  • hook.js is not loaded and we do not see the string in the javascript's console

Notes

  • Note that if we remove the configuration 'urlArgs': "b=1" from the requirejs-config.js file all it works fine and hooks.js will be loaded.
@veloraven
Copy link
Contributor

@azanelli thank you for your report.
Please specify exact Magento version you are running.

@azanelli
Copy link
Contributor Author

azanelli commented Jan 23, 2017

@veloraven Magento 2.1.2

@namnn
Copy link

namnn commented Feb 20, 2017

@veloraven I have the same issue with a order comment module. I'm using Magento 2.1.0.

@jason-zz
Copy link

https://github.com/magento/magento2/blob/develop/lib/web/mage/requirejs/mixins.js#L116

URL augments should be removed in path variable. Otherwise, it won't match the key in requirejs-config.js. I think that's why mixins config gets fail when RequireJS defined urlArgs.

@thelettuce
Copy link
Contributor

Thanks for the tip. Had the same problem when using urlArgs: "bust=2017-02-23" in Magento_Theme/templates/page/js/require_js.phtml

Fooman GoogleAnalyticsPlus wasn't working due to this problem.

My fix for lib/web/mage/requirejs/mixins.js is :

getMixins: function (path) {
	if (path.indexOf('?')!=-1) {
		path=path.substring(0,path.indexOf('?'));
	}

that seems to fix it.

@joachimVT
Copy link

I'm having the same issue on magento 2.1.6. Any updates on this ?

@magento-team
Copy link
Contributor

Internal ticket to track issue progress: MAGETWO-69674

@magento-engcom-team magento-engcom-team added 2.1.x Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development bug report Area: Frontend and removed G1 Passed labels Sep 5, 2017
@magento-engcom-team magento-engcom-team added Area: Frontend Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed labels Sep 11, 2017
@magento-engcom-team
Copy link
Contributor

@azanelli, thank you for your report.
The issue is already fixed in 2.2.0

@magento-engcom-team magento-engcom-team added 2.2.x Fixed in 2.2.x The issue has been fixed in 2.2 release line labels Sep 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Frontend bug report Fixed in 2.2.x The issue has been fixed in 2.2 release line Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development
Projects
None yet
Development

No branches or pull requests

8 participants