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

thoughts on server component package with internal client boundary #379

Open
9 tasks
hi-ogawa opened this issue Jun 10, 2024 · 1 comment
Open
9 tasks

Comments

@hi-ogawa
Copy link
Owner

hi-ogawa commented Jun 10, 2024

Also the series of the issues related to client boundary resolution

todo

@hi-ogawa hi-ogawa changed the title support external server component with client component inside? thoughts on external server component with internal client boundary Jun 11, 2024
@hi-ogawa
Copy link
Owner Author

Examples

probably impossible to support

  • package.json
    • externally only server.js is accesible as a package
    • "type": "module" or "commonjs" doesn't matter
{
  "name": "xxx",
  "type": "module",
  "exports": "./server.js"
}
  • server.js
import { SomeClientComponent } from "./client.js"

export function SomeServerComponent() {
  return <div>
    <div>Server</div>
    <SomeClientComponent />
  </div>
}
  • client.js
"use client"

export function SomeClientComponent() {
  return <div>client</div>
}

For browser, Vite needs to optimize client.js but is it possible for Vite to reference client.js which is not a public export entry?

Vite-friendly way to write the same package

  • package.json
{
  "name": "xxx",
  "type": "module",
  "exports": {
     ".": "./server.js",
     "./client": "./client.js" // 👈 expose client
  }
}
  • server.js
import { SomeClientComponent } from "xxx/client" // 👈 reference via package export even internally 

export function SomeServerComponent() {
  return <div>
    <div>Server</div>
    <SomeClientComponent />
  </div>
}
  • client.js
"use client"

export function SomeClientComponent() {
  return <div>client</div>
}

@hi-ogawa hi-ogawa changed the title thoughts on external server component with internal client boundary thoughts on server component package with internal client boundary Dec 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant