webpack
Version:
Packs ECMAScript/CommonJs/AMD modules for the browser. Allows you to split your codebase into multiple bundles, which can be loaded on demand. Supports loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.
43 lines (35 loc) • 1.39 kB
JavaScript
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Alexander Akait @alexander-akait
*/
;
const formatSize = require("../util/formatSize");
const WebpackError = require("./WebpackError");
/**
* @typedef {object} UnusedReexportDetails
* @property {string} name
* @property {number} size bytes the module costs
*/
class UnusedReexportsWarning extends WebpackError {
/**
* Creates an instance of UnusedReexportsWarning.
* @param {UnusedReexportDetails[]} modules the worst offenders, largest first
* @param {number} total how many modules are bundled unused
* @param {number} wasted bytes they cost together
*/
constructor(modules, total, wasted) {
const list = modules
.map((module) => `\n ${module.name} (${formatSize(module.size)})`)
.join("");
super(
`unused re-exports: ${total} ${
total === 1 ? "module is" : "modules are"
} bundled although nothing uses what they export, adding ${formatSize(
wasted
)}:${list}\nA module you import re-exports them, and their top-level code has side effects webpack is not allowed to drop. Setting '"sideEffects": false' in the package.json that owns them lets webpack leave them out.\nFor more info visit https://webpack.js.org/guides/tree-shaking/`
);
/** @type {string} */
this.name = "UnusedReexportsWarning";
}
}
module.exports = UnusedReexportsWarning;