0

just see the example as follow:

file a.js

define({name:'a'});

file b.js

define(['jquery','a'],function($,a){
    let local=$.extend({customForB:'b'},a);// at the point a is used
    return function(options){return $.extend({},local,options)};
});

file c.js

define(['jquery','a'],function($,a){
    let local=$.extend({customForC:'c'},a);// at the point a is used
    return function(options){return $.extend({},local,options)};
});

file d.js

define(['jquery','a'],function($,a){
    a.name='global change';//effect to b and c or other dependencies
    require(['b','c'],function(b,c){
         //do nothing, but the local.name change 
         $.b=b;
         $.c=c;
    }
    $.a=a;
    return $;
});

file test.html

<script>
     require(['d'],function($){
          // At this point, it is uncertain whether B and C are loaded, 
          // is there a way to make sure that B and C are loaded, 
          // Can i use plugins to change the contents of the a?
          // At the same time affect its dependence       
     });
</script>

The same as follows

file d.js

define(['jquery','a'],function($,a){
    a.name='global change';//effect to b and c or other dependencies
    $.a=a;
    return $;
});

file test.html

<script>
     require(['d'],function($){
          require(['b','c'],function(b,c){
              $.b=b;
              $.c=c;
              //It's more complicated than the code above,But the functions are the same
         }
     });
</script>

I have no choice but to add a few extra words to avoid verification

peacetrue
  • 186
  • 1
  • 15
  • Your problem here is exactly the same problem as the general issue of returning a value from an asynchronous functions. `require` is not special in this regard but behaves like all other asynchronous functions. The limitation you face and the solutions available are the same as in the general case. See [here](https://stackoverflow.com/questions/14220321/how-do-i-return-the-response-from-an-asynchronous-call). – Louis Aug 18 '17 at 23:25
  • I've got the answer,use map { map: { '*': { 'a': 'd' }, 'd': { 'a': 'a' } }} – peacetrue Aug 19 '17 at 01:14

0 Answers0