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

[vite-plugin]: adding new embedded expressions causes errors #1229

Closed
dlehmhus opened this issue Mar 23, 2023 · 3 comments
Closed

[vite-plugin]: adding new embedded expressions causes errors #1229

dlehmhus opened this issue Mar 23, 2023 · 3 comments
Labels
bug report 🦗 Issue is probably a bug, but it needs to be checked needs: complete repro 🖥️ Issue need to have complete repro provided platform: ssr 🛠️ Issue related to SSR

Comments

@dlehmhus
Copy link

Environment

  • Linaria versions:
    @linaria/core: 4.2.8
    @linaria/react: 4.3.6
    @linaria/vite: 4.2.9
  • Bundler (+ version): Vite 4.2.1
  • Node.js version: 18.15.0
  • OS: macOS Ventura 13.2.1

Description

When running vite in dev mode, adding a embedded expressions into a linaria component causes an error like the following:

[plugin:linaria] /home/projects/vitejs-vite-b813qg/src/App.tsx: The expression evaluated to 'undefined', which is probably a mistake. If you want it to be inserted into CSS, explicitly cast or transform the value to a string, e.g. - 'String(colors.blue)'.
  21 | };
  22 | const Heading = styled.h1`
> 23 | color: ${colors.blue};
     |          ^^^^^^^^^^^
  24 | `;
  25 | _c = Heading;
  26 | function App() { 

Restarting the server solves that issue and the embedded expressions will be evaluated correctly.

linaria+vite+issue.mov

Reproducible Demo

Stackblitz Example

@dlehmhus dlehmhus added bug report 🦗 Issue is probably a bug, but it needs to be checked needs: complete repro 🖥️ Issue need to have complete repro provided needs: triage 🏷 Issue needs to be checked and prioritized labels Mar 23, 2023
@github-actions github-actions bot added platform: ssr 🛠️ Issue related to SSR and removed needs: triage 🏷 Issue needs to be checked and prioritized labels Mar 23, 2023
@dlehmhus
Copy link
Author

A workaround for that issue is to patch the @linaria/vite package and remove the transform cache here. I noticed that the webpack plugin also is not using a cache, maybe for the same reason? Not sure.

@yudenichaa
Copy link

Same error if class created via css function is re-exported.

The expression evaluated to 'undefined', which is probably a mistake. If you want it to be inserted into CSS, explicitly cast or transform the value to a string, e.g. - 'String(iconContainer)'.
  11 |
> 12 |   .${iconContainer} {
     |      ^^^^^^^^^^^^^

@dlehmhus
Copy link
Author

Cannot reproduce the issue anymore. I think #1306 fixed it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report 🦗 Issue is probably a bug, but it needs to be checked needs: complete repro 🖥️ Issue need to have complete repro provided platform: ssr 🛠️ Issue related to SSR
Projects
None yet
Development

No branches or pull requests

2 participants