Detalhes do pacote

webpack-bugsnag-plugins

bugsnag315.1kMIT2.2.1

Webpack plugins for common Bugsnag actions

bugsnag, webpack

readme (leia-me)

Documentation Build status NPM

Webpack plugins for reporting new builds to your dashboard and uploading source maps for deobfuscating stack traces.

Installation

npm install --save-dev webpack-bugsnag-plugins

Plugins

new BugsnagBuildReporterPlugin(build, opts):WebpackPlugin

const { BugsnagBuildReporterPlugin } = require('webpack-bugsnag-plugins')

Reports your application's build to BugSnag. It can auto detect source control from .git, .hg and package.json. This plugin hooks into the 'after-emit' event once all output files have been generated by the Webpack compiler. If anything causes the compilation to fail before this step, the build report will not get sent.

  • build describes the build you are reporting to Bugsnag
    • apiKey: string your Bugsnag API key [required]
    • appVersion: string the version of the application you are building [required]
    • releaseStage: string 'production', 'staging' etc. (leave blank if this build can be released to different releaseStages)
    • sourceControl: object an object describing the source control of the build (if not specified, the module will attempt to detect source control information from .git, .hg and the nearest package.json)
      • provider: string can be one of: 'github', 'github-enterprise', 'gitlab', 'gitlab-onpremise', 'bitbucket', 'bitbucket-server'
      • repository: string a URL (git/ssh/https) pointing to the repository, or webpage representing the repository
      • revision: string the unique identifier for the commit (e.g. git SHA)
    • builderName: string the name of the person/machine that created this build (defaults to the result of the whoami command)
    • autoAssignRelease: boolean automatically associate this build with any new error events and sessions that are received for the releaseStage until a subsequent build notification is received. If this is set to true and no releaseStage is provided the build will be applied to 'production'.
    • metadata: object an object describing key/value pairs containing any custom build information that provides useful metadata about the build. e.g. build configuration parameters, versions of dependencies, reason for the build etc.
  • opts
    • logLevel: string the minimum severity of log to output ('debug', 'info', 'warn', 'error'), default 'warn'
    • logger: object provide a different logger object { debug, info, warn, error }
    • path: string the path to search for source control info, defaults to process.cwd()
    • endpoint: string post the build payload to a URL other than the default (https://build.bugsnag.com)

Usage

const { BugsnagBuildReporterPlugin } = require('webpack-bugsnag-plugins')

module.exports = {
  entry: './app.js',
  output: {
    path: __dirname,
    filename: './bundle.js'
  },
  plugins: [].concat(
    // It's a good idea to only run this plugin when you're building a bundle
    // that will be released, rather than for every development build
    isDistEnv
      ? new BugsnagBuildReporterPlugin({
          apiKey: 'YOUR_API_KEY',
          appVersion: '1.2.3'
        }, { /* opts */ })
      : []
  )
}

new BugsnagSourceMapUploaderPlugin(opts):WebpackPlugin

const { BugsnagSourceMapUploaderPlugin } = require('webpack-bugsnag-plugins')

Upload your application's sourcemap(s) to Bugsnag. When Webpack is done producing output, this plugin detects sourcemaps for any output chunks and uploads them to Bugsnag.

  • opts provide options to the sourcemap uploader
    • apiKey: string your Bugsnag API key [required]
    • publicPath: string the path to your bundled assets (as the browser will see them). This option must either be provided here, or as output.publicPath in your Webpack config.
    • appVersion: string the version of the application you are building (defaults to the version set in your project's package.json file, if one is specified there)
    • codeBundleId: string the codeBundleId (e.g. for NativeScript projects)
    • overwrite: boolean whether you want to overwrite previously uploaded sourcemaps
    • endpoint: string post the build payload to a URL other than the default (https://upload.bugsnag.com)
    • ignoredBundleExtensions: string[] a list of bundle file extensions which shouldn't be uploaded (default [ '.css' ])

Usage

const { BugsnagSourceMapUploaderPlugin } = require('webpack-bugsnag-plugins')

module.exports = {
  entry: './app.js',
  devtool: 'source-map',
  output: {
    path: __dirname,
    filename: './bundle.js',
    publicPath: 'https://your-app.xyz/assets/'
  },
  plugins: [].concat(
    // It's a good idea to only run this plugin when you're building a bundle
    // that will be released, rather than for every development build
    isDistEnv
      ? new BugsnagSourceMapUploaderPlugin({
          apiKey: 'YOUR_API_KEY',
          appVersion: '1.2.3'
        })
      : []
  )
}

Supported Webpack versions

These plugins have been tested with webpack versions 3, 4 and 5.

Support

Contributing

All contributors are welcome! See our contributing guide.

License

This module is free software released under the MIT License. See LICENSE.txt for details.

changelog (log de mudanças)

Changelog

[2.2.1] - 2025-05-27

  • Ensure we expose all options in the Webpack plugin that are available in the Bugsnag CLI (#99)
  • Allow BugsnagBuildReporterPlugin to pass all options in a single object (#99)

[2.2.0] - 2025-05-13

  • Ensure webpack plugin callback is called when running the source map upload and create build plugins (#95)

[2.1.0] - 2025-05-12

  • Ensure that we pass overwrite and endpoint to the BugSnag CLI (#93)

[2.0.0] - 2025-04-28

There are no breaking changes in this release, but it has been marked as a major change due to the significant difference in the underlying tooling. Both source map upload and registering new builds is now done via the @bugsnag/cli package.

  • Migrate @bugsnag/source-maps to @bugsnag/cli (#91)
  • Migrate @bugsnag/build-reporter to @bugsnag/cli (#91)

[1.9.0] - 2025-02-24

  • handle parent directory references in source paths (#85)

[1.8.0] - 2021-07-07

  • Use webpack for logging (#55)
  • Upgrade build reporter to latest version (#57)

[1.7.0] - 2021-05-18

  • Update to v2 of @bugsnag/source-maps (#53)

[1.6.0] - 2020-12-17

  • Add support for Webpack 5 (credit @chadrien) (#49)

[1.5.0] - 2020-12-10

  • Upgrade to new @bugsnag/source-maps library (#48)

[1.4.5] - 2020-01-28

  • Allow setting of codeBundleId on BugsnagSourceMapUploaderPlugin (#40, fixes #38)

[1.4.2] - 2019-09-10

Changed

  • Allow publicPath to be an empty string (supports targeting Node and using the top level project directory for the output) (#39)

[1.4.1] - 2019-08-12

Fixed

  • Manually join paths rather than using url.resolve() as that doesn't work with the (*) wildcard character (#37, fixes #35)

[1.4.0] - 2019-03-13

Changed

  • Switch to manually calculating full paths on disk, preparing for the removal of existsAt in Webpack v5. This fixes a bug when output.futureEmitAssets is enabled in Webpack v4.29 (#29, fixes #28)

[1.3.0] - 2019-01-21

Added

  • Add a list of ignored bundle exceptions (defaults to [ '.css' ], preventing CSS bundles and source maps from unnecessarily being uploaded) (#26, fixes #24)

Changed

  • Improve bundle source file lookup (when bundles are output to a different directory than their source maps) (#27, fixes #20)

[1.2.4] - 2018-12-14

Fixed

  • Handle missing asset when source map is not written to disk (#23, fixes #18)

[1.2.3] - 2018-12-04

Added

  • Retry on failed requests (via dependency bump) (#21)

[1.2.2] - 2018-06-27

Added

  • Support multiple maps per chunk (#14)

[1.2.1] - 2018-06-25

Fixed

  • Tolerate leading slashes in chunk names (supports use with laravel-mix) (#12)

[1.2.0] - 2018-06-15

This version uses feature detection to decide which Webpack APIs to use, making this change backwards compatible with Webpack v3.

[1.1.1] - 2018-03-15

Fixed

  • fix(source-map-uploader): Only find corresponding source if a map file was found (#4)

[1.1.0] - 2018-02-21

Added

  • Added BugsnagSourceMapUploaderPlugin (#1)

[1.0.0] - 2018-01-15

Initial release 🚀