Skip to content

refactor(ModuleWarning): upgrade to ES6 - #3853

Merged
sokra merged 1 commit into
webpack:masterfrom
willmendesneto:refactor-module-warnings
Jan 9, 2017
Merged

sokra merged 1 commit into
webpack:masterfrom
willmendesneto:refactor-module-warnings

Conversation

@willmendesneto

Copy link
Copy Markdown
Contributor

What kind of change does this PR introduce?

ES5 => ES6 refactor

Did you add tests for your changes?

refactor, all existing tests pass

If relevant, link to documentation update:

N/A

Summary

Helping in part of the ES6 refactor

Does this PR introduce a breaking change?

Nope

Comment thread lib/ModuleWarning.js
}
this.name = "ModuleWarning";
this.module = module;
this.message = warning;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Give this as the argument to super instead (super(warning))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm just keeping how it was before. I can't change it because I can't track all impacts. That's the reason why I kept all the current behaviors and attributes.

Comment thread lib/ModuleWarning.js Outdated
super();

if(Error.hasOwnProperty("captureStackTrace")) {
Error.captureStackTrace(this, ModuleWarning);

@Jessidhia Jessidhia Jan 9, 2017

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed in native subclasses, unless you specifically want to exclude the constructor from the stack trace.

CustomErrorClass: without captureStackTrace
    at CustomErrorClass (.../test.js:5:10)
    at throwMe (.../test.js:32:11)
CustomErrorClass2: with captureStackTrace
    at throwMe (.../test.js:32:11)

ES5-style errors would just have no .stack at all, so it was necessary in those.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Kovensky in that case I can just pass this.constructor as same argument used in other error classes

@willmendesneto willmendesneto Jan 9, 2017

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as here. If you guys are comfortable with these changes I can update the PR without problems.

@sokra
sokra merged commit 054b37f into webpack:master Jan 9, 2017
@sokra

sokra commented Jan 9, 2017

Copy link
Copy Markdown
Member

Thanks

@willmendesneto
willmendesneto deleted the refactor-module-warnings branch January 9, 2017 08:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants