diff --git a/web/htdocs/js/index.ts b/web/htdocs/js/index.ts index 5a6f2e8dff8..5d804a50138 100644 --- a/web/htdocs/js/index.ts +++ b/web/htdocs/js/index.ts @@ -48,63 +48,35 @@ import * as password_meter from "password_meter"; import * as cmk_figures from "cmk_figures"; import "cmk_figures_plugins"; -try { - require("cmk_figures_plugins_cee"); -} catch (e) { - // eslint-disable-next-line no-empty -} - import * as graphs from "graphs"; import * as nodevis from "./modules/nodevis/main"; // Optional import is currently not possible using the ES6 imports let graphs_cee; -try { - graphs_cee = require("graphs_cee"); -} catch (e) { - graphs_cee = null; -} - let ntop_host_details; -try { - ntop_host_details = require("ntop_host_details"); -} catch (e) { - ntop_host_details = null; -} - let ntop_alerts; -try { - ntop_alerts = require("ntop_alerts"); -} catch (e) { - ntop_alerts = null; -} - let ntop_flows; -try { - ntop_flows = require("ntop_flows"); -} catch (e) { - ntop_flows = null; -} - let ntop_top_talkers; -try { - ntop_top_talkers = require("ntop_top_talkers"); -} catch (e) { - ntop_top_talkers = null; -} - let ntop_utils; -try { - ntop_utils = require("ntop_utils"); -} catch (e) { - ntop_utils = null; -} - let license_usage_timeseries_graph; -try { + +if (process.env.ENTERPRISE !== "no") { + require("cmk_figures_plugins_cee"); + graphs_cee = require("graphs_cee"); + ntop_host_details = require("ntop_host_details"); + ntop_alerts = require("ntop_alerts"); + ntop_flows = require("ntop_flows"); + ntop_top_talkers = require("ntop_top_talkers"); + ntop_utils = require("ntop_utils"); license_usage_timeseries_graph = require("license_usage_timeseries_graph"); -} catch (e) { +} else { + graphs_cee = null; + ntop_host_details = null; + ntop_alerts = null; + ntop_flows = null; + ntop_top_talkers = null; + ntop_utils = null; license_usage_timeseries_graph = null; } diff --git a/webpack.config.js b/webpack.config.js index 41052a9617f..fa70e9cc78e 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -7,6 +7,24 @@ const RemoveEmptyScriptsPlugin = require("webpack-remove-empty-scripts"); const TerserPlugin = require("terser-webpack-plugin"); const webpack = require("webpack"); +class WarningsToErrors { + apply(compiler) { + compiler.hooks.shouldEmit.tap("WarningsToErrors", compilation => { + if (compilation.warnings.length > 0) { + compilation.errors = compilation.errors.concat(compilation.warnings); + compilation.warnings = []; + } + + compilation.children.forEach(child => { + if (child.warnings.length > 0) { + child.errors = child.errors.concat(child.warnings); + child.warnings = []; + } + }); + }); + } +} + module.exports = { mode: "production", devtool: "source-map", @@ -116,6 +134,7 @@ module.exports = { plugins: [ new RemoveEmptyScriptsPlugin(), new webpack.EnvironmentPlugin(["ENTERPRISE", "MANAGED"]), + new WarningsToErrors(), ], }; @@ -161,4 +180,5 @@ if (process.env.WEBPACK_MODE === "quick") { }, ]); } + module.exports.module.rules.unshift(babel_loader);