DEV: Reduce Webpack memory use in development (#24387)

The default for webpack is to keep cached values indefinitely. In discourse, this unbound memory usage causes node to raise an OOM error after 50-100 rebuilds in development mode (with source maps enabled). Setting maxGenerations=1 means that the cache will be cleaned up regularly. With this change, I see no discernible increase in memory after 150+ rebuilds.
This commit is contained in:
David Taylor 2023-11-15 16:13:40 +00:00 committed by GitHub
parent bb941cc850
commit ed611a63ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -139,6 +139,12 @@ module.exports = function (defaults) {
output: {
publicPath: "auto",
},
cache: isProduction
? false
: {
type: "memory",
maxGenerations: 1,
},
entry: {
"assets/discourse.js/features/markdown-it.js": {
import: "./static/markdown-it",