2015-05-13 06:17:06 +08:00
|
|
|
/*
|
|
|
|
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
|
|
Author Tobias Koppers @sokra
|
|
|
|
*/
|
|
|
|
|
2017-01-01 10:35:41 +08:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
const DelegatedModuleFactoryPlugin = require("./DelegatedModuleFactoryPlugin");
|
|
|
|
const DelegatedSourceDependency = require("./dependencies/DelegatedSourceDependency");
|
2017-07-26 16:12:40 +08:00
|
|
|
const DelegatedExportsDependency = require("./dependencies/DelegatedExportsDependency");
|
|
|
|
const NullFactory = require("./NullFactory");
|
2017-01-01 10:35:41 +08:00
|
|
|
|
|
|
|
class DelegatedPlugin {
|
|
|
|
constructor(options) {
|
|
|
|
this.options = options;
|
|
|
|
}
|
|
|
|
|
|
|
|
apply(compiler) {
|
2017-12-06 22:01:25 +08:00
|
|
|
compiler.hooks.compilation.tap("DelegatedPlugin", (compilation, {
|
|
|
|
normalModuleFactory
|
|
|
|
}) => {
|
|
|
|
compilation.dependencyFactories.set(DelegatedSourceDependency, normalModuleFactory);
|
2017-07-26 16:12:40 +08:00
|
|
|
compilation.dependencyFactories.set(DelegatedExportsDependency, new NullFactory());
|
2017-01-01 10:35:41 +08:00
|
|
|
});
|
|
|
|
|
2017-12-06 22:01:25 +08:00
|
|
|
compiler.hooks.compile.tap("DelegatedPlugin", ({
|
|
|
|
normalModuleFactory
|
|
|
|
}) => {
|
2017-12-20 16:53:33 +08:00
|
|
|
new DelegatedModuleFactoryPlugin(this.options).apply(normalModuleFactory);
|
2017-01-01 10:35:41 +08:00
|
|
|
});
|
|
|
|
}
|
2015-05-13 06:17:06 +08:00
|
|
|
}
|
|
|
|
|
2017-01-01 10:35:41 +08:00
|
|
|
module.exports = DelegatedPlugin;
|