sveltejs / svelte

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

Svelte 5 not working in monorepo #10885

Open peterreeves opened 3 months ago

peterreeves commented 3 months ago

Describe the bug

Svelte 5 appears not to work in monorepo setups. I've tried both a setup with turborepo, and a smaller setup just using NPM workspaces. I've included the turborepo setup below as it's simpler to setup.

Reproduction

( Following the turborepo example https://github.com/vercel/turbo/tree/main/examples/with-svelte )

npx create-turbo@latest -e with-svelte

After setup, observe that npm run dev works correctly when visiting the page..

Update either of the "web" or "docs" project with "svelte": "^5.0.0-next.1" and run npm i. Run npm run dev again, and see that the page no longer loads, with this error displayed (filepaths edited):

TypeError: __vite_ssr_import_0__.create_ssr_component is not a function
    at eval (.../apps/docs/.svelte-kit/generated/root.svelte:12:36)
    at async instantiateModule (.../node_modules/vite/dist/node/chunks/dep-DJaaTb_D.js:55001:9)

Logs

No response

System Info

System:
    OS: Windows 11 10.0.22631
    CPU: (24) x64 AMD Ryzen 9 5900X 12-Core Processor
    Memory: 18.52 GB / 31.91 GB
  Binaries:
    Node: 20.10.0 - C:\Program Files\nodejs\node.EXE
    npm: 10.2.5 - C:\Program Files\nodejs\npm.CMD
    pnpm: 8.1.1 - ~\AppData\Local\pnpm\pnpm.EXE
  Browsers:
    Edge: Chromium (122.0.2365.92)
    Internet Explorer: 11.0.22621.1

Severity

blocking an upgrade

peterreeves commented 3 months ago

Small update, I just tried this again with pnpm and it works correctly. I guess this might be the kick I need to start switching my projects from npm to pnpm...

ideodora commented 3 months ago

I bumped into this too... using npm workspace with both svelte4 and 5 packages in it.