{"id":16895,"library":"rollbar-sourcemap-webpack-plugin","title":"Rollbar Sourcemap Webpack Plugin","description":"This Webpack plugin automates the upload of generated sourcemaps to Rollbar after a production build. It addresses the challenge of making minified JavaScript stacktraces useful in Rollbar by ensuring the corresponding sourcemaps are always available. The current stable version is 3.3.0, with ongoing development and maintenance indicated by recent badges and version bumps. Its primary differentiator is deep integration with the Webpack build process, abstracting away the manual `curl` requests or shell scripts typically used for sourcemap uploads, thus reducing setup complexity and potential for error. It requires Webpack 4 or higher since version 3.0.0, streamlining the deployment of sourcemaps for error monitoring.","status":"active","version":"3.3.0","language":"javascript","source_language":"en","source_url":"https://github.com/thredup/rollbar-sourcemap-webpack-plugin","tags":["javascript","webpack","plugin","rollbar","source map","sourcemap","sourcemaps","production"],"install":[{"cmd":"npm install rollbar-sourcemap-webpack-plugin","lang":"bash","label":"npm"},{"cmd":"yarn add rollbar-sourcemap-webpack-plugin","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollbar-sourcemap-webpack-plugin","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required peer dependency for Webpack plugin functionality.","package":"webpack","optional":false}],"imports":[{"note":"The plugin is exported as a default export.","wrong":"import { RollbarSourceMapPlugin } from 'rollbar-sourcemap-webpack-plugin';","symbol":"RollbarSourceMapPlugin","correct":"import RollbarSourceMapPlugin from 'rollbar-sourcemap-webpack-plugin';"},{"note":"CommonJS `require` for older Node.js or `webpack.config.js` setups.","symbol":"RollbarSourceMapPlugin","correct":"const RollbarSourceMapPlugin = require('rollbar-sourcemap-webpack-plugin');"}],"quickstart":{"code":"const RollbarSourceMapPlugin = require('rollbar-sourcemap-webpack-plugin');\nconst path = require('path');\n\nconst PUBLIC_PATH = 'https://my.cdn.net/assets';\n\nmodule.exports = {\n  mode: 'production',\n  devtool: 'hidden-source-map',\n  entry: './src/index.js',\n  output: {\n    path: path.resolve(__dirname, 'dist'),\n    publicPath: PUBLIC_PATH,\n    filename: 'index-[contenthash].js'\n  },\n  plugins: [\n    new RollbarSourceMapPlugin({\n      accessToken: process.env.ROLLBAR_ACCESS_TOKEN ?? 'aaaabbbbccccddddeeeeffff00001111', // Use environment variable in production\n      version: process.env.GIT_SHA ?? 'default-version-123',\n      publicPath: PUBLIC_PATH,\n      includeChunks: ['main'] // Specify chunk name if desired\n    })\n  ]\n};","lang":"javascript","description":"This quickstart demonstrates how to configure the plugin in a webpack.config.js to upload sourcemaps for a production build."},"warnings":[{"fix":"Upgrade Webpack to version 4 or newer, or downgrade `rollbar-sourcemap-webpack-plugin` to a 2.x version compatible with your Webpack setup.","message":"Version 3.0.0 introduced a breaking change requiring Webpack 4 or higher. Projects using Webpack 3 or older must remain on `rollbar-sourcemap-webpack-plugin` v2.x.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Ensure `accessToken` (your Rollbar post_server_item token), `version` (a unique string for your code version, e.g., git SHA), and `publicPath` (the base URL for your deployed bundles) are all provided in the plugin configuration.","message":"The `accessToken`, `version`, and `publicPath` options are all required for the plugin to function correctly. Omitting any of these will lead to upload failures.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Set `devtool: 'hidden-source-map'` in your Webpack configuration for production builds.","message":"Using `devtool: 'hidden-source-map'` is recommended for production builds when using this plugin, as it generates sourcemaps without adding comments to the bundled files, which could expose source map URLs publicly. Other `devtool` options might embed source map references or generate inline sourcemaps which are not suitable for external upload.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-22T00:00:00.000Z","next_check":"2026-07-21T00:00:00.000Z","problems":[{"fix":"Change the import statement to `import RollbarSourceMapPlugin from 'rollbar-sourcemap-webpack-plugin';` for ESM, or `const RollbarSourceMapPlugin = require('rollbar-sourcemap-webpack-plugin');` for CommonJS.","cause":"Attempting to use named import syntax `import { RollbarSourceMapPlugin }` when the plugin is exported as a default.","error":"TypeError: RollbarSourceMapPlugin is not a constructor"},{"fix":"Review the plugin configuration in your `webpack.config.js` and ensure all required options (`accessToken`, `version`, `publicPath`) are present and correctly valued.","cause":"One of the mandatory configuration options (`accessToken`, `version`, or `publicPath`) was not provided to the plugin.","error":"Error: Missing required option: accessToken (or version/publicPath)"},{"fix":"Double-check your Rollbar `post_server_item` access token. Ensure your `version` string is unique and valid. Verify that the `publicPath` configuration matches the exact base URL where your production JavaScript bundles are hosted.","cause":"Often caused by an incorrect `accessToken`, an invalid `version` string, or a `publicPath` that doesn't correctly map to the deployed assets on your CDN.","error":"Rollbar API Error: 400 Bad Request (or similar upload failure message)"}],"ecosystem":"npm","meta_description":null}