remove unnecessary module arguments from module attached errors
This commit is contained in:
parent
e9db83c6c7
commit
4174521f9d
|
@ -8,23 +8,19 @@
|
|||
const WebpackError = require("./WebpackError");
|
||||
const makeSerializable = require("./util/makeSerializable");
|
||||
|
||||
/** @typedef {import("./Module")} Module */
|
||||
|
||||
/** @typedef {import("./Dependency").DependencyLocation} DependencyLocation */
|
||||
|
||||
class CommentCompilationWarning extends WebpackError {
|
||||
/**
|
||||
*
|
||||
* @param {string} message warning message
|
||||
* @param {Module} module affected module
|
||||
* @param {DependencyLocation} loc affected lines of code
|
||||
*/
|
||||
constructor(message, module, loc) {
|
||||
constructor(message, loc) {
|
||||
super(message);
|
||||
|
||||
this.name = "CommentCompilationWarning";
|
||||
|
||||
this.module = module;
|
||||
this.loc = loc;
|
||||
|
||||
Error.captureStackTrace(this, this.constructor);
|
||||
|
|
|
@ -72,7 +72,7 @@ exports.expressionIsUnsupported = (parser, message) => {
|
|||
parser.state.current.addDependency(dep);
|
||||
if (!parser.state.module) return;
|
||||
parser.state.module.warnings.push(
|
||||
new UnsupportedFeatureWarning(parser.state.module, message, expr.loc)
|
||||
new UnsupportedFeatureWarning(message, expr.loc)
|
||||
);
|
||||
return true;
|
||||
};
|
||||
|
|
|
@ -10,7 +10,7 @@ const WebpackError = require("./WebpackError");
|
|||
const makeSerializable = require("./util/makeSerializable");
|
||||
|
||||
class ModuleBuildError extends WebpackError {
|
||||
constructor(module, err, { from = null } = {}) {
|
||||
constructor(err, { from = null } = {}) {
|
||||
let message = "Module build failed";
|
||||
let details = undefined;
|
||||
|
||||
|
@ -48,7 +48,6 @@ class ModuleBuildError extends WebpackError {
|
|||
|
||||
this.name = "ModuleBuildError";
|
||||
this.details = details;
|
||||
this.module = module;
|
||||
this.error = err;
|
||||
|
||||
Error.captureStackTrace(this, this.constructor);
|
||||
|
|
|
@ -10,7 +10,7 @@ const WebpackError = require("./WebpackError");
|
|||
const makeSerializable = require("./util/makeSerializable");
|
||||
|
||||
class ModuleError extends WebpackError {
|
||||
constructor(module, err, { from = null } = {}) {
|
||||
constructor(err, { from = null } = {}) {
|
||||
let message = "Module Error";
|
||||
|
||||
if (from) {
|
||||
|
@ -28,7 +28,6 @@ class ModuleError extends WebpackError {
|
|||
super(message);
|
||||
|
||||
this.name = "ModuleError";
|
||||
this.module = module;
|
||||
this.error = err;
|
||||
this.details =
|
||||
err && typeof err === "object" && err.stack
|
||||
|
|
|
@ -8,21 +8,19 @@
|
|||
const WebpackError = require("./WebpackError");
|
||||
const makeSerializable = require("./util/makeSerializable");
|
||||
|
||||
/** @typedef {import("./Module")} Module */
|
||||
|
||||
class ModuleParseError extends WebpackError {
|
||||
/**
|
||||
* @param {Module} module the errored module
|
||||
* @param {string} source source code
|
||||
* @param {Error&any} err the parse error
|
||||
*/
|
||||
constructor(module, source, err) {
|
||||
let message = "Module parse failed: " + err.message;
|
||||
constructor(source, err) {
|
||||
let message = "Module parse failed: " + (err && err.message);
|
||||
let loc = undefined;
|
||||
|
||||
message += "\nYou may need an appropriate loader to handle this file type.";
|
||||
|
||||
if (
|
||||
err &&
|
||||
err.loc &&
|
||||
typeof err.loc === "object" &&
|
||||
typeof err.loc.line === "number"
|
||||
|
@ -46,14 +44,13 @@ class ModuleParseError extends WebpackError {
|
|||
}
|
||||
|
||||
loc = { start: err.loc };
|
||||
} else {
|
||||
} else if (err && err.stack) {
|
||||
message += "\n" + err.stack;
|
||||
}
|
||||
|
||||
super(message);
|
||||
|
||||
this.name = "ModuleParseError";
|
||||
this.module = module;
|
||||
this.loc = loc;
|
||||
this.error = err;
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ const WebpackError = require("./WebpackError");
|
|||
const makeSerializable = require("./util/makeSerializable");
|
||||
|
||||
class ModuleWarning extends WebpackError {
|
||||
constructor(module, warning, { from = null } = {}) {
|
||||
constructor(warning, { from = null } = {}) {
|
||||
let message = "Module Warning";
|
||||
|
||||
if (from) {
|
||||
|
@ -28,7 +28,6 @@ class ModuleWarning extends WebpackError {
|
|||
super(message);
|
||||
|
||||
this.name = "ModuleWarning";
|
||||
this.module = module;
|
||||
this.warning = warning;
|
||||
this.details =
|
||||
warning && typeof warning === "object" && warning.stack
|
||||
|
|
|
@ -200,7 +200,7 @@ class NormalModule extends Module {
|
|||
}
|
||||
const currentLoader = this.getCurrentLoader(loaderContext);
|
||||
this.warnings.push(
|
||||
new ModuleWarning(this, warning, {
|
||||
new ModuleWarning(warning, {
|
||||
from: requestShortener.shorten(currentLoader.loader)
|
||||
})
|
||||
);
|
||||
|
@ -211,7 +211,7 @@ class NormalModule extends Module {
|
|||
}
|
||||
const currentLoader = this.getCurrentLoader(loaderContext);
|
||||
this.errors.push(
|
||||
new ModuleError(this, error, {
|
||||
new ModuleError(error, {
|
||||
from: requestShortener.shorten(currentLoader.loader)
|
||||
})
|
||||
);
|
||||
|
@ -318,7 +318,7 @@ class NormalModule extends Module {
|
|||
err = new NonErrorEmittedError(err);
|
||||
}
|
||||
const currentLoader = this.getCurrentLoader(loaderContext);
|
||||
const error = new ModuleBuildError(this, err, {
|
||||
const error = new ModuleBuildError(err, {
|
||||
from:
|
||||
currentLoader &&
|
||||
compilation.runtimeTemplate.requestShortener.shorten(
|
||||
|
@ -344,7 +344,7 @@ class NormalModule extends Module {
|
|||
: "unknown"
|
||||
}) didn't return a Buffer or String`
|
||||
);
|
||||
const error = new ModuleBuildError(this, err);
|
||||
const error = new ModuleBuildError(err);
|
||||
return callback(error);
|
||||
}
|
||||
|
||||
|
@ -474,7 +474,7 @@ class NormalModule extends Module {
|
|||
|
||||
const handleParseError = e => {
|
||||
const source = this._source.source();
|
||||
const error = new ModuleParseError(this, source, e);
|
||||
const error = new ModuleParseError(source, e);
|
||||
this.markModuleAsErrored(error);
|
||||
this._initBuildHash(compilation);
|
||||
return callback();
|
||||
|
|
|
@ -9,19 +9,16 @@ const WebpackError = require("./WebpackError");
|
|||
const makeSerializable = require("./util/makeSerializable");
|
||||
|
||||
/** @typedef {import("./Dependency").DependencyLocation} DependencyLocation */
|
||||
/** @typedef {import("./Module")} Module */
|
||||
|
||||
class UnsupportedFeatureWarning extends WebpackError {
|
||||
/**
|
||||
* @param {Module} module module relevant to warning
|
||||
* @param {string} message description of warning
|
||||
* @param {DependencyLocation} loc location start and end positions of the module
|
||||
*/
|
||||
constructor(module, message, loc) {
|
||||
constructor(message, loc) {
|
||||
super(message);
|
||||
|
||||
this.name = "UnsupportedFeatureWarning";
|
||||
this.module = module;
|
||||
this.loc = loc;
|
||||
this.hideStack = true;
|
||||
|
||||
|
|
|
@ -214,7 +214,6 @@ class AMDRequireDependenciesBlockParserPlugin {
|
|||
if (parser.state.module) {
|
||||
parser.state.module.errors.push(
|
||||
new UnsupportedFeatureWarning(
|
||||
parser.state.module,
|
||||
"Cannot statically analyse 'require(…, …)' in line " +
|
||||
expr.loc.start.line,
|
||||
expr.loc
|
||||
|
|
|
@ -48,7 +48,6 @@ class ImportParserPlugin {
|
|||
`Compilation error while processing magic comment(-s): /*${
|
||||
comment.value
|
||||
}*/: ${e.message}`,
|
||||
parser.state.module,
|
||||
comment.loc
|
||||
)
|
||||
);
|
||||
|
@ -60,7 +59,6 @@ class ImportParserPlugin {
|
|||
if (typeof importOptions.webpackIgnore !== "boolean") {
|
||||
parser.state.module.warnings.push(
|
||||
new UnsupportedFeatureWarning(
|
||||
parser.state.module,
|
||||
`\`webpackIgnore\` expected a boolean, but received: ${
|
||||
importOptions.webpackIgnore
|
||||
}.`,
|
||||
|
@ -78,7 +76,6 @@ class ImportParserPlugin {
|
|||
if (typeof importOptions.webpackChunkName !== "string") {
|
||||
parser.state.module.warnings.push(
|
||||
new UnsupportedFeatureWarning(
|
||||
parser.state.module,
|
||||
`\`webpackChunkName\` expected a string, but received: ${
|
||||
importOptions.webpackChunkName
|
||||
}.`,
|
||||
|
@ -93,7 +90,6 @@ class ImportParserPlugin {
|
|||
if (typeof importOptions.webpackMode !== "string") {
|
||||
parser.state.module.warnings.push(
|
||||
new UnsupportedFeatureWarning(
|
||||
parser.state.module,
|
||||
`\`webpackMode\` expected a string, but received: ${
|
||||
importOptions.webpackMode
|
||||
}.`,
|
||||
|
@ -112,7 +108,6 @@ class ImportParserPlugin {
|
|||
} else {
|
||||
parser.state.module.warnings.push(
|
||||
new UnsupportedFeatureWarning(
|
||||
parser.state.module,
|
||||
`\`webpackPrefetch\` expected true or a number, but received: ${
|
||||
importOptions.webpackPrefetch
|
||||
}.`,
|
||||
|
@ -129,7 +124,6 @@ class ImportParserPlugin {
|
|||
} else {
|
||||
parser.state.module.warnings.push(
|
||||
new UnsupportedFeatureWarning(
|
||||
parser.state.module,
|
||||
`\`webpackPreload\` expected true or a number, but received: ${
|
||||
importOptions.webpackPreload
|
||||
}.`,
|
||||
|
@ -145,7 +139,6 @@ class ImportParserPlugin {
|
|||
) {
|
||||
parser.state.module.warnings.push(
|
||||
new UnsupportedFeatureWarning(
|
||||
parser.state.module,
|
||||
`\`webpackInclude\` expected a regular expression, but received: ${
|
||||
importOptions.webpackInclude
|
||||
}.`,
|
||||
|
@ -163,7 +156,6 @@ class ImportParserPlugin {
|
|||
) {
|
||||
parser.state.module.warnings.push(
|
||||
new UnsupportedFeatureWarning(
|
||||
parser.state.module,
|
||||
`\`webpackExclude\` expected a regular expression, but received: ${
|
||||
importOptions.webpackExclude
|
||||
}.`,
|
||||
|
@ -180,7 +172,6 @@ class ImportParserPlugin {
|
|||
if (mode !== "lazy" && mode !== "eager" && mode !== "weak") {
|
||||
parser.state.module.warnings.push(
|
||||
new UnsupportedFeatureWarning(
|
||||
parser.state.module,
|
||||
`\`webpackMode\` expected 'lazy', 'eager' or 'weak', but received: ${mode}.`,
|
||||
expr.loc
|
||||
)
|
||||
|
@ -217,7 +208,6 @@ class ImportParserPlugin {
|
|||
) {
|
||||
parser.state.module.warnings.push(
|
||||
new UnsupportedFeatureWarning(
|
||||
parser.state.module,
|
||||
`\`webpackMode\` expected 'lazy', 'lazy-once', 'eager' or 'weak', but received: ${mode}.`,
|
||||
expr.loc
|
||||
)
|
||||
|
|
|
@ -90,7 +90,7 @@ class SystemPlugin {
|
|||
|
||||
parser.hooks.call.for("System.import").tap("SystemPlugin", expr => {
|
||||
parser.state.module.warnings.push(
|
||||
new SystemImportDeprecationWarning(parser.state.module, expr.loc)
|
||||
new SystemImportDeprecationWarning(expr.loc)
|
||||
);
|
||||
|
||||
return parser.hooks.importCall.call(expr);
|
||||
|
@ -109,7 +109,7 @@ class SystemPlugin {
|
|||
}
|
||||
|
||||
class SystemImportDeprecationWarning extends WebpackError {
|
||||
constructor(module, loc) {
|
||||
constructor(loc) {
|
||||
super(
|
||||
"System.import() is deprecated and will be removed soon. Use import() instead.\n" +
|
||||
"For more info visit https://webpack.js.org/guides/code-splitting/"
|
||||
|
@ -117,7 +117,6 @@ class SystemImportDeprecationWarning extends WebpackError {
|
|||
|
||||
this.name = "SystemImportDeprecationWarning";
|
||||
|
||||
this.module = module;
|
||||
this.loc = loc;
|
||||
|
||||
Error.captureStackTrace(this, this.constructor);
|
||||
|
|
Loading…
Reference in New Issue