Webpack: cache lib.js to disk to prevent occasional OOM

This commit is contained in:
Cohee
2024-11-28 22:39:20 +02:00
parent 4f24f8078d
commit f630c8892a
2 changed files with 6 additions and 1 deletions

View File

@ -1,4 +1,5 @@
import process from 'node:process'; import process from 'node:process';
import fs from 'node:fs';
import webpack from 'webpack'; import webpack from 'webpack';
import middleware from 'webpack-dev-middleware'; import middleware from 'webpack-dev-middleware';
import { publicLibConfig } from '../../webpack.config.js'; import { publicLibConfig } from '../../webpack.config.js';
@ -16,5 +17,8 @@ export default function getWebpackServeMiddleware() {
}); });
} }
return middleware(compiler, {}); return middleware(compiler, {
// @ts-ignore Use actual file system to ease on heap memory usage
outputFileSystem: fs,
});
} }

View File

@ -24,6 +24,7 @@ export const publicLibConfig = {
hints: false, hints: false,
}, },
output: { output: {
path: path.resolve(process.cwd(), 'dist'),
filename: 'lib.js', filename: 'lib.js',
libraryTarget: 'module', libraryTarget: 'module',
}, },