Skip to content

Commit 65c241a

Browse files
committed
feat: webpack-dev-server GC plugin & auto-restat on crash - prettier
1 parent 7aca28d commit 65c241a

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

config/webpack/ForceGarbageCollectionPlugin.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type {Compiler} from 'webpack';
44
/**
55
* Custom webpack plugin that forces garbage collection every 5 compilations
66
* and logs memory usage to help monitor memory consumption during development.
7-
*
7+
*
88
* Note: Requires Node.js to be started with --expose-gc flag to enable garbage collection.
99
*/
1010
class ForceGarbageCollectionPlugin {
@@ -14,18 +14,18 @@ class ForceGarbageCollectionPlugin {
1414
if (gc && typeof gc === 'function') {
1515
compiler.hooks.done.tap(this.constructor.name, () => {
1616
this.compilationCount++;
17-
17+
1818
// Log memory usage every compilation
1919
const memUsage = process.memoryUsage();
2020
const heapUsedMB = Math.round(memUsage.heapUsed / 1024 / 1024);
2121
const heapTotalMB = Math.round(memUsage.heapTotal / 1024 / 1024);
22-
22+
2323
console.log(`📊 Compilation #${this.compilationCount} - Heap: ${heapUsedMB}MB/${heapTotalMB}MB`);
2424
if (this.compilationCount % 5 === 0) {
2525
console.log(`🗑️ Forcing garbage collection after ${this.compilationCount} compilations`);
2626
// @ts-expect-error - gc is a global function provided when Node.js is started with --expose-gc flag
2727
gc();
28-
28+
2929
// Log memory after garbage collection
3030
const memAfterGC = process.memoryUsage();
3131
const heapAfterMB = Math.round(memAfterGC.heapUsed / 1024 / 1024);

config/webpack/webpack.common.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ function mapEnvironmentToLogoSuffix(environmentFile: string): string {
6969
*/
7070
const getCommonConfiguration = ({file = '.env', platform = 'web'}: Environment): Configuration => {
7171
const isDevelopment = file === '.env' || file === '.env.development';
72-
72+
7373
return {
7474
mode: isDevelopment ? 'development' : 'production',
7575
devtool: 'source-map',
@@ -145,10 +145,10 @@ const getCommonConfiguration = ({file = '.env', platform = 'web'}: Environment):
145145
}),
146146
...(file === '.env.production' || file === '.env.staging'
147147
? [
148-
new IgnorePlugin({
149-
resourceRegExp: /@welldone-software\/why-did-you-render/,
150-
}),
151-
]
148+
new IgnorePlugin({
149+
resourceRegExp: /@welldone-software\/why-did-you-render/,
150+
}),
151+
]
152152
: []),
153153
...(platform === 'web' ? [new CustomVersionFilePlugin()] : []),
154154
new DefinePlugin({

0 commit comments

Comments
 (0)