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

Astro SSR client:load Error: Cannot use import statement outside a module #104

Closed
AndreiTelteu opened this issue Sep 9, 2022 · 4 comments
Labels
bug Something isn't working duplicate This issue or pull request already exists

Comments

@AndreiTelteu
Copy link

Hi. I have a astro project with my page written in solid-js and i want to use a simple TextInput.
Here is a demo of that i'm trying to do: https://stackblitz.com/edit/github-xmtfif?file=src/pages/index.astro

Error is:

Cannot use import statement outside a module
/home/projects/github-xmtfif/node_modules/@suid/base/createComponentFactory.js:1
import composeClasses from "./composeClasses";

Astro troubleshooting for this error: https://docs.astro.build/en/guides/troubleshooting/#cannot-use-import-statement-outside-a-module

I tried using noExternal instead: https://vitejs.dev/config/ssr-options.html#ssr-noexternal

      noExternal: [
        '@suid/material',
        '@suid/base',
        '@suid/system',
        '@suid/css',
        '@suid/utils',
        '@suid/styled-engine',
      ],

And now the error is:

ReferenceError: document is not defined
    at Module.findStyleElement [as default] (/node_modules/@suid/css/dom/findStyleElement.js:2:5)
    at /node_modules/@suid/styled-engine/createStyle.js:31:44
    at Proxy.createComputed (/home/projects/github-xmtfif/node_modules/solid-js/dist/server.cjs:56:5)
    at Module.createStyle (/node_modules/@suid/styled-engine/createStyle.js:22:4)
    at Box2 (Box.jsx:30:28)
    at Proxy.createComponent (/home/projects/github-xmtfif/node_modules/solid-js/dist/server.cjs:283:15)
    at createStyled.jsx:50:10
    at Proxy.createComponent (/home/projects/github-xmtfif/node_modules/solid-js/dist/server.cjs:283:15)
    at get children [as children] (FormControl.jsx:97:2)
    at eval (/home/projects/github-xmtfif/node_modules/solid-js/dist/server.cjs:187:35

The only way to make it work is to load my page component with client:only="solid-js", but this means i don't have any ssr on the entire page.

@juanrgm juanrgm added WIP Work in process bug Something isn't working duplicate This issue or pull request already exists labels Sep 11, 2022
@kedzior-io
Copy link

@AndreiTelteu I'm on the same boat. Have AstroJS beautifully working with SolidJs + SSR but the moment I introduce this library or solid-bootstrap, stuff doesn't work anymore.

@awojciak
Copy link

I'm having the same issue when using vite-plugin-ssr

@kedzior-io
Copy link

@awojciak yeah I really wanted this to work but ... in the end went back to AstroJs + React + MUI which works flawlessly.

@juanrgm juanrgm removed the WIP Work in process label Nov 17, 2022
@juanrgm
Copy link
Member

juanrgm commented Nov 17, 2022

Closed via 89148a6.

// vite.config.ts
import suid from "@suid/vite-plugin";
import solid from "solid-start/vite";
import { defineConfig } from "vite";

export default defineConfig({
  plugins: [suid(), solid({ ssr: false })],
});

@juanrgm juanrgm closed this as completed Nov 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

4 participants