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

RSC: shared components using next built-in components doesn't work #35449

Closed
1 task done
huozhi opened this issue Mar 19, 2022 · 1 comment · Fixed by #35975
Closed
1 task done

RSC: shared components using next built-in components doesn't work #35449

huozhi opened this issue Mar 19, 2022 · 1 comment · Fixed by #35975

Comments

@huozhi
Copy link
Member

huozhi commented Mar 19, 2022

Verify canary release

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

Provide environment information

    Operating System:
      Platform: darwin
      Arch: arm64
      Version: Darwin Kernel Version 21.1.0: Wed Oct 13 17:33:24 PDT 2021; root:xnu-8019.41.5~1/RELEASE_ARM64_T8101
    Binaries:
      Node: 14.17.0
      npm: 8.5.5
      Yarn: 1.22.15
      pnpm: 6.11.0
    Relevant packages:
      next: 12.1.1-canary.14
      react: 18.0.0-rc.2
      react-dom: 18.0.0-rc.2

What browser are you using? (if relevant)

Chrome 99

How are you deploying your application? (if relevant)

No response

Describe the Bug

Sample App

// next.config.js
module.exports = {
  experimental: {
    runtime: 'edge',
    serverComponents: true
  }
}

// pages/index.server.js
import Shared from '../shared.js'

export default () => <Shared />

// shared.js
import Link from 'next/link'
export default () => <Link href='/'><a>home</a></Link>

Seeing error

TypeError: Cannot read property 'default' of undefined

Other clues

Flight manifest doesn't contain the reference of next/link as expected.

Expected Behavior

Should render the link and be able to interact with, since next/link should be treated as client components

To Reproduce

  • Use the sample app code snippets and run next dev
  • Visit localhost:3000
@huozhi huozhi added bug Issue was opened via the bug report template. kind: bug and removed bug Issue was opened via the bug report template. labels Mar 19, 2022
@kodiakhq kodiakhq bot closed this as completed in #35975 Apr 7, 2022
kodiakhq bot pushed a commit that referenced this issue Apr 7, 2022
Fixes #35449

Include the shared components (from source code) is in client bundles, previously we lost them so that the client components imported by them are lost in module graph

* let flight server loader apply to all pages and imported modules (except node_modules at the moment)
* if it's a shared component from source code, include it in client bundle
* ignore handling node_modules at the moment (due to the limitation support of esm imports with RSC)

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [x] Errors have helpful link attached, see `contributing.md`
colinhacks pushed a commit to colinhacks/next.js that referenced this issue Apr 14, 2022
…#35975)

Fixes vercel#35449

Include the shared components (from source code) is in client bundles, previously we lost them so that the client components imported by them are lost in module graph

* let flight server loader apply to all pages and imported modules (except node_modules at the moment)
* if it's a shared component from source code, include it in client bundle
* ignore handling node_modules at the moment (due to the limitation support of esm imports with RSC)

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [x] Errors have helpful link attached, see `contributing.md`
@github-actions
Copy link
Contributor

github-actions bot commented May 8, 2022

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

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant