{"id":26650,"library":"webpack-prebundle-plugin","title":"Webpack Prebundle Plugin","description":"A Webpack plugin that prebundles vendor and common code using esbuild, reducing the number of modules Webpack needs to process and boosting build speed. Version 1.0.2 is the latest stable release. It uses esbuild for fast bundling and can replace DLLPlugin without the need for pre-building or committing bundles to Git. Supports watch mode via chokidar. Differentiators: simpler than DLLPlugin, no manual DLL build step, and automatically externalizes prebundled modules via Webpack externals.","status":"active","version":"1.0.2","language":"javascript","source_language":"en","source_url":"https://github.com/prototeam/webpack-prebundle-plugin","tags":["javascript","webpack","prebundling"],"install":[{"cmd":"npm install webpack-prebundle-plugin","lang":"bash","label":"npm"},{"cmd":"yarn add webpack-prebundle-plugin","lang":"bash","label":"yarn"},{"cmd":"pnpm add webpack-prebundle-plugin","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Used for watch mode when watching entry files for changes","package":"chokidar","optional":true},{"reason":"Core bundler for prebundling vendor and common code","package":"esbuild","optional":false}],"imports":[{"note":"Package is CommonJS only; named export is default export.","wrong":"import webpackPrebundlePlugin from 'webpack-prebundle-plugin'","symbol":"webpackPrebundlePlugin","correct":"const webpackPrebundlePlugin = require('webpack-prebundle-plugin')"},{"note":"Do not attempt to access a sub-property; the require returns the constructor directly.","wrong":"new webpackPrebundlePlugin.PrebundlePlugin({...})","symbol":"new webpackPrebundlePlugin({...})","correct":"new webpackPrebundlePlugin({ vendors: { entries: ['react'], output: path.resolve(__dirname, 'vendors.js') } })"},{"note":"There is no named export; using named import will result in undefined.","wrong":"import { PrebundlePlugin } from 'webpack-prebundle-plugin'","symbol":"webpackPrebundlePlugin as default export","correct":"import webpackPrebundlePlugin = require('webpack-prebundle-plugin')"}],"quickstart":{"code":"// webpack.config.js\nconst webpackPrebundlePlugin = require('webpack-prebundle-plugin');\nconst path = require('path');\n\nmodule.exports = {\n  plugins: [\n    new webpackPrebundlePlugin({\n      vendors: {\n        entries: ['react', 'react-dom', 'antd'],\n        output: path.resolve(__dirname, '../public/vendors.js')\n      },\n      commons: [\n        {\n          entry: path.resolve(__dirname, '../src/services/index.ts'),\n          output: path.resolve(__dirname, '../src/prebuilt/services/index.js'),\n          watch: true\n        }\n      ]\n    })\n  ]\n};\n// Then add <script src=\"%PUBLIC_URL%/vendors.js\"></script> in HTML template","lang":"javascript","description":"Configures the plugin to prebundle vendors and common code, reducing Webpack module count and improving build speed."},"warnings":[{"fix":"Use require('webpack-prebundle-plugin') or use a bundler/transpiler to handle CJS interop.","message":"Package is CommonJS only. Using ES import syntax (e.g., import webpackPrebundlePlugin from '...') will fail.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Avoid manually setting externals for the same modules; let the plugin handle it.","message":"The plugin uses Webpack externals internally. If you have conflicting externals configuration, prebundling may not work correctly.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Ensure chokidar is installed as a dependency (it's a peer dependency).","message":"Watch mode for commons relies on chokidar. If chokidar is not installed or fails, watch will silently not work.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Refer to the README or TypeScript definitions for current options.","message":"The schema.json is not actively maintained and may be out of sync with actual options.","severity":"deprecated","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run 'npm install chokidar' or 'yarn add chokidar'.","cause":"Peer dependency chokidar is not installed.","error":"Module not found: Error: Can't resolve 'chokidar'"},{"fix":"Use 'const webpackPrebundlePlugin = require('webpack-prebundle-plugin');' then 'new webpackPrebundlePlugin(...)'.","cause":"Using ES import syntax instead of require, or attempting to instantiate a non-existent named export.","error":"TypeError: webpackPrebundlePlugin is not a constructor"},{"fix":"Run 'npm install esbuild' or 'yarn add esbuild'.","cause":"Peer dependency esbuild is not installed.","error":"Error: Cannot find module 'esbuild'"},{"fix":"Use path.resolve to provide an absolute path, e.g., path.resolve(__dirname, 'vendors.js').","cause":"The output path provided is relative, not absolute.","error":"PrebundlePlugin: vendors output must be an absolute path"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}