{"id":20255,"library":"p-webpack","title":"p-webpack","description":"p-webpack is a thin wrapper that adds Promise support to Webpack's compile API (versions 1-4). Version 1.0.1 is the current stable release. It accepts the same configuration options as Webpack and returns a Promise that resolves with the compilation stats. It is a minimal, no-dependency library that simply promisifies the callback-based compiler.run(). Unlike alternatives like webpack-promise or manual wrapping, p-webpack focuses only on the run method and maintains full compatibility with Webpack's options object. It is suitable for Node.js 4+ and requires Webpack as a peer dependency.","status":"active","version":"1.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/Richienb/p-webpack","tags":["javascript","webpack","promise","options","object","value"],"install":[{"cmd":"npm install p-webpack","lang":"bash","label":"npm"},{"cmd":"yarn add p-webpack","lang":"bash","label":"yarn"},{"cmd":"pnpm add p-webpack","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency; p-webpack wraps webpack's compiler","package":"webpack","optional":false}],"imports":[{"note":"The module exports a single async function; CommonJS require works but TypeScript types may prefer ESM import.","wrong":"const webpack = require('p-webpack')","symbol":"default","correct":"import webpack from 'p-webpack'"},{"note":"This is a default-export module; destructuring the name does not work.","wrong":"const { webpack } = require('p-webpack')","symbol":"p-webpack","correct":"const webpack = require('p-webpack')"}],"quickstart":{"code":"const webpack = require('p-webpack');\nconst fs = require('fs');\n\nasync function build() {\n  try {\n    const stats = await webpack({\n      entry: './src/index.js',\n      output: {\n        path: __dirname + '/dist',\n        filename: 'bundle.js'\n      }\n    });\n    console.log('Build completed:', stats.toString({ colors: true }));\n  } catch (err) {\n    console.error('Build failed:', err);\n  }\n}\n\nbuild();","lang":"javascript","description":"Shows basic usage of p-webpack with async/await, using a simple webpack configuration."},"warnings":[{"fix":"Run 'npm install webpack' alongside p-webpack.","message":"Requires webpack as a peer dependency. Must install webpack separately.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use webpack's native promise support or upgrade to a newer wrapper.","message":"Only works with webpack 1-4. Does not support webpack 5's new compiler API.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use webpack's own multi-compiler or watch APIs directly for those features.","message":"Does not support multi-compiler or watch mode. Only wraps the single run() callback.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Change 'const { webpack } = require(\"p-webpack\")' to 'const webpack = require(\"p-webpack\")'.","cause":"Incorrect import: destructured named export instead of default.","error":"TypeError: webpack is not a function"},{"fix":"Run 'npm install webpack' in your project.","cause":"Missing webpack peer dependency.","error":"Error: Cannot find module 'webpack'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}