-
Notifications
You must be signed in to change notification settings - Fork 417
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 compile stats in multiple packaging #278
fix compile stats in multiple packaging #278
Conversation
lib/compile.js
Outdated
} | ||
|
||
const compileOutputPaths = []; | ||
const consoleStats = this.webpackConfig.stats || { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't just
const consoleStats = this.webpackConfig.stats || _.get(this, 'webpackConfig[0].stats') || { ...
be enough instead of the ifs below? Then it would try plain, then array and finally fall back to the defaults.
@dangcuuson With the one liner above the unit test changes will be minimal too (just one test case). With the big if solution, you have several new code branches that you need to test (even the stats that you initialize now in there). |
3afbf1e
to
986f15d
Compare
tests/compile.test.js
Outdated
const testWebpackConfig = { | ||
stats: 'minimal' | ||
}; | ||
let mockStats = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be const
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed!
tests/compile.test.js
Outdated
return (expect(module.compile()).to.be.fulfilled); | ||
}) | ||
.then(() => { | ||
expect(mockStats.toString.args).to.eql([[testWebpackConfig.stats], [testWebpackConfig.stats]]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can do the same for "mockStats.toString.firstCall.args" to check that the plain webpack config's stats was used there. Or is that already covered with this check?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It already covered in that checks since sinon.args will list the history of all args passed to the spy function, but I have added the first call check. Not sure if excessive test is good or bad 😈
0421dd6
to
e2eaa64
Compare
e2eaa64
to
f5b13e4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did a local check with your branch with a bigger project (packaged individually) and it work perfectly 👍
With stats: 'minimal'
i got
Serverless: Bundling with Webpack...
185 modules
134 modules
170 modules
130 modules
130 modules
131 modules
166 modules
132 modules
131 modules
130 modules
189 modules
3 modules
That's good! 👍 |
Released with |
@HyperBrain small remaining issue is that this is causing a lot of whitespace:
With |
@tommedema Thanks for the hint 💯 . It might be that 'errors-only' emits an empty console log when printing the stats. Maybe that can be checked for this setting and the log can be skipped. Can you open an issue for that, so that it is tracked? |
Thanks, I will create an issue in the near future. |
…stats fix compile stats in multiple packaging
What did you implement:
Fix a problem of #261
How did you implement it:
Extract stats options of first webpack item
How can we verify it:
The old code will fail with the updated unit test

The new code doesn't

Todos:
Is this ready for review?: YES
Is it a breaking change?: NO