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

pass hydratable to solid plugin #12

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions src/preset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ export interface EntryOptions {
dev_entry?: boolean | string
/** Setting `true` will generate a server-only entry (default: `false`) */
server_entry?: boolean | string
/**
* Setting `true` will set `hydratable` option of babel plugin (default: `false`)
* @see https://www.solidjs.com/guides/server
*/
hydratable?: boolean | undefined
}

export type ModifyEsbuildOptions = (
Expand Down Expand Up @@ -67,6 +72,7 @@ export interface EntryType {
dev: boolean
server: boolean
jsx: boolean
hydratable: boolean
}

export interface BuildItem {
Expand Down Expand Up @@ -127,6 +133,7 @@ export function parsePresetOptions(
dev: !!options.dev_entry,
server: !!options.server_entry,
jsx: options.entry.endsWith('.jsx') || options.entry.endsWith('.tsx'),
hydratable: !!options.hydratable,
},
}
})
Expand Down Expand Up @@ -179,7 +186,11 @@ export function generateTsupOptions(
if (item) {
item.entries.add(entry)
} else {
items.push({ type: { dev, server, jsx }, entries: new Set([entry]) })
const hydratable = entry.options.hydratable ?? false
items.push({
type: { dev, server, jsx, hydratable },
entries: new Set([entry]),
})
}
}
}
Expand Down Expand Up @@ -247,7 +258,12 @@ export function generateTsupOptions(
},
esbuildPlugins: !type.jsx
? [
solidPlugin({ solid: { generate: type.server ? 'ssr' : 'dom' } }),
solidPlugin({
solid: {
hydratable: type.hydratable,
generate: type.server ? 'ssr' : 'dom',
},
}),
...options.esbuild_plugins,
]
: options.esbuild_plugins,
Expand Down