sveltejs / svelte

Cybernetically enhanced web apps
https://svelte.dev
MIT License
78.49k stars 4.11k forks source link

Latest svelte@5.0.0-next.47 breaks my app #10404

Closed jgb-solutions closed 7 months ago

jgb-solutions commented 7 months ago

Describe the bug

I just updated to svelte@5.0.0-next.47 and it broke my app. It keeps throwing that some imports are duplicated but they are not. I had to go back to svelte@5.0.0-next.45. Hopefully I committed my bun.lockb file to Git before updating. Here's an snippet of the error message:

{
  name: 'CompileError',
  id: '/Users/jgb/Code/JGB/Web/mp3pam-svelte/src/lib/components/Player.svelte',
  message: "/Users/jgb/Code/JGB/Web/mp3pam-svelte/src/lib/components/Player.svelte:1:27 'trpcClient' has already been declared",
  frame: '1  |  <script lang="ts">\n' +
    "2  |  \timport { trpcClient } from '$lib/trpc/client'\n" +
    '   |          ^\n' +
    "3  |  \timport Container from './Container.svelte'\n" +
    "4  |  \timport { page } from '$app/stores'",
  code: 'duplicate-declaration',
  stack: "CompileError: 'trpcClient' has already been declared\n" +
    '    at error (file:///Users/jgb/Code/JGB/Web/mp3pam-svelte/node_modules/svelte/src/compiler/errors.js:532:8)\n' +
    '    at Scope.declare (file:///Users/jgb/Code/JGB/Web/mp3pam-svelte/node_modules/svelte/src/compiler/phases/scope.js:98:4)\n' +
    '    at Scope.declare (file:///Users/jgb/Code/JGB/Web/mp3pam-svelte/node_modules/svelte/src/compiler/phases/scope.js:92:25)\n' +
    '    at Scope.declare (file:///Users/jgb/Code/JGB/Web/mp3pam-svelte/node_modules/svelte/src/compiler/phases/scope.js:92:25)\n' +
    '    at Scope.declare (file:///Users/jgb/Code/JGB/Web/mp3pam-svelte/node_modules/svelte/src/compiler/phases/scope.js:92:25)\n' +
    '    at Scope.declare (file:///Users/jgb/Code/JGB/Web/mp3pam-svelte/node_modules/svelte/src/compiler/phases/scope.js:92:25)\n' +
    '    at ImportDeclaration (file:///Users/jgb/Code/JGB/Web/mp3pam-svelte/node_modules/svelte/src/compiler/phases/scope.js:417:17)\n' +
    '    at visit (file:///Users/jgb/Code/JGB/Web/mp3pam-svelte/node_modules/zimmerframe/src/walk.js:121:13)\n' +
    '    at file:///Users/jgb/Code/JGB/Web/mp3pam-svelte/node_modules/zimmerframe/src/walk.js:52:25\n' +
    '    at Array.forEach (<anonymous>)',
  loc: {
    line: 1,
    column: 27,
    file: '/Users/jgb/Code/JGB/Web/mp3pam-svelte/src/lib/components/Player.svelte'
  },
  plugin: 'vite-plugin-svelte',
  pluginCode: '<script lang="ts">\n' +
    "\timport { trpcClient } from '$lib/trpc/client'\n" +

Reproduction

I ran bun update to update all the packages. I got svelte@5.0.0-next.47. The app broke.

Quick update: I saw @Rich-Harris pushed an update to svelte@5.0.0-next.48 and I'm not sure if that fixes it. But I'm not ready to test that now.

Logs

Error logs ```shell { name: 'CompileError', id: '/Users/jgb/Code/JGB/Web/mp3pam-svelte/src/lib/components/Player.svelte', message: "/Users/jgb/Code/JGB/Web/mp3pam-svelte/src/lib/components/Player.svelte:1:27 'trpcClient' has already been declared", frame: '1 | \n' + '\n' + '\n' + "\t
\n" + '\t\t\n' + '\t\t\t {\n' + ' const id = pState?.currentSound?.id as string\n' + '\n' + ' goto(AppRoutes.track.detailPage(id))\n' + ' }}\n' + '\t\t\t>\n' + '\t\t\t\t{#if pState.currentSound}\n' + '\t\t\t\t\t

System Info

MacOS Sonoma Version 14.2.1 (23C71)
Bun 1.0.26

Severity

blocking all usage of svelte

Zachiah commented 7 months ago

Can you please wrap your logs in a collapsible section because it's so long right now that it makes the thread hard to use

Conduitry commented 7 months ago

"Update the the latest version with bun update." is not a reproduction. Please provide a minimal reproduction, as requested in the issue template.

jgb-solutions commented 7 months ago

Can you please wrap your logs in a collapsible section because it's so long right now that it makes the thread hard to use

I fixed it thanks

jgb-solutions commented 7 months ago

"Update the the latest version with bun update." is not a reproduction. Please provide a minimal reproduction, as requested in the issue template.

I added more details but I'm not ready to provide reproduction repo right now. Thanks though!

dummdidumm commented 7 months ago

Can you try with the latest version? There was a bug in 47 that affected compilation in a broad manner.

otodockal commented 7 months ago

@dummdidumm In my case the problem is fixed in 48. But I still see TS errors in the snippet block for some reason...

Screenshot 2024-02-06 at 14 39 19
Zachiah commented 7 months ago

Did you restart vscode?

otodockal commented 7 months ago

@Zachiah yep, very likely the same issue https://github.com/sveltejs/language-tools/issues/2281

jgb-solutions commented 7 months ago

@dummdidumm I can confirm that updating to svelte@5.0.0-next.48 indeed fixed the issue. I'm closing it. Thanks all!