-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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(core): close webpack compiler when build complete #6608
fix(core): close webpack compiler when build complete #6608
Conversation
Call webpack `close` method when build complete according to https://webpack.js.org/api/node/#run. Fallback webpack 4 `close` method
Call webpack `close` method when build complete according to https://webpack.js.org/api/node/#run. Fallback webpack 4 `close` method
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/nrwl/nx-dev/2xEjgV4hruiRSZPLXdYYG5jd7gCj [Deployment for f2f6832 canceled] |
Nx Cloud ReportCI ran the following commands for commit f2f6832. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this branch Sent with 💌 from NxCloud. |
Call webpack `close` method when build complete according to https://webpack.js.org/api/node/#run. Fallback webpack 4 `close` method
@FrozenPandaz please take a look when you have time. I think it is an important change. |
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 looks like this causes issues with other plugins. Can you take a look please?
@@ -26,7 +26,10 @@ export function runWebpack(config: any, webpack: any): Observable<any> { | |||
} else { | |||
webpackCompiler.run((err, stats) => { | |||
callback(err, stats); | |||
subscriber.complete(); | |||
|
|||
webpackCompiler.close(() => { |
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.
Instead of monkey patching webpack above, perhaps it is easier to check for the existence of a close
method?
if (webpackCompiler.close) {
webpackCompiler.close(() => {
subscriber.complete();
});
} else {
subscriber.complete();
}
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.
@FrozenPandaz, but if you check the close method in that case you will have a garbage after release of the Nx 13. If I do not mistake you will remove files with monkey patched code anyway. Thus it looks better in my opinion. Anyway it is up to you
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.
Thank you for thinking ahead!
That is okay because it is only 1 place. Please add a TODO
comment saying to clean it up the conditional after Nx 13 😄.
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.
@FrozenPandaz, done. I removed the fallback for webpack 4 and added if
statement with TODO
.
Call webpack `close` method when build complete according to https://webpack.js.org/api/node/#run.
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.
Awesome! Thank you making those changes! LGTM 🎉
* fix(core): close webpack compiler when build complete Call webpack `close` method when build complete according to https://webpack.js.org/api/node/#run. Fallback webpack 4 `close` method
* fix(core): close webpack compiler when build complete Call webpack `close` method when build complete according to https://webpack.js.org/api/node/#run. Fallback webpack 4 `close` method
This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request. |
Call webpack
close
method when build complete according to . Fallback webpack 4close
methodCurrent Behavior
Currently the webpack compiler does not call the
close
method after the build complete, because webpack 4 does not have it. But it is crucial for the webpack 5 to be able to use persistent cache.Expected Behavior
The
close
method of webpack compiler instance called when build complete. Fallback webpack 4 compiler instance with theclose
method.