Skip to content

web.template being used in SSR library mode #116

Closed

Description

@wakaztahir

When you use vite-plugin-solid in a library vite config

even when ssr = true, It still uses solid/web template function for the jsx like this which is only available in the client package

Screenshot 2023-10-01 141530

As you can see, this is the output of the cjs bundle, built using this vite config
This is ofcourse a jsx transformation error, jsx should be transformed to appropriate code for cjs and esm bundles, so they can work in ssr and browser modes perfectly

export const CommonLibOptions: LibraryOptions = {
    entry: path.resolve(__dirname, "src/index.ts"),
    fileName: format => `index.${format}.js`
}
export const CommonBuildOptions: BuildOptions = {
    rollupOptions: {
        external: [
            "solid-js",
            "solid-js/web"
        ],
    },
}
export default defineConfig({
    build: {
        ...CommonBuildOptions,
        outDir : "dist/cjs",
        lib: {
            ...CommonLibOptions,
            formats: ["cjs"],
        }
    },
    plugins: [
        solidPlugin({
            ssr: true
        })
    ],
})

@ryansolid This issue prevents you from building a library that contains JSX when using vite-plugin-solid, The only fix is to use solid-tsup-preset

Activity

  1. brenelz commented on Sep 11, 2026

    @brenelz
    Contributor

    The configuration above needs build.ssr: true in addition to solidPlugin({ ssr: true }).

    If you add that and still have issues please open another issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions