2016-12-03 18:36:10 +08:00
|
|
|
/*
|
|
|
|
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
|
|
Author Tobias Koppers @sokra
|
|
|
|
*/
|
2017-01-08 02:05:10 +08:00
|
|
|
"use strict";
|
|
|
|
const ContextDependency = require("./ContextDependency");
|
|
|
|
const ContextDependencyTemplateAsRequireCall = require("./ContextDependencyTemplateAsRequireCall");
|
2016-12-03 18:36:10 +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 + "";
|
|
|
|
}
|
|
|
|
|
2017-01-08 02:05:10 +08:00
|
|
|
class ImportContextDependency extends ContextDependency {
|
2017-10-16 18:52:04 +08:00
|
|
|
constructor(request, recursive, regExp, range, valueRange, options) {
|
2017-01-08 02:05:10 +08:00
|
|
|
super(request, recursive, regExp);
|
|
|
|
this.range = range;
|
|
|
|
this.valueRange = valueRange;
|
2017-10-16 18:52:04 +08:00
|
|
|
this.options = options;
|
|
|
|
}
|
|
|
|
|
|
|
|
isEqualResource(other) {
|
|
|
|
if(!super.isEqualResource(other)) return false;
|
|
|
|
|
|
|
|
if(!(other instanceof ImportContextDependency))
|
|
|
|
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);
|
2017-01-08 02:05:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
get type() {
|
2017-10-16 18:52:04 +08:00
|
|
|
return `import() context ${this.options.async}`;
|
2017-01-08 02:05:10 +08:00
|
|
|
}
|
2016-12-03 18:36:10 +08:00
|
|
|
|
2017-01-08 02:05:10 +08:00
|
|
|
}
|
2016-12-03 18:36:10 +08:00
|
|
|
|
2017-01-08 02:05:10 +08:00
|
|
|
ImportContextDependency.Template = ContextDependencyTemplateAsRequireCall;
|
|
|
|
|
|
|
|
module.exports = ImportContextDependency;
|