solidjs / solidjs/solid-vite-plugin
Make ssr settings less strict
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 520
- Forks
- 70
- Avg merge
- 23h 35m
- Merged PRs (30d)
- 39
Description
I need to prerender certain pages in ssg mode, so some chunks should be trasnformed with ssr: true option.
However, this condition: https://github.com/solidjs/vite-plugin-solid/blob/master/src/index.ts#L377 requires in my plugin change option explicitly:
function setSSRMode(enable: boolean) {
if (enable) {
options.solidPluginOptionsRef.ssr = true
options.solidPluginOptionsRef.solid!.hydratable = false
} else {
options.solidPluginOptionsRef.ssr = _ssr
options.solidPluginOptionsRef.solid.hydratable = _hydratable
}
}
async function getEntryFragment(entry: NormalizedEntry) {
setSSRMode(true)
const ssrMod = await server.ssrLoadModule(entry.ssrEntry, { fixStacktrace: true })
setSSRMode(false)
if (ssrMod.render?.constructor !== Function) {
throw new Error(`SSG entry ${entry.ssrEntry} should provide 'render' export`)
}
const fragment = await ssrMod.render()
return fragment
}
I suggest something like:
const generate = options.ssr || isSsr ? 'ssr' : 'dom'
const hydratable = isSsr || options.ssr
solidOptions = {
generate,
hydratable
};
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 with src/index.ts around line 377, where the SSR option is currently required, and compare that condition with the proposed generate and hydratable settings. Trace how the Vite plugin options are applied during SSG and verify that selected chunks can use ssr: true without requiring external option mutation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript, vite
- Domain
- build-system, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100