{"id":20095,"library":"heap-sampling-webpack-plugin","title":"Heap Sampling Webpack Plugin","description":"A Webpack plugin that adds heap sampling profiling to builds using Node.js Inspector HeapProfiler. It generates .heapprofile files openable in Chromium DevTools Memory tab. Version 1.2.2 is stable with no recent updates. Unlike CPU profiling (e.g., webpack.debug.ProfilingPlugin), this focuses on memory allocation, suitable for production builds to diagnose memory consumption in build machines. Configuration is minimal via Webpack plugin array.","status":"active","version":"1.2.2","language":"javascript","source_language":"en","source_url":null,"tags":["javascript"],"install":[{"cmd":"npm install heap-sampling-webpack-plugin","lang":"bash","label":"npm"},{"cmd":"yarn add heap-sampling-webpack-plugin","lang":"bash","label":"yarn"},{"cmd":"pnpm add heap-sampling-webpack-plugin","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Plugin is CommonJS only; no ES module wrapper provided.","wrong":"import HeapSamplingPlugin from 'heap-sampling-webpack-plugin';","symbol":"HeapSamplingPlugin","correct":"const HeapSamplingPlugin = require('heap-sampling-webpack-plugin');"},{"note":"Options are passed as an object, not a string. The only option is outputPath.","wrong":"new HeapSamplingPlugin('/path/to/file.heapprofile')","symbol":"new HeapSamplingPlugin()","correct":"new HeapSamplingPlugin({ outputPath: '/path/to/file.heapprofile' })"},{"note":"No TypeScript types included; use any or declare module manually.","wrong":"import { HeapSamplingPlugin } from 'heap-sampling-webpack-plugin';","symbol":"HeapSamplingPlugin as type (TypeScript)","correct":"declare module 'heap-sampling-webpack-plugin' { const HeapSamplingPlugin: any; export = HeapSamplingPlugin; }"}],"quickstart":{"code":"const HeapSamplingPlugin = require('heap-sampling-webpack-plugin');\n\nmodule.exports = {\n  plugins: [\n    new HeapSamplingPlugin({\n      outputPath: '/tmp/build.heapprofile'\n    })\n  ]\n};","lang":"javascript","description":"Shows basic Webpack configuration with HeapSamplingPlugin enabling heap profiling output to a file."},"warnings":[{"fix":"Ensure Node.js process has inspector access (--inspect flag not required, but runtime must support Inspector).","message":"Plugin uses Node.js Inspector protocol, which may not be available in all environments (e.g., restricted Docker containers).","severity":"gotcha","affected_versions":"all"},{"fix":"Use a unique filename per build (e.g., include timestamp in outputPath).","message":"Output file is overwritten on each build without warning.","severity":"gotcha","affected_versions":"all"},{"fix":"Test with your Webpack version; consider alternatives like webpack-bundle-analyzer for memory analysis.","message":"The plugin has not been updated in several years; may not work with Webpack 5+ due to internal API changes.","severity":"deprecated","affected_versions":">=1.2.2"},{"fix":"Use only for diagnostic builds, not in CI pipeline for every commit.","message":"Heap sampling increases build time and memory usage significantly.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Ensure you are using a standard Node.js runtime (not a stripped-down build) and that the process has inspector permissions.","cause":"Node.js runtime does not support Inspector (e.g., in some bundled environments).","error":"Error: Inspector is not available"},{"fix":"Use require('heap-sampling-webpack-plugin') instead of import.","cause":"Incorrect import style (used ES module import on CommonJS module).","error":"TypeError: HeapSamplingPlugin is not a constructor"},{"fix":"Ensure outputPath directory exists and is writable. Use absolute path or ensure relative path is correct for Webpack context.","cause":"Plugin runs after compilation but may not have permission to write to outputPath.","error":"heapprofile file empty or not generated"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}