Code coverage report for lib\ProvidePlugin.js

Statements: 100% (9 / 9)      Branches: 100% (0 / 0)      Functions: 100% (4 / 4)      Lines: 100% (9 / 9)      Ignored: none     

All files » lib\ » ProvidePlugin.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18        1   1 1   1 1 1 1 1 1      
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
var ModuleParserHelpers = require("./ModuleParserHelpers");
 
function ProvidePlugin(definitions) {
	this.definitions = definitions;
}
module.exports = ProvidePlugin;
ProvidePlugin.prototype.apply = function(compiler) {
	Object.keys(this.definitions).forEach(function(name) {
		var request = this.definitions[name];
		compiler.parser.plugin("expression " + name, function(expr) {
			return ModuleParserHelpers.addParsedVariable(this, name, "require(" + JSON.stringify(request) + ")");
		});
	}, this);
};