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

default import from styled-components doesn't work #7

Open
jaked opened this issue Apr 25, 2024 · 1 comment
Open

default import from styled-components doesn't work #7

jaked opened this issue Apr 25, 2024 · 1 comment

Comments

@jaked
Copy link
Collaborator

jaked commented Apr 25, 2024

styled-components has a default export (according to its type signature), but if you use it you get

TypeError: __vite_ssr_import_2__.default.div is not a function
@jaked
Copy link
Collaborator Author

jaked commented Apr 25, 2024

turns out this works fine if you use it in a client-side cell:

import styled from 'styled-components';

const Div = styled.div`
background-color: red;
`;

<Div>hello</Div>

but if you define a component in a cell without using it, the code is run server-side (even though you'll use the defined component client-side), which fails with the above error.

Maybe there's some Vite config to handle the module interop properly? Or we could distinguish client / server cells explicitly instead of trying to infer from usage? Or we could try to do a better job of inferring from usage, i.e. detect a component definition as client-side only.

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