fix filter
This commit is contained in:
parent
d0ee75b255
commit
d6af29698e
|
@ -39,6 +39,14 @@ class WarnNonEsmSourceTypePlugin {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {NormalModule} module module
|
||||
*/
|
||||
warn(module) {
|
||||
// TODO add type reason to NormalModule ?
|
||||
module.addWarning(new NonEsmSourceTypeWarning(module.type));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Compiler} compiler compiler
|
||||
*/
|
||||
|
@ -52,16 +60,14 @@ class WarnNonEsmSourceTypePlugin {
|
|||
for (const module of modules) {
|
||||
const type = module.type;
|
||||
if (type !== "javascript/esm" && type.startsWith("javascript/")) {
|
||||
if (
|
||||
this.filterFunction &&
|
||||
!this.filterFunction(
|
||||
/** @type {NormalModule} */ (module).resource
|
||||
)
|
||||
)
|
||||
continue;
|
||||
|
||||
// TODO add type reason to NormalModule ?
|
||||
module.addWarning(new NonEsmSourceTypeWarning(type));
|
||||
const normalModule = /** @type {NormalModule} */ (module);
|
||||
if (this.filterFunction) {
|
||||
if (this.filterFunction(normalModule.resource)) {
|
||||
this.warn(normalModule);
|
||||
}
|
||||
} else {
|
||||
this.warn(normalModule);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue