sveltejs / kit

web development, streamlined
https://svelte.dev/docs/kit
MIT License
18.71k stars 1.94k forks source link

TypeError: builder.findServerAssets is not a function or its return value is not iterable at generate_serverless_function #12564

Closed PaperPrototype closed 3 months ago

PaperPrototype commented 3 months ago

Describe the bug

Managed to deploy just fine, then I added a few packages and now this error gets printed to the console

error during build:
TypeError: builder.findServerAssets is not a function or its return value is not iterable
    at generate_serverless_function (file:///Users/abdiellopez/sparker/sparker-website/node_modules/.pnpm/@sveltejs+adapter-vercel@5.4.1_@sveltejs+kit@1.30.4/node_modules/@sveltejs/adapter-vercel/index.js:94:33)
    at async adapt (file:///Users/abdiellopez/sparker/sparker-website/node_modules/.pnpm/@sveltejs+adapter-vercel@5.4.1_@sveltejs+kit@1.30.4/node_modules/@sveltejs/adapter-vercel/index.js:309:5)
    at async adapt (file:///Users/abdiellopez/sparker/sparker-website/node_modules/.pnpm/@sveltejs+kit@1.30.4_svelte@4.2.18_vite@4.5.3/node_modules/@sveltejs/kit/src/core/adapt/index.js:37:2)
    at async finalise (file:///Users/abdiellopez/sparker/sparker-website/node_modules/.pnpm/@sveltejs+kit@1.30.4_svelte@4.2.18_vite@4.5.3/node_modules/@sveltejs/kit/src/exports/vite/index.js:810:7)
    at async Object.handler (file:///Users/abdiellopez/sparker/sparker-website/node_modules/.pnpm/@sveltejs+kit@1.30.4_svelte@4.2.18_vite@4.5.3/node_modules/@sveltejs/kit/src/exports/vite/index.js:840:5)
    at async PluginDriver.hookParallel (file:///Users/abdiellopez/sparker/sparker-website/node_modules/.pnpm/rollup@3.29.4/node_modules/rollup/dist/es/shared/node-entry.js:25466:17)
    at async Object.close (file:///Users/abdiellopez/sparker/sparker-website/node_modules/.pnpm/rollup@3.29.4/node_modules/rollup/dist/es/shared/node-entry.js:26726:13)
    at async build (file:///Users/abdiellopez/sparker/sparker-website/node_modules/.pnpm/vite@4.5.3_sass@1.77.8/node_modules/vite/dist/node/chunks/dep-41cf5ffd.js:48095:13)
    at async CAC.<anonymous> (file:///Users/abdiellopez/sparker/sparker-website/node_modules/.pnpm/vite@4.5.3_sass@1.77.8/node_modules/vite/dist/node/cli.js:842:9)
 ELIFECYCLE  Command failed with exit code 1.

Reproduction

Honestly don't think I will be able to reproduce this. Although the issue/error is identical on my machine and vercel deployments.

Here is my package.json and pnpm-lock.yaml if that helps. I've deleted the pnpm-lock and updated all the packages as well but still no change.

package.json

{
  "name": "sparker-website",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "dev": "vite dev --host 127.0.0.1 --port 3000",
    "build": "vite build",
    "preview": "vite preview",
    "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
    "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
    "lint": "prettier --check . && eslint .",
    "format": "prettier --write .",
    "storybook": "storybook dev -p 6006",
    "build-storybook": "storybook build"
  },
  "devDependencies": {
    "@sveltejs/adapter-cloudflare": "^2.3.4",
    "@sveltejs/kit": "^1.30.4",
    "@typescript-eslint/eslint-plugin": "^6.21.0",
    "@typescript-eslint/parser": "^6.21.0",
    "@vite-pwa/sveltekit": "^0.3.0",
    "autoprefixer": "^10.4.20",
    "eslint": "^8.57.0",
    "eslint-config-prettier": "^9.1.0",
    "eslint-plugin-storybook": "^0.8.0",
    "eslint-plugin-svelte": "^2.43.0",
    "postcss": "^8.4.41",
    "sass": "^1.77.8",
    "svelte": "^4.2.18",
    "svelte-check": "^3.8.5",
    "tailwindcss": "^3.4.9",
    "tslib": "^2.6.3",
    "typescript": "^5.5.4",
    "vite": "^4.5.3"
  },
  "type": "module",
  "dependencies": {
    "@codemirror/commands": "^6.6.0",
    "@codemirror/lang-html": "^6.4.9",
    "@codemirror/lang-javascript": "^6.2.2",
    "@codemirror/language": "^6.10.2",
    "@codemirror/lint": "^6.8.1",
    "@codemirror/state": "^6.4.1",
    "@codemirror/view": "^6.30.0",
    "@eslint/eslintrc": "^3.1.0",
    "@lezer/highlight": "^1.2.0",
    "@msgpack/msgpack": "3.0.0-beta2",
    "@replit/codemirror-lang-csharp": "^6.2.0",
    "@supabase/ssr": "^0.0.10",
    "@supabase/supabase-js": "^2.45.1",
    "@sveltejs/adapter-vercel": "^5.4.1",
    "@uiw/codemirror-themes": "^4.23.0",
    "bits-ui": "^0.21.13",
    "clsx": "^2.1.1",
    "codemirror": "^6.0.1",
    "confetti-js": "^0.0.18",
    "eslint-browser": "^3.8.1",
    "eslint-linter-browserify": "^9.8.0",
    "file-saver": "^2.0.5",
    "github-markdown-css": "^5.6.1",
    "highlight.js": "^11.10.0",
    "jssha": "^3.3.1",
    "lucide-svelte": "^0.373.0",
    "marked": "^12.0.2",
    "marked-highlight": "^2.1.4",
    "mode-watcher": "^0.3.1",
    "nanoid": "^5.0.7",
    "openai": "^4.55.3",
    "paneforge": "^0.0.5",
    "radix-icons-svelte": "^1.2.1",
    "save-as": "^0.1.8",
    "stripe": "^15.12.0",
    "svelte-radix": "^1.1.0",
    "tailwind-merge": "^2.4.0",
    "tailwind-variants": "^0.2.1",
    "tus-js-client": "^4.1.0",
    "uuid": "^9.0.1",
    "vite-plugin-pwa": "^0.17.5"
  }
}
package.json
```json
{
  "name": "sparker-website",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "dev": "vite dev --host 127.0.0.1 --port 3000",
    "build": "vite build",
    "preview": "vite preview",
    "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
    "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
    "lint": "prettier --check . && eslint .",
    "format": "prettier --write .",
    "storybook": "storybook dev -p 6006",
    "build-storybook": "storybook build"
  },
  "devDependencies": {
    "@sveltejs/adapter-cloudflare": "^2.3.4",
    "@sveltejs/kit": "^1.30.4",
    "@typescript-eslint/eslint-plugin": "^6.21.0",
    "@typescript-eslint/parser": "^6.21.0",
    "@vite-pwa/sveltekit": "^0.3.0",
    "autoprefixer": "^10.4.20",
    "eslint": "^8.57.0",
    "eslint-config-prettier": "^9.1.0",
    "eslint-plugin-storybook": "^0.8.0",
    "eslint-plugin-svelte": "^2.43.0",
    "postcss": "^8.4.41",
    "sass": "^1.77.8",
    "svelte": "^4.2.18",
    "svelte-check": "^3.8.5",
    "tailwindcss": "^3.4.9",
    "tslib": "^2.6.3",
    "typescript": "^5.5.4",
    "vite": "^4.5.3"
  },
  "type": "module",
  "dependencies": {
    "@codemirror/commands": "^6.6.0",
    "@codemirror/lang-html": "^6.4.9",
    "@codemirror/lang-javascript": "^6.2.2",
    "@codemirror/language": "^6.10.2",
    "@codemirror/lint": "^6.8.1",
    "@codemirror/state": "^6.4.1",
    "@codemirror/view": "^6.30.0",
    "@eslint/eslintrc": "^3.1.0",
    "@lezer/highlight": "^1.2.0",
    "@msgpack/msgpack": "3.0.0-beta2",
    "@replit/codemirror-lang-csharp": "^6.2.0",
    "@supabase/ssr": "^0.0.10",
    "@supabase/supabase-js": "^2.45.1",
    "@sveltejs/adapter-vercel": "^5.4.1",
    "@uiw/codemirror-themes": "^4.23.0",
    "bits-ui": "^0.21.13",
    "clsx": "^2.1.1",
    "codemirror": "^6.0.1",
    "confetti-js": "^0.0.18",
    "eslint-browser": "^3.8.1",
    "eslint-linter-browserify": "^9.8.0",
    "file-saver": "^2.0.5",
    "github-markdown-css": "^5.6.1",
    "highlight.js": "^11.10.0",
    "jssha": "^3.3.1",
    "lucide-svelte": "^0.373.0",
    "marked": "^12.0.2",
    "marked-highlight": "^2.1.4",
    "mode-watcher": "^0.3.1",
    "nanoid": "^5.0.7",
    "openai": "^4.55.3",
    "paneforge": "^0.0.5",
    "radix-icons-svelte": "^1.2.1",
    "save-as": "^0.1.8",
    "stripe": "^15.12.0",
    "svelte-radix": "^1.1.0",
    "tailwind-merge": "^2.4.0",
    "tailwind-variants": "^0.2.1",
    "tus-js-client": "^4.1.0",
    "uuid": "^9.0.1",
    "vite-plugin-pwa": "^0.17.5"
  }
}

### Logs

```Shell
It runs fine with `pnpm run dev` but `pnpm run build` fails locally and through vercel

System Info

Mac OS 14.4.1
Apple M2 Pro

=============
Node v20.12.1 (npm v10.5.0)

Severity

annoyance

Additional Information

I assume this is a bug, but I may be wrong :)

PaperPrototype commented 3 months ago

Okay, so pnpm run build works as long as I am using @sveltejs/adapter-auto. I'll stick with this for now until the problem is solved.

PaperPrototype commented 3 months ago

aaand, since vercel automatically changes the adapter it has failed...

PaperPrototype commented 3 months ago

Looks like it works after updating the "@sveltejs/kit" version to "^2.5.20" (I was on "1.x.x") Also changed the vitePreprocess to use "@sveltejs/vite-plugin-svelte" package instead of "@sveltejs/kit/vite" as per https://kit.svelte.dev/docs/integrations#preprocessors

vexy commented 2 months ago

Was switching to @sveltejs/vite-plugin-svelte the main cause ? I've did the same but with no luck.