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