Problem Statement
Dear Sentry Team,
I am integrating @sentry/sveltekit with a custom SvelteKit adapter for Azure Static Web Apps.
I was able to make the sourcemap flow work, but I ran into a limitation in the rewriteSources hook API.
Context:
- My adapter is not one of the built-in adapter targets, so I use:
sentrySvelteKit({ adapter: 'other', ... })
- To keep sourcemaps correct in the final adapter output, I re-bundle / re-emit
.svelte-kit/output/server and .svelte-kit/output/client into the adapter output directories instead of raw-copying them.
- My demo/test app lives in
./tests/demo, so source paths need additional rewriting in a monorepo-style layout.
- I currently solve this with:
unstable_sentryVitePluginOptions.sourcemaps.rewriteSources
The problem:
today the hook only receives (source, map), but in my case I also need to know where the current source map file is located.
Something like this would be very helpful:
type RewriteSourcesHook = (source: string, map: any, mapPath: string) => string;
or at least:
type RewriteSourcesHook = (source: string, map: any, mapDir: string) => string;
Why this would help:
in order to rewrite relative source paths correctly, I need to resolve them relative to the source map location, not just relative to process.cwd().
Conceptually I need to do something like:
resolve(mapDir, source)
At the moment, because the hook does not provide the map location, I have to:
- scan directories,
- read
.map files,
- find which map contains the given source entry,
- reconstruct the directory of that map,
- only then rewrite the source path.
So most of my implementation is just working around the missing mapDir / mapPath context.
Providing either mapDir or mapPath to the hook would remove most of that complexity and make rewriteSources much easier to use for custom adapters and monorepo-like layouts.
My current implementation is here for reference:
https://github.com/kt-npm-modules/svelte-adapter-azure-swa/blob/main/src/utils.js
Would you consider exposing the source map directory or path to rewriteSources?
Thank you!
Konstantin
Solution Brainstorm
https://github.com/kt-npm-modules/svelte-adapter-azure-swa/blob/main/src/utils.js
https://github.com/kt-npm-modules/svelte-adapter-azure-swa/blob/2d0da5a00063f5d2758837a3b7648671bd11e33b/tests/demo/vite.config.ts#L28
Additional Context
No response
Priority
React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it.
Problem Statement
Dear Sentry Team,
I am integrating
@sentry/sveltekitwith a custom SvelteKit adapter for Azure Static Web Apps.I was able to make the sourcemap flow work, but I ran into a limitation in the
rewriteSourceshook API.Context:
sentrySvelteKit({ adapter: 'other', ... }).svelte-kit/output/serverand.svelte-kit/output/clientinto the adapter output directories instead of raw-copying them../tests/demo, so source paths need additional rewriting in a monorepo-style layout.unstable_sentryVitePluginOptions.sourcemaps.rewriteSourcesThe problem:
today the hook only receives
(source, map), but in my case I also need to know where the current source map file is located.Something like this would be very helpful:
type RewriteSourcesHook = (source: string, map: any, mapPath: string) => string;or at least:
type RewriteSourcesHook = (source: string, map: any, mapDir: string) => string;Why this would help:
in order to rewrite relative source paths correctly, I need to resolve them relative to the source map location, not just relative to
process.cwd().Conceptually I need to do something like:
resolve(mapDir, source)At the moment, because the hook does not provide the map location, I have to:
.mapfiles,So most of my implementation is just working around the missing
mapDir/mapPathcontext.Providing either
mapDirormapPathto the hook would remove most of that complexity and makerewriteSourcesmuch easier to use for custom adapters and monorepo-like layouts.My current implementation is here for reference:
https://github.com/kt-npm-modules/svelte-adapter-azure-swa/blob/main/src/utils.js
Would you consider exposing the source map directory or path to
rewriteSources?Thank you!
Konstantin
Solution Brainstorm
https://github.com/kt-npm-modules/svelte-adapter-azure-swa/blob/main/src/utils.js
https://github.com/kt-npm-modules/svelte-adapter-azure-swa/blob/2d0da5a00063f5d2758837a3b7648671bd11e33b/tests/demo/vite.config.ts#L28
Additional Context
No response
Priority
React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding
+1orme too, to help us triage it.