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

Exporting client components as an object throws an error. #44389

Open
1 task done
benton-droplab opened this issue Dec 28, 2022 · 2 comments
Open
1 task done

Exporting client components as an object throws an error. #44389

benton-droplab opened this issue Dec 28, 2022 · 2 comments
Labels
bug Issue was opened via the bug report template.

Comments

@benton-droplab
Copy link

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 22.2.0: Fri Nov 11 02:06:26 PST 2022; root:xnu-8792.61.2~4/RELEASE_ARM64_T8112
Binaries:
  Node: 18.12.1
  npm: 9.2.0
  Yarn: 1.22.19
  pnpm: N/A
Relevant packages:
  next: 13.1.1
  eslint-config-next: 13.1.1
  react: 18.2.0
  react-dom: 18.2.0

Which area(s) of Next.js are affected? (leave empty if unsure)

App directory (appDir: true)

Link to the code that reproduces this issue

https://github.com/benton-droplab/export-reproduction

To Reproduce

  1. Create a client component exported as part of an object with the "use client" directive.
  2. Import into a server component.\

Describe the Bug

Next throws the following error:

`Unhandled Runtime Error

Error: Unsupported Server Component type: undefined
Call Stack
attemptResolveElement
node_modules/next/dist/compiled/react-server-dom-webpack/server.browser.js (1387:8)
attemptResolveElement
node_modules/next/dist/compiled/react-server-dom-webpack/server.browser.js (1850:20)
resolveModelToJSON
node_modules/next/dist/compiled/react-server-dom-webpack/server.browser.js (1210:13)
stringify

stringify
node_modules/next/dist/compiled/react-server-dom-webpack/server.browser.js (205:13)
processModelChunk
node_modules/next/dist/compiled/react-server-dom-webpack/server.browser.js (2111:25)
retryTask
node_modules/next/dist/compiled/react-server-dom-webpack/server.browser.js (2158:6)
performWork
node_modules/next/dist/compiled/react-server-dom-webpack/server.browser.js (1396:13)
callback
node_modules/next/dist/compiled/react-server-dom-webpack/server.browser.js (67:2)
scheduleWork
node_modules/next/dist/compiled/react-server-dom-webpack/server.browser.js (1395:4)
pingTask
node_modules/next/dist/compiled/react-server-dom-webpack/server.browser.js (1409:13)
process.processTicksAndRejections
node:internal/process/task_queues (95:5)`

Expected Behavior

The component should import without throwing an error.

Which browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

@benton-droplab benton-droplab added the bug Issue was opened via the bug report template. label Dec 28, 2022
@AlejandroV01
Copy link

Same Error: Unsupported Server Component type: undefined When trying to import a third-party component, using the new app dir.

@AM-thedev
Copy link

See this thread: #41940
You could try creating a folder with an index.ts that exports all the third-party components you want to use and put "use client" at the top of the index.ts

A bit hacky but it might work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue was opened via the bug report template.
Projects
None yet
Development

No branches or pull requests

3 participants