vercel / next.js

The React Framework
https://nextjs.org
MIT License
125.09k stars 26.72k forks source link

Turbopack: Unable to load SVG. Uncaught Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object. #66866

Closed paulm17 closed 3 months ago

paulm17 commented 3 months ago

Link to the code that reproduces this issue

https://github.com/paulm17/turbopacksvgerror

To Reproduce

Clone repo: https://github.com/paulm17/turbopacksvgerror pnpm i pnpm run dev

Works without --turbo.

Current vs. Expected behavior

SVG should show up when --turbo is being used.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 21.6.0: Mon Aug 22 20:19:52 PDT 2022; root:xnu-8020.140.49~2/RELEASE_ARM64_T6000
  Available memory (MB): 32768
  Available CPU cores: 10
Binaries:
  Node: 20.13.1
  npm: 10.5.2
  Yarn: 3.6.0
  pnpm: 9.3.0
Relevant Packages:
  next: 14.2.4 // Latest available version is detected (14.2.4).
  eslint-config-next: 14.2.4
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.4.5
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Turbopack

Which stage(s) are affected? (Select all that apply)

next dev (local)

Additional context

server component error

Error: Unsupported Server Component type: {...}

"use client" error

Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.

timneutkens commented 3 months ago

https://github.com/paulm17/turbopacksvgerror/blob/main/next.config.mjs#L3-L11

You customized webpack configuration, which obviously does not work with Turbopack 😄

You can use the configuration shown in the documentation: https://nextjs.org/docs/app/api-reference/next-config-js/turbo#webpack-loaders

github-actions[bot] commented 2 months ago

This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.