Uploading Honeybadger source maps with esbuild and Sprockets

Curated ago by @jeremysmithco

Description

If you are using Honeybadger for JS error monitoring on your Rails app, you may want to upload source maps so they can be applied to JS stack traces.

Here’s how you can do that if you are using esbuild, Sprockets, and deploying to Heroku. The source map will be uploaded to Honeybadger during the build phase, via a Rake task enhancing the assets:precompile step.

1
2
3
4
5
6
7
8
9
10
{
  "name": "app",
  "private": true,
  "dependencies": {
    "esbuild": "^0.22"
  },
  "scripts": {
    "build": "node esbuild.config.mjs"
  }
}

This is a truncated example, only showing the esbuild dependency and build script.