You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, Sentry SDK dev here, currently working on adding automatic upload of source maps to Sentry to our SvelteKit SDK (WIP). In a first step we're targeting the Node adapter but we'll look at other adapters afterwards.
I came across an interesting problem and I'm not sure if there's a bug in Kit or if it is intended behaviour. I want to enable source maps generation during production builds.
First off, let's look at source maps generation: I've explored how source maps options are propagated between the various svelte packages (kit, svelte, adapter-node) and I believe that the only place we need to enable source maps generation is in vite.config.js:
seems like this option is passed all the way to the svelte compiler but I might have missed something along the way. So:
Question 1: Do users need to set additional options to generate source maps at build time or is the config above enough?
With this config, I found that (at least some) source maps generated for the server-side bundles seem to point to the wrong "source" file. As an example, let's take the /src/routes/about/+page.ts file from the standard Sverdle sample app. After running the node adapter, the final server-side file is written to build/server/3-[some-id].js. Its source map however, doesn't point to the original file but instead to .sveltekit/adapter-node/entries/pages/about/_page.ts.js:
{"version": 3,"file": "3-7513ece7.js","sources": ["../../../.svelte-kit/adapter-node/entries/pages/about/_page.ts.js",// <--- this is not the actual source file"../../../.svelte-kit/adapter-node/nodes/3.js"],// ...}
Only that file's source map then points to the original +page.ts file:
{"version": 3,"file": "_page.ts.js","sources": ["../../../../../../src/routes/about/+page.ts"// <--- this is the correct source file],// ...}
Question 2: Is this a bug in source map generation or intended behaviour?
We can probably work around this by using sorcery but I'm curious either way as to why this is happening and if there's a way that we can fix this.
At this point, I'm not sure if that's a bug or not. Or maybe if we're missing something crucial for correct source maps generation. So I'd appreciate any answer that could help us out here. Also happy to open an issue if it turns out that it actually is a bug.
Thanks and have a nice day!
Why do we need source maps?
Sentry shows stack traces of errors. To make these stack traces useful, we don't want to show the minified source code but the actual source code. For that, users need to upload source maps to Sentry so we can process the stack trace and show the source files.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi, Sentry SDK dev here, currently working on adding automatic upload of source maps to Sentry to our SvelteKit SDK (WIP). In a first step we're targeting the Node adapter but we'll look at other adapters afterwards.
I came across an interesting problem and I'm not sure if there's a bug in Kit or if it is intended behaviour. I want to enable source maps generation during production builds.
First off, let's look at source maps generation: I've explored how source maps options are propagated between the various svelte packages (kit, svelte, adapter-node) and I believe that the only place we need to enable source maps generation is in
vite.config.js
:seems like this option is passed all the way to the svelte compiler but I might have missed something along the way. So:
Question 1: Do users need to set additional options to generate source maps at build time or is the config above enough?
With this config, I found that (at least some) source maps generated for the server-side bundles seem to point to the wrong "source" file. As an example, let's take the
/src/routes/about/+page.ts
file from the standard Sverdle sample app. After running the node adapter, the final server-side file is written tobuild/server/3-[some-id].js
. Its source map however, doesn't point to the original file but instead to.sveltekit/adapter-node/entries/pages/about/_page.ts.js
:Only that file's source map then points to the original
+page.ts
file:Question 2: Is this a bug in source map generation or intended behaviour?
We can probably work around this by using
sorcery
but I'm curious either way as to why this is happening and if there's a way that we can fix this.At this point, I'm not sure if that's a bug or not. Or maybe if we're missing something crucial for correct source maps generation. So I'd appreciate any answer that could help us out here. Also happy to open an issue if it turns out that it actually is a bug.
Thanks and have a nice day!
Why do we need source maps?
Sentry shows stack traces of errors. To make these stack traces useful, we don't want to show the minified source code but the actual source code. For that, users need to upload source maps to Sentry so we can process the stack trace and show the source files.
Beta Was this translation helpful? Give feedback.
All reactions