solid-start icon indicating copy to clipboard operation
solid-start copied to clipboard

Error: 'classList' is not exported by node_modules when running build command

Open charkour opened this issue 1 year ago • 0 comments

Hi,

Thanks for the fantastic work you do.

I have a simple portfolio website built in solid with vite and I'm trying to transition to SolidStart. I've migrated the code and it works well in dev, but running the build command results in an error: Error: 'classList' is not exported by node_modules/.pnpm/[email protected]/node_modules/solid-js/web/dist/server.js. I think this is because classList is a helper only for client code, correct? The code snippet and reproduction repo is below.

Code snippet using `classList`
import { type Component, JSX } from "solid-js";
import { spread, classList, setAttribute } from "solid-js/web";

interface Props extends JSX.HTMLAttributes<HTMLHeadingElement> {
  as?: Parameters<typeof document.createElement>[0];
}

export const Typography: Component<Props> = ({ as = "h1", ...rest }) => {
  const element = document.createElement(as);
  spread(element, rest);
  classList(element, {
    "uppercase font-bold text-3xl sm:text-5xl md:text-6xl border-b w-full text-center tracking-wide py-0.5 sm:py-1 md:py-2":
      as === "h1",
    "text-xl sm:text-3xl font-thin sm:leading-10":
      as === "h2",
    "text-lg sm:text-2xl font-bold":
      as === "h3",
    "": as === "small",
    "text-sm sm:text-base leading-4": as === "p",
  });
  typeof rest.children === "string" &&
    setAttribute(element, "id", rest.children);

  return element;
};

Link to reproduction.

Possibly related to https://github.com/solidjs/solid-start/issues/95.

Is there a workaround for this? Or is this a bug with SolidStart and the related libraries? Perhaps I don't understand the differences between Solid and SolidStart enough and the way the server is used in the latter.

Thank you

charkour avatar Dec 03 '22 03:12 charkour