Registry / devops / webpack-prebundle-plugin

webpack-prebundle-plugin

JSON →
library1.0.2jsnpmunverified

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.

npm install webpack-prebundle-plugin
INSTALL
IMPORT
SIG · WEBPACK-PREBUNDLE-
W
webpack-prebundle-plugin
devopsjavascriptv1.0.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

webpackPrebundlePlugin
const webpackPrebundlePlugin = require('webpack-prebundle-plugin')
import webpackPrebundlePlugin from 'webpack-prebundle-plugin'
Package is CommonJS only; named export is default export.
new webpackPrebundlePlugin({...})
new webpackPrebundlePlugin({ vendors: { entries: ['react'], output: path.resolve(__dirname, 'vendors.js') } })
new webpackPrebundlePlugin.PrebundlePlugin({...})
Do not attempt to access a sub-property; the require returns the constructor directly.
webpackPrebundlePlugin as default export
import webpackPrebundlePlugin = require('webpack-prebundle-plugin')
import { PrebundlePlugin } from 'webpack-prebundle-plugin'
There is no named export; using named import will result in undefined.

Configures the plugin to prebundle vendors and common code, reducing Webpack module count and improving build speed.

// webpack.config.js const webpackPrebundlePlugin = require('webpack-prebundle-plugin'); const path = require('path'); module.exports = { plugins: [ new webpackPrebundlePlugin({ vendors: { entries: ['react', 'react-dom', 'antd'], output: path.resolve(__dirname, '../public/vendors.js') }, commons: [ { entry: path.resolve(__dirname, '../src/services/index.ts'), output: path.resolve(__dirname, '../src/prebuilt/services/index.js'), watch: true } ] }) ] }; // Then add <script src="%PUBLIC_URL%/vendors.js"></script> in HTML template
Debug
Known issues
gotchaPackage is CommonJS only. Using ES import syntax (e.g., import webpackPrebundlePlugin from '...') will fail.
fix
Use require('webpack-prebundle-plugin') or use a bundler/transpiler to handle CJS interop.
affects: >=1.0.0
gotchaThe plugin uses Webpack externals internally. If you have conflicting externals configuration, prebundling may not work correctly.
fix
Avoid manually setting externals for the same modules; let the plugin handle it.
affects: >=0.1.0
gotchaWatch mode for commons relies on chokidar. If chokidar is not installed or fails, watch will silently not work.
fix
Ensure chokidar is installed as a dependency (it's a peer dependency).
affects: >=1.0.0
deprecatedThe schema.json is not actively maintained and may be out of sync with actual options.
fix
Refer to the README or TypeScript definitions for current options.
affects: >=1.0.0
Errors
Common errors & fixes
Module not found: Error: Can't resolve 'chokidar'
Peer dependency chokidar is not installed.
fix
Run 'npm install chokidar' or 'yarn add chokidar'.
TypeError: webpackPrebundlePlugin is not a constructor
Using ES import syntax instead of require, or attempting to instantiate a non-existent named export.
fix
Use 'const webpackPrebundlePlugin = require('webpack-prebundle-plugin');' then 'new webpackPrebundlePlugin(...)'.
Error: Cannot find module 'esbuild'
Peer dependency esbuild is not installed.
fix
Run 'npm install esbuild' or 'yarn add esbuild'.
PrebundlePlugin: vendors output must be an absolute path
The output path provided is relative, not absolute.
fix
Use path.resolve to provide an absolute path, e.g., path.resolve(__dirname, 'vendors.js').
Upgrade
Version history
1.0.2latest on npm
Audit
Dependencies
chokidaroptionalUsed for watch mode when watching entry files for changes
esbuildrequiredCore bundler for prebundling vendor and common code
Agent activity
12 hits · last 30 days
node
12
Resources
webpack-prebundle-plugin — npm install webpack-prebundle-plugin · libregistry