From 0571ad5ad7db0d9facf2f8c3e5d5b62f3ba2fa25 Mon Sep 17 00:00:00 2001 From: Dominik Prokop Date: Wed, 9 Jan 2019 11:33:08 +0100 Subject: [PATCH] Removes unnecessary warnings from webpack output about missing exports This should not break anything as ForkTsCheckerWebpackPlugin takes care of that --- scripts/webpack/IgnoreNotFoundExportPlugin.js | 22 +++++++++++++++++++ scripts/webpack/webpack.hot.js | 2 ++ 2 files changed, 24 insertions(+) create mode 100644 scripts/webpack/IgnoreNotFoundExportPlugin.js diff --git a/scripts/webpack/IgnoreNotFoundExportPlugin.js b/scripts/webpack/IgnoreNotFoundExportPlugin.js new file mode 100644 index 00000000000..37bf1f7200e --- /dev/null +++ b/scripts/webpack/IgnoreNotFoundExportPlugin.js @@ -0,0 +1,22 @@ +// https://github.com/TypeStrong/ts-loader/issues/653#issuecomment-390889335 + +const ModuleDependencyWarning = require("webpack/lib/ModuleDependencyWarning") + +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) + } + } +} diff --git a/scripts/webpack/webpack.hot.js b/scripts/webpack/webpack.hot.js index ca08ff1e726..b37e4c08592 100644 --- a/scripts/webpack/webpack.hot.js +++ b/scripts/webpack/webpack.hot.js @@ -7,6 +7,7 @@ const webpack = require('webpack'); const HtmlWebpackPlugin = require('html-webpack-plugin'); const HtmlWebpackHarddiskPlugin = require('html-webpack-harddisk-plugin'); const CleanWebpackPlugin = require('clean-webpack-plugin'); +const IgnoreNotFoundExportPlugin = require("./IgnoreNotFoundExportPlugin.js"); module.exports = merge(common, { entry: { @@ -111,5 +112,6 @@ module.exports = merge(common, { NODE_ENV: JSON.stringify('development'), }, }), + new IgnoreNotFoundExportPlugin(), ], });