2018-09-17 13:55:49 -07:00
|
|
|
const ModuleDependencyWarning = require('webpack/lib/ModuleDependencyWarning');
|
|
|
|
|
2018-11-25 20:02:35 -08:00
|
|
|
// suppress unfortunate warnings due to transpileOnly=true and certain ts export patterns
|
2018-09-17 13:55:49 -07:00
|
|
|
// https://github.com/TypeStrong/ts-loader/issues/653#issuecomment-390889335
|
|
|
|
// https://github.com/TypeStrong/ts-loader/issues/751
|
|
|
|
|
|
|
|
module.exports = class IgnoreNotFoundExportPlugin {
|
|
|
|
apply(compiler) {
|
|
|
|
const messageRegExp = /export '.*'( \(reexported as '.*'\))? was not found in/;
|
|
|
|
function doneHook(stats) {
|
|
|
|
stats.compilation.warnings = stats.compilation.warnings.filter(function(warn) {
|
|
|
|
if (warn instanceof ModuleDependencyWarning && messageRegExp.test(warn.message)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
if (compiler.hooks) {
|
|
|
|
compiler.hooks.done.tap('IgnoreNotFoundExportPlugin', doneHook);
|
|
|
|
} else {
|
|
|
|
compiler.plugin('done', doneHook);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|