requirejs插件在新的上下文中加载模块

| 我想让一个模块在页面上多次加载,每个实例具有唯一的上下文。有两种正常的方法可以做到这一点。 模块可以返回构造函数 我可以显式运行require方法,提供一个上下文ID。 在我的情况下,这些方法都可以使用,但是我想要第三个选择。 :) 我想要一个requirejs插件,它将在一个新的上下文中返回一个模块给我。即
require([\"new!some/module\"], function(SomeModule) {
    // SomeModule, here, is in its own context.  If i were to run this
    // method call again, SomeModule would be in a new context.
});
我已经开始研究构建插件来实现此目的...
load: function (name, req, load, config) {
    var index = get_unique_index();
    req({context:index}, [name], function(value) {
        if(!config.isBuild){
            load(value);
        }
    });
}
但是{context:index}字典在这里不起作用...想法?     
已邀请:
        与其使用传递给本地的req来加载,不如使用全局require函数,即所谓的require()。传递给本地的已绑定到上下文。     

要回复问题请先登录注册