W
W
wellgo2017-10-23 11:43:42
RequireJS
wellgo, 2017-10-23 11:43:42

Why does undef work fine the second time in requirejs?

There is an added custom module described through

define(['custom'], function(){ return { load: function(name, req, onLoad, config){
onLoad.fromText('smth js code');
} }; });

So the problem is that it
require.undef('custom!smth_module');
works fine only the second time, i.e. require->undef->require doesn't work. The second require raises an error because custom module is not hooked and smth_module tries to load from the standard namespace instead of the logic described in it.
But at the same time, if you do require->undef->require->undef->require, then the third require works as it should - without errors, and correctly calls custom logic.
What the hell, who knows?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question