<commit_before>/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author <NAME> @sokra
*/
"use strict";
var RequireIncludeDependency = require("./RequireIncludeDependency");
var RequireIncludeDependencyParserPlugin = require("./RequireIncludeDependencyParserPlugin");
var ConstDependency = require("./ConstDependency");

const ParserHelpers = require("../ParserHelpers");

function RequireIncludePlugin() {}
module.exports = RequireIncludePlugin;

RequireIncludePlugin.prototype.apply = function(compiler) {
	compiler.plugin("compilation", function(compilation, params) {
		var normalModuleFactory = params.normalModuleFactory;

		compilation.dependencyFactories.set(RequireIncludeDependency, normalModuleFactory);
		compilation.dependencyTemplates.set(RequireIncludeDependency, new RequireIncludeDependency.Template());

		params.normalModuleFactory.plugin("parser", function(parser, parserOptions) {

			if(typeof parserOptions.requireInclude !== "undefined" && !parserOptions.requireInclude)
				return;

			parser.apply(new RequireIncludeDependencyParserPlugin());
			parser.plugin("evaluate typeof require.include", ParserHelpers.evaluateToString("function"));
			parser.plugin("typeof require.include", function(expr) {
				var dep = new ConstDependency("'function'", expr.range);
				dep.loc = expr.loc;
				this.state.current.addDependency(dep);
				return true;
			});

		});
	});
};<commit_msg>refactor(ES6): upgrade RequireIncludePlugin to ES6<commit_after>/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author <NAME> @sokra
*/
"use strict";

const RequireIncludeDependency = require("./RequireIncludeDependency");
const RequireIncludeDependencyParserPlugin = require("./RequireIncludeDependencyParserPlugin");
const ConstDependency = require("./ConstDependency");

const ParserHelpers = require("../ParserHelpers");

class RequireIncludePlugin {

	apply(compiler) {
		compiler.plugin("compilation", (compilation, params) => {
			const normalModuleFactory = params.normalModuleFactory;

			compilation.dependencyFactories.set(RequireIncludeDependency, normalModuleFactory);
			compilation.dependencyTemplates.set(RequireIncludeDependency, new RequireIncludeDependency.Template());

			params.normalModuleFactory.plugin("parser", (parser, parserOptions) => {

				if(typeof parserOptions.requireInclude !== "undefined" && !parserOptions.requireInclude)
					return;

				parser.apply(new RequireIncludeDependencyParserPlugin());
				parser.plugin("evaluate typeof require.include", ParserHelpers.evaluateToString("function"));
				parser.plugin("typeof require.include", (expr) => {
					const dep = new ConstDependency("'function'", expr.range);
					dep.loc = expr.loc;
					parser.state.current.addDependency(dep);
					return true;
				});

			});
		});
	}
}
module.exports = RequireIncludePlugin;
{'fraction_non_alphanumeric': 0.126009126009126, 'fraction_numerical': 0.000702000702000702, 'mean_word_length': 6.142857142857143, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2965448', 'n_tokens_mistral': 825, 'n_tokens_neox': 723, 'n_words': 133}