Reputation: 685
I am wondering how module definition works. It is better just to give an example.
If two modules with the same name are defined one after another, the second definition won't work:
define("somemodule", [], function () {return "foo";})
define("somemodule", [], function () {return "bar";})
require(["somemodule"], function (module) {console.log(module)})
It will return:
> "foo"
But if we call the module after the first definition, the second module will redefine the first one:
define("somemodule", [], function () {return "foo";})
require(["somemodule"], function (module) {console.log(module)})
define("somemodule", [], function () {return "bar";})
require(["somemodule"], function (module) {console.log(module)})
Returns:
> "foo"
> "bar"
Why does it work this way? In fact I'm looking for possibility to prevent module redefinition at all. In other words I need the code above to return "foo" all the time.
Upvotes: 4
Views: 484
Reputation: 685
I was using requirejs 2.0.6. The problem is not reproduced in requirejs 2.1.15. Solved!
Upvotes: 3