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

web.template being used in SSR library mode #116

Open
wakaztahir opened this issue Oct 1, 2023 · 0 comments
Open

web.template being used in SSR library mode #116

wakaztahir opened this issue Oct 1, 2023 · 0 comments

Comments

@wakaztahir
Copy link

wakaztahir commented Oct 1, 2023

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

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