ConsoleTVs / sswr

🔥 Svelte stale while revalidate (SWR) data fetching strategy
MIT License
234 stars 11 forks source link

Posible vite4 incompatibility #40

Closed vladblindu closed 1 year ago

vladblindu commented 1 year ago

Hello and thank you for your time,

I got this weird error on a fresh sveltekit installation, just by pasting the example code in a +page.svelte

Internal server error: Cannot read properties of undefined (reading 'SWR')
      at eval (/node_modules/sswr/dist/sswr.es.js:130:35)
      at async instantiateModule (file:///Users/vlad/Documents/zecode/@lib/JS/vicon/frontend/node_modules/vite/dist/node/chunks/dep-ca21228b.js:52420:9) (x2)
TypeError: Cannot read properties of undefined (reading 'SWR')
    at eval (/node_modules/sswr/dist/sswr.es.js:130:35)
    at async instantiateModule (file:///Users/vlad/Documents/zecode/@lib/JS/vicon/frontend/node_modules/vite/dist/node/chunks/dep-ca21228b.js:52420:9)

My package.json is:

{
    "name": "vbox",
    "version": "0.0.1",
    "scripts": {
        "dev": "vite dev",
        "build": "vite build",
        "preview": "vite preview",
        "test": "playwright test",
        "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
        "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
        "test:unit": "vitest"
    },
    "devDependencies": {
        "@fontsource/fira-mono": "^4.5.10",
        "@neoconfetti/svelte": "^1.0.0",
        "@originjs/vite-plugin-commonjs": "^1.0.3",
        "@playwright/test": "^1.28.1",
        "@sveltejs/adapter-auto": "^1.0.0-next.90",
        "@sveltejs/kit": "^1.0.0-next.587",
        "@types/cookie": "^0.5.1",
        "autoprefixer": "^10.4.13",
        "postcss": "^8.4.21",
        "svelte": "^3.54.0",
        "svelte-check": "^2.9.2",
        "tailwindcss": "^3.2.7",
        "tslib": "^2.4.1",
        "typescript": "^4.9.3",
        "vite": "^4.0.0",
        "vitest": "^0.25.3"
    },
    "type": "module",
    "dependencies": {
        "@auth/core": "^0.5.0",
        "@auth/sveltekit": "^0.2.2",
        "@popperjs/core": "^2.11.6",
        "@tailwindcss/forms": "^0.5.3",
        "@tailwindcss/typography": "^0.5.9",
        "chart.js": "^4.2.1",
        "daisyui": "^2.51.2",
        "sswr": "^1.7.0"
    },
    "license": "MIT"
}

I'm on a M1 mac. I ended up whit this setup without specifically wanting to use vite 4. If there is a bare-bones sswr project somewhere I can clone, it would be great, as I am in an early stage of development and there is no significant effort loss. Thanks again

ConsoleTVs commented 1 year ago

I have fixed that.

cgxxv commented 1 year ago

I got the same problem, seems not fixed.