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
feat(Stats): recursively get warnings or errors of a stats and its children #11438
Conversation
|
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.
What is use case?
https://github.com/harrisoff/move-assets-webpack-plugin/blob/master/test/index.test.js#L210 I copied function function webpack(options: Configuration = {}) {
const webpackActual = require('webpack');
// https://webpack.js.org/concepts/mode/
if (
options.mode === undefined &&
options.mode !== null &&
webpackMajor !== null &&
webpackMajor >= 4
) {
// eslint-disable-next-line no-param-reassign
options.mode = 'development';
}
if (options.mode === null) {
// eslint-disable-next-line no-param-reassign
delete options.mode;
}
const compiler = webpackActual(options);
const runAsync = () =>
new Promise((resolve, reject) => {
compiler.run((error: Error, stats: Stats) => {
if (error || stats.hasErrors()) {
reject(error);
return;
}
resolve(stats);
});
});
return { ...compiler, run: runAsync };
} And in my test codes, I used copy-webpack-plugin: try {
const options = {
plugins: [
new CopyPlugin({
patterns: [
{
from: fePublicPath,
to: feDistPath,
globOptions: {
ignore: [
'index.html',
{
glob: 'index.html',
matchBase: false,
},
],
},
},
],
}),
],
}
const stats = await webpack(config).run()
} catch (error) {
console.error(error)
}
|
For maintainers only:
|
@ The most important CI builds failed. This way your PR can't be merged. Please take a look at the CI results from azure (2 errors / 1 warnings) and appveyor (failure) and fix these issues. |
What kind of change does this PR introduce?
a feature
Did you add tests for your changes?
yes
Does this PR introduce a breaking change?
no
What needs to be documented once your changes are merged?
add
getWarnings()
andgetErrors()
methods to Stats object API