kit: It looks like the new version of SvelteKit is incompatible with the @sentry/sveltekit package
Describe the bug
build failure
Reproduction
- clone the project: https://github.com/sopaco/saga-reader.git.
- execute
bun run dev.
Logs
build
[18 lines elided]
│ at emitError (node:events:1:13)
│ ✗ Build failed in 6.72s
│ error during build:
│ [vite-plugin-sveltekit-compile] Failed with code 1
│ at <anonymous> (/Users/jiangmeng/workspace/research/saga-reader/node_modules/@sveltejs/kit/src/utils/fork.js:65:17)
│ at emit (node:events:93:22)
│ at #onClose (node:worker_threads:216:44)
│ error: script "build" exited with code 1
│ beforeBuildCommand `bun run build` failed with exit code 1
│ Error beforeBuildCommand `bun run build` failed with exit code 1
dev
│ [219 lines elided]
│ 5021 | */
│ 5022 | function originalPositionFor$1(map, needle) {
│ 5023 | let { line, column, bias } = needle;
│ 5024 | line--;
│ 5025 | if (line < 0)
│ 5026 | throw new Error(LINE_GTR_ZERO);
│ ^
│ error: `line` must be greater than 0 (lines start at line 1)
│ at originalPositionFor$1 (/Users/Workspace/research/saga-reader/node_modules/vite/dist/node/chunks/dep-DBxKXgDP.js:5026:19)
System Info
npx envinfo --system --npmPackages svelte,rollup,webpack --binaries --browsers
System:
OS: macOS 14.5
CPU: (12) arm64 Apple M2 Pro
Memory: 790.73 MB / 32.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 22.14.0 - ~/.nvm/versions/node/v22.14.0/bin/node
npm: 10.9.2 - ~/.nvm/versions/node/v22.14.0/bin/npm
bun: 1.2.15 - ~/.bun/bin/bun
Browsers:
Edge: 134.0.3124.51
Safari: 17.5
Severity
annoyance
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 2
- Comments: 16 (11 by maintainers)
Commits related to this issue
- test(sveltekit): Pin `@sveltejs/kit@2.21.2` to unblock CI (#16529) While we're investigating https://github.com/sveltejs/kit/issues/13869 and https://github.com/getsentry/sentry-javascript/issues/165... — committed to getsentry/sentry-javascript by Lms24 a year ago
- fix(sveltekit): Add import attribute for node exports (#16528) This patch changes the `node` export in the `package.json` file to include an `import` version (similar to the other exports) to fix htt... — committed to getsentry/sentry-javascript by eltigerchino a year ago
- work around sentry bug https://github.com/sveltejs/kit/issues/13869#issuecomment-2958203909 — committed to spacethree/cloudflare-sveltekit-sentry by jamemackson a year ago
Released with version 9.28.1! Thanks so much for your help @eltigerchino!
I’ve found the issue and it’s because Vite is resolving to the CJS version of
@sentry/sveltekitinstead of an ESM version when bundling, causing the bundle to incorrectly import things (a default import instead of named imports).Created a PR here https://github.com/getsentry/sentry-javascript/pull/16528
The workaround for now is to stay on SvelteKit
2.21.2or add the following to your Vite config:The latest Kit is bundling all deps that rely on SvelteKit so that class instantiations and instanceof checks work. Adding the package to
vite.ssr.externalensures that it isn’t bundled (and therefore the current error wouldn’t appear).I made a small repo here: https://stackblitz.com/edit/sveltejs-kit-template-default-kxvebrub
It has latest sveltekit + svelte installed and Sentry. If you run npm build, you will get errors.
Reverting the Sveltekit package back to
2.21.2makes that error go away.It looks like the new version of svelte is not compatible with the @sentry/sveltekit package. Removing the latter allows it to compile successfully.
Ok i can reproduce locally with bun and latest kit, this is a kit bug…let me see if i can move it there
Seems like issue in sentry with svelte. Currently using @sentry/sveltekit: ^8.48.0 with svelte: ^5.18.0.