[Feature?]: clientOnly dx for named exports
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 5.9k
- Forks
- 426
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 11
Description
Duplicates
- I have searched the existing issues
Latest version
- I have tested the latest version
Summary 💡
clientOnly only supports components that are default export so it seems like use these 2 things together is currently not great developer experience. I got it to work like this.
const Component = clientOnly(() =>
import("./component").then((r) => ({ default: r.Component })),
);
I see that clientOnly has an options payload, and I think it would be a good idea to add an "export" variable to that options object. so it could mesh well with the existing implementation, instead of hardcoding module.default it can use module[options.export] and we can make the default value of options.export = 'default'
Examples 🌈
Here is what existing vs proposed use could be
// current
const Component = clientOnly(() =>
import("./component").then((r) => ({ default: r.Component })),
);
// proposed
const Component = clientOnly(() => import('./component'), { export: 'Component'});
Motivation 🔦
I saw this open issue that mentions allowing components to be beside the route files that use them when using by not exposing a default export https://github.com/solidjs/solid-start/issues/1882 and I think that is a fantastic solution for that and feels like the right choice.
but it doesn't work very cleanly with clientOnly
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the clientOnly entry point and reading how its options payload selects the loaded module's default export. Compare that behavior with the named-export example in the issue, then verify that the proposed option preserves current default-export usage and supports the Component export case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- developer-experience, frontend
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100