Answer the question
In order to leave comments, you need to log in
RequireJS module loading
Addresses of additional components for the factory come from the server and they need to be run in the current context.
Without requireJS, this can be done using global variables and a generated script.
How to do it with requireJS?
You can do this inside a module:
require(['Factory', 'require'], function (Factory, require) {
// ... тут какой-то код
// добавляет зависимости
function addDependence(name, path) {
require([path], function (module) {
Factory.add(name, module);
console.log(Factory.ModuleX); // вернет модуль
});
console.log(Factory.ModuleX); // вернет undefined
}
console.log(Factory.ModuleX); // вернет undefined
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question