Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type Error on new Vite projects with svelte-ts project #1055

Closed
trbernstein opened this issue Dec 18, 2024 · 3 comments
Closed

Type Error on new Vite projects with svelte-ts project #1055

trbernstein opened this issue Dec 18, 2024 · 3 comments
Labels
bug Something isn't working triage Awaiting triage by a project member

Comments

@trbernstein
Copy link
Contributor

Describe the bug

Starting a new Vite project and selecting svelte-ts template (by first selecting svelte and then TypeScript) results in an error, because code var in error.js is null.

Reproduction URL

https://github.com/vitejs/vite/tree/main/packages/create-vite/template-svelte-ts

Reproduction

  1. Start a new Vite project using npm create vite@latest
  2. Install dependencies in project folder with npm install
  3. Start dev server with npm run dev
  4. Observe error.

Logs

[vite] Internal server error: Cannot read properties of undefined (reading 'startsWith')
Plugin: vite-plugin-svelte
File: /***/src/App.svelte
    at couldBeFixedByCssPreprocessor (file://***/node_modules/.pnpm/@[email protected][email protected][email protected]/node_modules/@sveltejs/vite-plugin-svelte/src/utils/error.js:111:72)
    at enhanceCompileError (file://***/node_modules/.pnpm/@[email protected][email protected][email protected]/node_modules/@sveltejs/vite-plugin-svelte/src/utils/error.js:126:6)
    at compileSvelte (file:/***/node_modules/.pnpm/@[email protected][email protected][email protected]/node_modules/@sveltejs/vite-plugin-svelte/src/utils/compile.js:148:4)
    at async TransformPluginContext.transform (file:/***/node_modules/.pnpm/@[email protected][email protected][email protected]/node_modules/@sveltejs/vite-plugin-svelte/src/index.js:164:20)
    at async EnvironmentPluginContainer.transform (file:/***/node_modules/.pnpm/[email protected]/node_modules/vite/dist/node/chunks/dep-yUJfKD1i.js:47001:18)
    at async loadAndTransform (file:/***/node_modules/.pnpm/[email protected]/node_modules/vite/dist/node/chunks/dep-yUJfKD1i.js:40852:27)
    at async viteTransformMiddleware (file:/***/node_modules/.pnpm/[email protected]/node_modules/vite/dist/node/chunks/dep-yUJfKD1i.js:42296:24)

System Info

System:
    OS: macOS 15.2
    CPU: (24) arm64 Apple M2 Ultra
    Memory: 40.07 GB / 192.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 23.4.0 - /opt/homebrew/bin/node
    npm: 10.9.2 - /opt/homebrew/bin/npm
    pnpm: 9.15.0 - /opt/homebrew/bin/pnpm
  Browsers:
    Safari: 18.2
  npmPackages:
    @sveltejs/vite-plugin-svelte: ^5.0.2 => 5.0.2 
    svelte: ^5.14.2 => 5.14.2 
    vite: ^6.0.1 => 6.0.3
@trbernstein trbernstein added bug Something isn't working triage Awaiting triage by a project member labels Dec 18, 2024
@360matt
Copy link

360matt commented Dec 18, 2024

Fixed on Svelte v5.14.3
See #1053

@dominikg
Copy link
Member

leaving this open for now bc there is an adjacent bug in vite-plugin-svelte error handling regarding errors without a code property

@dominikg
Copy link
Member

fixed in 4.0.4 and 5.0.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage Awaiting triage by a project member
Projects
None yet
Development

No branches or pull requests

3 participants