Skip to content

Improve @sentry/wizard -i sourcemaps for Cloudflare/Wrangler #824

@timkelty

Description

@timkelty

Problem Statement

The docs point you to @sentry/wizard -i sourcemaps when setting up Cloudflare + sourcemaps.

If you're using wrangler's default bundler, that doesn't help you much:

  • It asks you for an output directory, when wrangler will build to .wrangler/tmp/bundle-{hash} by default.
  • It also asks for a "production build command", which most boilerplates don't have (the simply have "deploy": "wrangler deploy", which takes an --env arg)

Related: getsentry/sentry-javascript#14841

Solution Brainstorm

If you're using the default bundler, you really need to be using --outdir ./dist so sentry CLI knows where to look.

Also, rather than tacking on npm run sentry:sourcemaps, I think using NPM's Pre & Post Scripts would be a better choice, eg:

{
  "scripts": {
    "deploy": "wrangler deploy --outdir ./dist",
    "postdeploy": "npm run sentry:sourcemaps",
    "sentry:sourcemaps": "sentry-cli sourcemaps inject ./dist && sentry-cli sourcemaps upload ./dist"
  }
}

This would allow people to still run npm deploy -- --env=production and have sourcemaps uploaded.

Even better than that, would be to get Cloudflare to expand their custom builds config, so you could do something after a build and not just before.

Metadata

Metadata

Assignees

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions