feat(cloudflare): Read wrangler config and resolve the Sentry options module#22291
Draft
JPeer264 wants to merge 1 commit into
Draft
feat(cloudflare): Read wrangler config and resolve the Sentry options module#22291JPeer264 wants to merge 1 commit into
JPeer264 wants to merge 1 commit into
Conversation
8343656 to
eb2d012
Compare
Contributor
size-limit report 📦
|
timfish
requested changes
Jul 15, 2026
Collaborator
There was a problem hiding this comment.
unfortunately there is no library from Cloudflare (yet) that is reading the wrangler config.
Wrangler has a unstable_readConfig API briefly mentioned here although not fully documented. This is what their Vite plugin uses and it's used a lot elsewhere so should be stable enough. It resolves and normalise the wrangler config for you.
afcb71d to
8517822
Compare
eb2d012 to
a7e002e
Compare
… module
Add the building blocks the auto-instrument Vite plugin will use, with no wiring
into a plugin yet:
- `wranglerConfig`: locate and parse `wrangler.{json,jsonc,toml}`, returning the
worker entry (`main`) and the configured Durable Object class names.
- `instrumentFile`: find a conventional `instrument.server.{ts,js,mjs,cjs}` next
to the entry and build the options import, falling back to an env-based
callback when absent.
- `defineCloudflareOptions`: identity helper that gives the options callback its
type in that module.
Adds `jsonc-parser`, `smol-toml`, and `magic-string` as dependencies.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
8517822 to
7e8f420
Compare
a7e002e to
b5454ef
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add the building blocks the auto-instrument Vite plugin will use, with no wiring into a plugin yet. These will come in a follow-up PR one by one.
wranglerConfig: locate and parsewrangler.{json,jsonc,toml}, returning the worker entry (main) and the configured Durable Object class names.instrumentFile: find a conventionalinstrument.server.{ts,js,mjs,cjs}next to the entry and build the options import, falling back to an env-based callback when absent.defineCloudflareOptions: identity helper that gives the options callback its type in that module.jsonc-parserandsmol-tomlare also used bywrangleritself, unfortunately there is no library from Cloudflare (yet) that is reading the wrangler config.The
instrument.server.*config can and should be written like the following:defineCloudflareOptionsis only adding typings forenvso it is easier it can also be used like the following:or
Future possibilities
For now there is a shared config for all instrumentations. In the future there would be the possibility to have different exports and map them to the actual bindings. E.g.: