2015-05-13 06:17:06 +08:00
|
|
|
/*
|
|
|
|
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
|
|
Author Tobias Koppers @sokra
|
|
|
|
*/
|
|
|
|
var DelegatedModule = require("./DelegatedModule");
|
|
|
|
|
|
|
|
function DelegatedModuleFactoryPlugin(options) {
|
|
|
|
this.options = options;
|
|
|
|
options.type = options.type || "require";
|
|
|
|
// this.source = source;
|
|
|
|
// this.type = type;
|
|
|
|
// this.scope = scope;
|
|
|
|
// this.context = context;
|
|
|
|
// this.content = content;
|
|
|
|
}
|
|
|
|
module.exports = DelegatedModuleFactoryPlugin;
|
|
|
|
|
|
|
|
DelegatedModuleFactoryPlugin.prototype.apply = function(normalModuleFactory) {
|
2015-05-17 00:27:59 +08:00
|
|
|
normalModuleFactory.plugin("module", function(module) {
|
|
|
|
if(module.libIdent) {
|
|
|
|
var request = module.libIdent(this.options);
|
|
|
|
if(request && request in this.options.content) {
|
|
|
|
var resolved = this.options.content[request];
|
|
|
|
return new DelegatedModule(this.options.source, resolved, this.options.type);
|
|
|
|
}
|
2015-05-13 06:17:06 +08:00
|
|
|
}
|
2015-05-17 00:27:59 +08:00
|
|
|
return module;
|
2015-05-13 06:17:06 +08:00
|
|
|
}.bind(this));
|
|
|
|
};
|