webpack/lib/dependencies/RequireContextDependency.js

43 lines
1.1 KiB
JavaScript
Raw Normal View History

2013-01-31 01:49:25 +08:00
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
const ContextDependency = require("./ContextDependency");
const ModuleDependencyTemplateAsRequireId = require("./ModuleDependencyTemplateAsRequireId");
2013-01-31 01:49:25 +08:00
2017-10-16 18:52:04 +08:00
function equalRegExp(a, b) {
if(a === b) return true;
if(typeof a !== "object" || typeof b !== "object") return false;
return a + "" === b + "";
}
class RequireContextDependency extends ContextDependency {
2017-10-16 18:52:04 +08:00
constructor(request, recursive, regExp, range, options) {
super(request, recursive, regExp);
this.range = range;
2017-10-16 18:52:04 +08:00
this.options = options;
}
isEqualResource(other) {
if(!super.isEqualResource(other)) return false;
if(!(other instanceof RequireContextDependency))
return false;
return this.options.async === other.options.async &&
this.options.chunkName === other.options.chunkName &&
equalRegExp(this.options.include, other.options.include) &&
equalRegExp(this.options.exclude, other.options.exclude);
}
get type() {
return "require.context";
}
2013-01-31 01:49:25 +08:00
}
RequireContextDependency.Template = ModuleDependencyTemplateAsRequireId;
2013-01-31 01:49:25 +08:00
module.exports = RequireContextDependency;