Skip to content

fix: generate Worker source maps in framework templates - #1166

Open
irvinebroque wants to merge 1 commit into
cloudflare:mainfrom
irvinebroque:bib/source-maps-defaults
Open

irvinebroque wants to merge 1 commit into
cloudflare:mainfrom
irvinebroque:bib/source-maps-defaults

Conversation

@irvinebroque

@irvinebroque irvinebroque commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Generate external source maps for the Worker/server builds in the Vite, Remix, React Router, and Astro templates.

Add templates check-source-maps to the repository checks. It inspects built framework output for enabled uploads, valid external map references, mapped source, and exclusion of server maps from public assets. Document the build contract for future templates.

refs https://developers.cloudflare.com/workers/observability/profiling-in-production/ and https://blog.cloudflare.com/workers-on-demand-profiling/

Without this — debugging in production is harder. You don't get stack traces for exceptions that map back to source code. And your production profiles are harder to reason about, since they don't point back to the right line numbers in source code.

Checklist

Existing templates are updated; template metadata is unchanged. The metadata checklist below is retained from the repository template.

  • Template Metadata
    • template directory ends with -template
    • "cloudflare" section of package.json is populated
    • template preview image uploaded to Images
    • README is populated and uses <!-- dash-content-start --> and <!-- dash-content-end --> to designate the Dash readme preview
    • .gitignore file exists
    • package.json contains a deploy command
    • package.json contains private: true and no version field

@kale-stew kale-stew left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes upload_source_maps: true actually do something for the Vite-plugin templates. Confirmed locally: react-starter writes dist/worker/index.js + .map outside the assets dir, and it still works with React Router 7.18.5 (#1181).

  1. CI is red on formatting: syncpack flags package.json because check:source-maps isn't in alphabetical order, so the new check has never run in CI.
  2. Astro: after the build, pages/*.astro.mjs and several chunks lose their sourceMappingURL comment, so the template's own code maps to build output rather than src/. check-source-maps still passes because it skips files without a comment and passes once any map is non-empty. Suggest failing when a .js has a sibling .map but no comment, or when nothing under src/ is mapped, and noting the Astro limitation like the Next.js README does.
  3. I split the saas-admin-template/public/.assetsignore change out into #1183 (same contents) so it can land on its own; it'll drop out of this PR on rebase.
  4. check:source-maps needs a prior build; worth saying in CONTRIBUTING or running after turbo run build.
  5. Tests only cover the Vite-plugin layout; add the Astro and build/server paths and the missing-comment case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants