Skip to content

Infer upload_source_maps setting in the output Worker config from the build.sourcemap setting in the Vite config#12446

Merged
jamesopstad merged 3 commits intomainfrom
james/infer-sourcemap
Feb 6, 2026
Merged

Infer upload_source_maps setting in the output Worker config from the build.sourcemap setting in the Vite config#12446
jamesopstad merged 3 commits intomainfrom
james/infer-sourcemap

Conversation

@jamesopstad
Copy link
Copy Markdown
Contributor

@jamesopstad jamesopstad commented Feb 6, 2026

Fixes #11963

Infer upload_source_maps setting in the output Worker config from the build.sourcemap setting in the Vite config.

If build.sourcemap is enabled for a Worker environment, as in the following example, "upload_source_maps": true will now automatically be added to the output wrangler.json file.
This removes the need to additionally specify the upload_source_maps property in the input Worker config.

export default defineConfig({
	environments: {
		my_worker: {
			build: {
				sourcemap: true,
			},
		},
	},
	plugins: [cloudflare()],
});

Note that if upload_source_maps is set in the input Worker config, this value will take precedence.
This makes it possible to generate source maps without uploading them.


A picture of a cute animal (not mandatory, but encouraged)


Open with Devin

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Feb 6, 2026

🦋 Changeset detected

Latest commit: 188c9cb

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-project-automation github-project-automation Bot moved this to Untriaged in workers-sdk Feb 6, 2026
@jamesopstad jamesopstad changed the title James/infer sourcemap Infer upload_source_maps setting in the output Worker config from the build.sourcemap setting in the Vite config Feb 6, 2026
@claude
Copy link
Copy Markdown
Contributor

claude Bot commented Feb 6, 2026

Claude finished @jamesopstad's task —— View job


Changeset Review

✅ All changesets look good

The changeset in .changeset/tender-views-think.md meets all requirements:

  1. Version Type: minor is correct - this adds a new automatic configuration feature
  2. Changelog Quality: Clear description with a helpful code example showing how the feature works
  3. Markdown Headers: No problematic h1/h2/h3 headers used
  4. Analytics: Not applicable - no analytics collection changes
  5. Experimental features: Not applicable - this is a stable feature addition

The changeset has a clear title, explains what the feature does, provides a usage example, and notes the precedence behavior when upload_source_maps is explicitly set.


@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Feb 6, 2026

create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@12446

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@12446

miniflare

npm i https://pkg.pr.new/miniflare@12446

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@12446

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@12446

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@12446

@cloudflare/vitest-pool-workers

npm i https://pkg.pr.new/@cloudflare/vitest-pool-workers@12446

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@12446

@cloudflare/workers-utils

npm i https://pkg.pr.new/@cloudflare/workers-utils@12446

wrangler

npm i https://pkg.pr.new/wrangler@12446

commit: 188c9cb

@jamesopstad jamesopstad force-pushed the james/infer-sourcemap branch from ee022d6 to 16face5 Compare February 6, 2026 12:28
@jamesopstad jamesopstad force-pushed the james/infer-sourcemap branch from 16face5 to 188c9cb Compare February 6, 2026 12:47
@jamesopstad jamesopstad marked this pull request as ready for review February 6, 2026 13:05
@jamesopstad jamesopstad requested a review from a team as a code owner February 6, 2026 13:05
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 3 additional findings.

Open in Devin Review

() => {
const wranglerConfig = JSON.parse(
fs.readFileSync(
path.join(rootDir, "dist", "worker", "wrangler.json"),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

just a FYI that this could be simplified

Suggested change
path.join(rootDir, "dist", "worker", "wrangler.json"),
path.join(rootDir, "dist/worker/wrangler.json"),

Copy link
Copy Markdown
Contributor

@vicb vicb left a comment

Choose a reason for hiding this comment

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

LGTM, 2 nits

@github-project-automation github-project-automation Bot moved this from Untriaged to Approved in workers-sdk Feb 6, 2026
@jamesopstad jamesopstad merged commit 1231a2e into main Feb 6, 2026
44 of 45 checks passed
@jamesopstad jamesopstad deleted the james/infer-sourcemap branch February 6, 2026 13:38
@github-project-automation github-project-automation Bot moved this from Approved to Done in workers-sdk Feb 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Vite Plugin: generate sourcemap on build if user specified upload_source_maps: true

3 participants