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: memory leak when writeToDisk used #472

Merged
merged 1 commit into from
Sep 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ module.exports = {

for (const compiler of compilers) {
compiler.hooks.emit.tap('WebpackDevMiddleware', (compilation) => {
if (compiler.hasWebpackDevMiddlewareAssetEmittedCallback) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Ugly name, but we guarantee what we don't intersect with something

Copy link
Member Author

Choose a reason for hiding this comment

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

Also in webpack@5 assetEmitted hook has compilation in arguments so we simplify this code in near future

return;
}

compiler.hooks.assetEmitted.tapAsync(
'WebpackDevMiddleware',
(file, content, callback) => {
Expand Down Expand Up @@ -74,6 +78,7 @@ module.exports = {
});
}
);
compiler.hasWebpackDevMiddlewareAssetEmittedCallback = true;
Copy link

Choose a reason for hiding this comment

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

We don't actually need to create a flag for the compiler. e.g.

let hasWebpackDevMiddlewareAssetEmitted = false;
compiler.hooks.emit.tap('WebpackDevMiddleware', (compilation) => {
// ...

hasWebpackDevMiddlewareAssetEmitted = true;

Copy link
Member Author

Choose a reason for hiding this comment

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

@unbug developers can add new compiler in runtime

});
}
},
Expand Down
Loading