mirror of https://github.com/webpack/webpack.git
				
				
				
			
		
			
				
	
	
		
			39 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
			
		
		
	
	
			39 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
| /*
 | |
| 	MIT License http://www.opensource.org/licenses/mit-license.php
 | |
| 	Author Tobias Koppers @sokra
 | |
| */
 | |
| var path = require("path");
 | |
| var ConstDependency = require("./dependencies/ConstDependency");
 | |
| 
 | |
| var NullFactory = require("./NullFactory");
 | |
| 
 | |
| function RequireJsStuffPlugin() {
 | |
| }
 | |
| module.exports = RequireJsStuffPlugin;
 | |
| RequireJsStuffPlugin.prototype.apply = function(compiler) {
 | |
| 	compiler.plugin("compilation", function(compilation, params) {
 | |
| 		compilation.dependencyFactories.set(ConstDependency, new NullFactory());
 | |
| 		compilation.dependencyTemplates.set(ConstDependency, new ConstDependency.Template());
 | |
| 	});
 | |
| 	function remove(expr) {
 | |
| 		var dep = new ConstDependency(";", expr.range);
 | |
| 		dep.loc = expr.loc;
 | |
| 		this.state.current.addDependency(dep);
 | |
| 		return true;
 | |
| 	}
 | |
| 	compiler.parser.plugin("call require.config", remove);
 | |
| 	compiler.parser.plugin("call requirejs.config", remove);
 | |
| 
 | |
| 	compiler.parser.plugin("expression require.version", function(expr) {
 | |
| 		var dep = new ConstDependency(JSON.stringify("0.0.0"), expr.range);
 | |
| 		dep.loc = expr.loc;
 | |
| 		this.state.current.addDependency(dep);
 | |
| 		return true;
 | |
| 	});
 | |
| 	compiler.parser.plugin("expression requirejs.onError", function(expr) {
 | |
| 		var dep = new ConstDependency(JSON.stringify("__webpack_require__.onError"), expr.range);
 | |
| 		dep.loc = expr.loc;
 | |
| 		this.state.current.addDependency(dep);
 | |
| 		return true;
 | |
| 	});
 | |
| }; |