Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

ES6 refactor lib/node/NodeMainTemplatePlugin.js #5088

Merged
merged 5 commits into from Jun 21, 2017

Conversation

ayastreb
Copy link
Contributor

What kind of change does this PR introduce?

ES6 refactoring

Did you add tests for your changes?

No

If relevant, link to documentation update:

N/A

Summary
Convert codebase to ES6. #4099

Does this PR introduce a breaking change?

No

Other information

My first commit to webpack 馃

@jsf-clabot
Copy link

jsf-clabot commented Jun 19, 2017

CLA assistant check
All committers have signed the CLA.

this.indent([
"installedChunks[chunkId] = [resolve, reject];",
"var filename = __dirname + " + this.applyPluginsWaterfall("asset-path", JSON.stringify("/" + chunkFilename), {
hash: "\" + " + this.renderCurrentHashCode(hash) + " + \"",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This part of code is repeated two more times in this file - here and here.
Maybe I should try to refactor it out? Or is it not in the scope of ES6 refactoring?

@webpack-bot
Copy link
Contributor

Thank you for your pull request! The most important CI builds succeeded, we鈥檒l review the pull request soon.

source,
"",
"// uncatched error handler for webpack runtime",
this.requireFn + ".oe = function(err) {",
Copy link
Member

Choose a reason for hiding this comment

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

Could you try to refactor these string concatenations to template strings?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've thought about it, but then I found https://jsperf.com/es6-string-literals-vs-string-concatenation/14 and seems like string concatenation is faster than template literals, but template literal is faster than array.join (which is used in Template.asString).
Looking on the code in other modules I couldn't find the prefered way to deal with concatenation - in some places it's + in other places it's template literals.

Do you prefer template literals?

@webpack-bot
Copy link
Contributor

@ayastreb Thanks for your update.

I labeled the Pull Request so reviewers will review it again.

@sokra Please review the new changes.

Copy link
Member

@sokra sokra left a comment

Choose a reason for hiding this comment

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

Minor things

hashWithLength: (length) => "\" + " + this.renderCurrentHashCode(hash, length) + " + \"",
const request = this.applyPluginsWaterfall("asset-path", JSON.stringify(`./${chunkFilename}`), {
hash: `" + ${this.renderCurrentHashCode(hash)} + "`,
hashWithLength: (length) => `" + ${this.renderCurrentHashCode(hash, length)} + \"`,
Copy link
Member

Choose a reason for hiding this comment

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

ode(hash, length)} + \"`,
ode(hash, length)} + "`,

hash: "\" + " + this.renderCurrentHashCode(hash) + " + \"",
hashWithLength: (length) => "\" + " + this.renderCurrentHashCode(hash, length) + " + \"",
hash: `" + ${this.renderCurrentHashCode(hash)} + "`,
hashWithLength: (length) => `" + ${this.renderCurrentHashCode(hash, length)} + \"`,
Copy link
Member

Choose a reason for hiding this comment

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

rentHashCode(hash, length)} + \"`,
rentHashCode(hash, length)} + "`,

hashWithLength: (length) => "\" + " + this.renderCurrentHashCode(hash, length) + " + \"",
"var filename = __dirname + " + this.applyPluginsWaterfall("asset-path", JSON.stringify(`/${chunkFilename}`), {
hash: `" + ${this.renderCurrentHashCode(hash)} + "`,
hashWithLength: (length) => `" + ${this.renderCurrentHashCode(hash, length)} + \"`,
Copy link
Member

Choose a reason for hiding this comment

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

rrentHashCode(hash, length)} + \"`,
rrentHashCode(hash, length)} + "`,

@webpack-bot
Copy link
Contributor

It looks like this Pull Request doesn't include enough test cases (based on Code Coverage analysis of the PR diff).

A PR need to be covered by tests if you add a new feature (we want to make sure that your feature is working) or if you fix a bug (we want to make sure that we don't run into a regression in future).

@ayastreb Please check if this is appliable to your PR and if you can add more test cases.

Read the test readme for details how to write test cases.

@sokra sokra merged commit 9128f96 into webpack:master Jun 21, 2017
@sokra
Copy link
Member

sokra commented Jun 21, 2017

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants