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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the exception thrown when writeToDisk is enabled in multi-compiler mode #301

Merged
merged 4 commits into from
Apr 19, 2018
Merged

Fix the exception thrown when writeToDisk is enabled in multi-compiler mode #301

merged 4 commits into from
Apr 19, 2018

Conversation

arianrhodsandlot
Copy link
Contributor

@arianrhodsandlot arianrhodsandlot commented Apr 19, 2018

What kind of change does this PR introduce?

This is a bugfix 🐛🔫 for #290 😸. I'm running into the same problem these days.

Did you add tests for your changes?

Yes, I've added a test in test/tests/server.js

Summary

Fix the exception thrown when writeToDisk is enabled in multi-compiler mode.

Does this PR introduce a breaking change?

No.

@jsf-clabot
Copy link

jsf-clabot commented Apr 19, 2018

CLA assistant check
All committers have signed the CLA.

@alexander-akait
Copy link
Member

@arianrhodsandlot Good work thanks!

@codecov
Copy link

codecov bot commented Apr 19, 2018

Codecov Report

Merging #301 into master will increase coverage by 0.02%.
The diff coverage is 92%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #301      +/-   ##
==========================================
+ Coverage   96.81%   96.83%   +0.02%     
==========================================
  Files           7        7              
  Lines         251      253       +2     
==========================================
+ Hits          243      245       +2     
  Misses          8        8
Impacted Files Coverage Δ
lib/fs.js 95.23% <92%> (+0.23%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e0d4293...694389c. Read the comment docs.

Copy link
Contributor

@shellscape shellscape left a comment

Choose a reason for hiding this comment

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

Thanks for the PR 🍺

Unfortunately this is a less than optimal solution, and it can't be accepted as-is. Dealing with multi-compilers should written as: https://github.com/webpack-contrib/webpack-hot-client/blob/0d8707da129cdb6d9b892603c330f4dd2eac829f/index.js#L123-L126. And that would mean theres no need for a separate function (and no really long function names 🎉), as the code can simply be wrapped in the for/of. That'll also mean that there's less of a drop in coverage.

@arianrhodsandlot
Copy link
Contributor Author

@shellscape Brilliant suggestion. I've changed my code 😸.

module.exports = [{
mode: 'development',
context: __dirname,
entry: './foo.js',
output: {
filename: 'foo.js',
path: '/js1',
path: path.resolve(__dirname, 'js1'),
Copy link
Contributor

Choose a reason for hiding this comment

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

curious: previous tests pass on this with the path.resolve. is there a reason for this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As documented, output.path should be an absolute path. And without path.resolve, it will attempt to write files into the root directory /. This configuration didn't cause an error in the past because files are all in memory when no test cases with writeToDisk: trueare using it.

Copy link
Contributor

Choose a reason for hiding this comment

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

excellent, thank you

@@ -377,4 +377,49 @@ describe('Server', () => {
});
});
});

function writeToDiskWithMultiCompiler(value, done) {
Copy link
Contributor

Choose a reason for hiding this comment

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

maintainer's preference here: please do shorten this function name. something under 15 characters preferably, e.g. multiToDisk

@shellscape
Copy link
Contributor

Note: we can ignore the coverage report on this PR. not sure why it labeled it as a 0.02% reduction on last commit

@shellscape shellscape merged commit ac17265 into webpack:master Apr 19, 2018
@arianrhodsandlot arianrhodsandlot deleted the fix-multi-compiler branch April 20, 2018 02:48
@Dagniele
Copy link

Hi!! first of all thanks for the great job. Do you know when this will be release?

@shellscape
Copy link
Contributor

@Dagniele when we're able to publish it. patience is a virtue, and given the PR was merged under 24 hours ago, your followup there is a bit premature.

@Dagniele
Copy link

@shellscape no problem, I was not impatience or complaining I just wanted to know if you had any plan or schedule 😄

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.

5 participants