solidjs / solid

A declarative, efficient, and flexible JavaScript library for building user interfaces.
https://solidjs.com
MIT License
32.34k stars 925 forks source link

Solid-start incompatible with ag-grid-solid: The requested module 'solid-js/web' does not provide an export named 'className' #1839

Closed xarthurx closed 1 year ago

xarthurx commented 1 year ago

Describe the bug

Trying to use AgGrid inside solidjs by:

import  AgGridSolid  from "ag-grid-solid";

When refreshing my customModule.jsx, the main webpage shows the error.

Your Example Website or App

https://github.com/xarthurx/soildStartTest

Steps to Reproduce the Bug or Issue

Expected behavior

Everything should be imported correctly.

Screenshots or Videos

No response

Platform

Additional context

When using

npx degit solidjs/templates/ts my-app

to initialize the project and do the same test, there seems no issue. So I guess this might be an issue related to solid-start, not solid.

ryansolid commented 1 year ago

Yeah this is just because the AGGrid package hasn't been set up for SSR. Like if you turn ssr: false in your SolidStart options it would work.

I don't know if AG-Grid has browser-specific dependencies that would require it to be loading only there but I suspect it might. But in anycase in the current state it is packaged in a way that will work in SSR.

To do so it would have to have a "solid" export that would point at the source code so we could compile it for ssr mode as both the client and server builds would be different than what is packaged there. And example package that shows how to bundle this is https://github.com/solidjs-community/rollup-preset-solid.

If your desire is for it to render on the server your best bet is to request them to support SSR (not sure if they do). If the desire is to have it not render during server side in a SSR setup there are some patterns for doing that in SolidStart and some features we are working on to lazy load it only into the client.

xarthurx commented 1 year ago

Yeah this is just because the AGGrid package hasn't been set up for SSR. Like if you turn ssr: false in your SolidStart options it would work.

I don't know if AG-Grid has browser-specific dependencies that would require it to be loading only there but I suspect it might. But in anycase in the current state it is packaged in a way that will work in SSR.

To do so it would have to have a "solid" export that would point at the source code so we could compile it for ssr mode as both the client and server builds would be different than what is packaged there. And example package that shows how to bundle this is https://github.com/solidjs-community/rollup-preset-solid.

If your desire is for it to render on the server your best bet is to request them to support SSR (not sure if they do). If the desire is to have it not render during server side in a SSR setup there are some patterns for doing that in SolidStart and some features we are working on to lazy load it only into the client.

Thank you for the reply. I'm actually a bit new to solid and totally new to SolidStart. Silly question... where can I turn the option "ssr:false" off? I browsed the doc, but don't see a setting file...

xarthurx commented 1 year ago

Ah, never mind. I created a new repo with the guild, and found out: image

xarthurx commented 1 year ago

Yeah this is just because the AGGrid package hasn't been set up for SSR. Like if you turn ssr: false in your SolidStart options it would work.

I don't know if AG-Grid has browser-specific dependencies that would require it to be loading only there but I suspect it might. But in anycase in the current state it is packaged in a way that will work in SSR.

To do so it would have to have a "solid" export that would point at the source code so we could compile it for ssr mode as both the client and server builds would be different than what is packaged there. And example package that shows how to bundle this is https://github.com/solidjs-community/rollup-preset-solid.

If your desire is for it to render on the server your best bet is to request them to support SSR (not sure if they do). If the desire is to have it not render during server side in a SSR setup there are some patterns for doing that in SolidStart and some features we are working on to lazy load it only into the client.

FYI, ag-grid developer said they will not support ssr: https://github.com/ag-grid/ag-grid/issues/6929

xarthurx commented 1 year ago

There's another questions related to this issue:

 version  0.2.26
 adapter  static
file:///C:/Users/xar/source/docRepo/ddmRemake/node_modules/solid-start-static/index.js:26
      if(!config?.solidOptions?.ssr) throw new Error('solid-start-static needs ssr to be enabled for pre-rendering routes at build time');

When I build the site to a static site, I got the above error...

Does it mean that with ssr disabled, I cannot generate a static site?

@ryansolid

ryansolid commented 1 year ago

I'm going to continue this conversation in the SolidStart issue.