Skip to content

Commit

Permalink
Revert "Revert "handle webpack warnings as errors""
Browse files Browse the repository at this point in the history
This reverts commit 5467189.

Reason for revert: It's possible to change the way we import our enterprise files. So we could make it only possible if webpack mode is really Enterprise and not with try and catch...

Change-Id: I77414c69b488e3cd2d73cec00384cc071e1ac793
  • Loading branch information
Mazen Alkatlabee authored and Mazen Alkatlabee committed May 8, 2023
1 parent 77f43de commit 73677c9
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 44 deletions.
60 changes: 16 additions & 44 deletions web/htdocs/js/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
20 changes: 20 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -116,6 +134,7 @@ module.exports = {
plugins: [
new RemoveEmptyScriptsPlugin(),
new webpack.EnvironmentPlugin(["ENTERPRISE", "MANAGED"]),
new WarningsToErrors(),
],
};

Expand Down Expand Up @@ -161,4 +180,5 @@ if (process.env.WEBPACK_MODE === "quick") {
},
]);
}

module.exports.module.rules.unshift(babel_loader);

0 comments on commit 73677c9

Please sign in to comment.