Phil C
Phil C

Reputation: 980

How do I redefine a module in requirejs?

This question has 3 parts. I have two modules a and b.

  1. How do I redefine b after it was required initially?
  2. If a depends on b, how do I then update a to use the new b?
  3. How can I find all modules which depend on b and update them?

For example;

 define('a',['b'],function(b){return {name:'A',other:b}}); 
 define('b',function(){return {name:'B'}}); 
 require(['a']); 
 require('a');

Upvotes: 3

Views: 2015

Answers (1)

Phil C
Phil C

Reputation: 980

OK , I figured out 1) using undef

require.undef('b')
define('b',function(){return {name:'B2'}}); 

2) can use undef also but it's clunky

require.undef('a')
require.undef('b')
define('b',function(){return {name:'B2'}}); 
require(['a'])
require('a')

Any answers for part 3?

Upvotes: 4

Related Questions