Webpack: cache lib.js to disk to prevent occasional OOM
| @@ -1,4 +1,5 @@ | ||
| 1 | 1 | import process from 'node:process'; |
| 2 | +import fs from 'node:fs'; | |
| 2 | 3 | import webpack from 'webpack'; |
| 3 | 4 | import middleware from 'webpack-dev-middleware'; |
| 4 | 5 | import { publicLibConfig } from '../../webpack.config.js'; |
| @@ -16,5 +17,8 @@ export default function getWebpackServeMiddleware() { | ||
| 16 | 17 | }); |
| 17 | 18 | } |
| 18 | 19 | |
| 19 | 20 | return middleware(compiler, {}); |
| 21 | + // @ts-ignore Use actual file system to ease on heap memory usage | |
| 22 | + outputFileSystem: fs, | |
| 23 | + }); | |
| 20 | 24 | } |
| @@ -24,6 +24,7 @@ export const publicLibConfig = { | ||
| 24 | 24 | hints: false, |
| 25 | 25 | }, |
| 26 | 26 | output: { |
| 27 | + path: path.resolve(process.cwd(), 'dist'), | |
| 27 | 28 | filename: 'lib.js', |
| 28 | 29 | libraryTarget: 'module', |
| 29 | 30 | }, |