Skip to content

Commit 054b37f

Browse files
authored
Merge pull request webpack#3853 from willmendesneto/refactor-module-warnings
refactor(ModuleWarning): upgrade to ES6
2 parents ecafbe4 + 0f444e8 commit 054b37f

1 file changed

Lines changed: 15 additions & 10 deletions

File tree

lib/ModuleWarning.js

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,20 @@
22
MIT License http://www.opensource.org/licenses/mit-license.php
33
Author Tobias Koppers @sokra
44
*/
5-
function ModuleWarning(module, warning) {
6-
Error.call(this);
7-
Error.captureStackTrace(this, ModuleWarning);
8-
this.name = "ModuleWarning";
9-
this.module = module;
10-
this.message = warning;
11-
this.warning = warning;
5+
"use strict";
6+
7+
class ModuleWarning extends Error {
8+
constructor(module, warning) {
9+
super();
10+
11+
if(Error.hasOwnProperty("captureStackTrace")) {
12+
Error.captureStackTrace(this, this.constructor);
13+
}
14+
this.name = "ModuleWarning";
15+
this.module = module;
16+
this.message = warning;
17+
this.warning = warning;
18+
}
1219
}
13-
module.exports = ModuleWarning;
1420

15-
ModuleWarning.prototype = Object.create(Error.prototype);
16-
ModuleWarning.prototype.constructor = ModuleWarning;
21+
module.exports = ModuleWarning;

0 commit comments

Comments
 (0)