webpack-bugsnag-plugins
raw JSON → 2.2.3 verified Sat Apr 25 auth: no javascript
Webpack plugins for reporting builds and uploading source maps to Bugsnag error monitoring. Current stable version is 2.2.3, released 2024 with maintenance updates. These plugins integrate Bugsnag's CLI for source map upload and build reporting directly into the Webpack build pipeline. Key differentiator: seamless integration with webpack 3/4/5, automatic source control detection from .git/.hg/package.json, and configurable log levels. Replaces manual invocation of @bugsnag/cli. Suitable for production builds to ensure stack traces are deobfuscated and build metadata is captured.
Common errors
error Error: Cannot find module '@bugsnag/cli' ↓
cause Missing peer dependency @bugsnag/cli (required since v2.0.0).
fix
npm install --save-dev @bugsnag/cli
error TypeError: BugsnagBuildReporterPlugin is not a constructor ↓
cause Using default import instead of named import.
fix
Use const { BugsnagBuildReporterPlugin } = require('webpack-bugsnag-plugins'); or import { BugsnagBuildReporterPlugin } from 'webpack-bugsnag-plugins';
error Error: Plugin could not be instantiated: invalid options ↓
cause Passed apiKey and appVersion as separate arguments instead of an object.
fix
new BugsnagBuildReporterPlugin({ apiKey: '...', appVersion: '...' })
Warnings
breaking v2.0.0 migrated from @bugsnag/source-maps and @bugsnag/build-reporter to @bugsnag/cli. Existing users of pre-2.0 must update configuration and install @bugsnag/cli as a peer dependency. ↓
fix Upgrade to v2+ and ensure @bugsnag/cli is in devDependencies. See CHANGELOG.
gotcha The 'overwrite' option for source map upload was added in v2.1.0. In v2.0.0, it is not available. ↓
fix Upgrade to v2.1.0 or later to use overwrite option.
gotcha The build reporter will not send a report if compilation fails before the 'after-emit' hook. This can lead to missing builds in Bugsnag dashboard. ↓
fix Check webpack compilation result; ensure plugin runs only after successful builds.
deprecated Using separate 'apiKey' and 'appVersion' as two function arguments was deprecated in v1.x and removed in v2. Use a single options object. ↓
fix Pass an object: new BugsnagBuildReporterPlugin({ apiKey: ..., appVersion: ... })
gotcha If you don't set 'releaseStage' in build reporter, the build will not auto-assign unless you set 'autoAssignRelease: true'. ↓
fix Explicitly set releaseStage or autoAssignRelease to true.
Install
npm install webpack-bugsnag-plugins yarn add webpack-bugsnag-plugins pnpm add webpack-bugsnag-plugins Imports
- BugsnagBuildReporterPlugin wrong
import BugsnagBuildReporterPlugin from 'webpack-bugsnag-plugins'correctimport { BugsnagBuildReporterPlugin } from 'webpack-bugsnag-plugins' - BugsnagSourceMapUploaderPlugin wrong
let BugsnagSourceMapUploaderPlugin = require('webpack-bugsnag-plugins')correctconst { BugsnagSourceMapUploaderPlugin } = require('webpack-bugsnag-plugins') - WebpackPlugin wrong
new BugsnagBuildReporterPlugin('YOUR_KEY', '1.0.0')correctnew BugsnagBuildReporterPlugin({ apiKey: 'YOUR_KEY', appVersion: '1.0.0' })
Quickstart
// webpack.config.js
const { BugsnagBuildReporterPlugin, BugsnagSourceMapUploaderPlugin } = require('webpack-bugsnag-plugins');
const isDistEnv = process.env.NODE_ENV === 'production';
module.exports = {
entry: './app.js',
output: {
path: __dirname,
filename: 'bundle.js'
},
plugins: [
isDistEnv && new BugsnagBuildReporterPlugin({
apiKey: process.env.BUGSNAG_API_KEY,
appVersion: require('./package.json').version,
releaseStage: 'production'
}),
isDistEnv && new BugsnagSourceMapUploaderPlugin({
apiKey: process.env.BUGSNAG_API_KEY,
appVersion: require('./package.json').version,
publicPath: 'https://example.com/js',
overwrite: true
})
].filter(Boolean)
};