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

Bad Error message when trying to use props values as Css values #1412

Closed
2 tasks done
GabrielZCode opened this issue May 16, 2024 · 7 comments
Closed
2 tasks done

Bad Error message when trying to use props values as Css values #1412

GabrielZCode opened this issue May 16, 2024 · 7 comments
Labels
incorrect setup Issue relating to incorrect config or setup

Comments

@GabrielZCode
Copy link

GabrielZCode commented May 16, 2024

Describe the bug

i know i can't use dynamic values as CSS values when using vanilla-extract , but the error message displayed is not helpful.

Description:

  • When deploying a project to vercel i get the error message: "Error: The Edge Function "_qwik-city" is referencing unsupported modules: @qwik-city-plan.js: @vanilla-extract/css, @vanilla-extract/css/functionSerializer"

Cause:

A div component with class ={ style({ backgroundColor: props.value.toString() }) }

Suggested Error Message:

vanilla-extract-css -- dynamic values are not allowed in this context -- $file_name:$file_line

Reproduction

npm create qwik; npm run qwik add vanilla-extract-css; npm run qwik add vercel-adapter ; npm run build; npm run deploy

System Info

node --version: 20.3.0
openSuse tumbleweed linux x64 
linux-header: 6.8.1-1-default

- package version: 0.5.4 (vanilla-extract)
- framework: qwik: 1.5.4

Used Package Manager

npm

Logs

"Error: The Edge Function "_qwik-city" is referencing unsupported modules:
    - @qwik-city-plan.js: @vanilla-extract/css, @vanilla-extract/css/functionSerializer"

Validations

@askoufis
Copy link
Contributor

askoufis commented May 17, 2024

I don't think the referencing unsupported modules error comes from Vanilla Extract. That seems like a vercel thing. If you call style within a component at runtime, you'd probably see this error message, but it seems like vercel is throwing an error first.

@GabrielZCode
Copy link
Author

OK good point, but the error message is still wrong, the configuration is right, the preview works so there's no at runtime (styles are already loaded to the component).

the problem relies with assingning variables to style(), witch the dev should not be doing.

I just think the error message is not helping the dev debugging the problem

@askoufis
Copy link
Contributor

I can't reproduce your error with the reproduction you've provided. npm run qwik add vanilla-extract-css and npm run qwik add vercel-adapter don't seem to be valid commands. I think the integrations have different names.

Even when I did add the VE and vercel integrations correctly, I managed to deploy the app just fine. If you could create a repo with a minimal example of the error, or at least provide steps on reproducing the error in a simple qwik app, that would be appreciated.

@GabrielZCode
Copy link
Author

Of course, I'll work on that, and get back to you in few days, sorry for the delay if that's a problem

@GabrielZCode
Copy link
Author

npm create qwik@latest basic ./project; cd ./project ; npm install; npm run qwik add vercel-edge; (Press Enter); npm run qwik add styled-vanilla-extract; (Press Enter); npm install --legacy-peer-deps; mkdir src/components/buggy-component; touch src/components/buggy-component.tsx; echo 'import { component$ } from "@builder.io/qwik";
import { style } from "styled-vanilla-extract/qwik";

export default component$(() => {
const value = "anything"
return (
<div class={style({ backgroundColor: value})}/>
)
})' >> ./src/components/buggy-component/buggy-component.tsx;
npm run build; npm run build.server ; npm run deploy (Remember to configure your vercel project to do npm install with the --legacy-peer-deps option)

I think now its reproducible

@askoufis
Copy link
Contributor

askoufis commented May 27, 2024

You can't use style in a runtime file, i.e. outside of a .css.ts file. Even though you're using styled-vanilla-extract/qwik, rather than @vanilla-extract/css directly, this is still the case (as shown in the package documentation).

I'm guessing that vercel is detecting some VE dependencies as runtime dependencies due to your use of style within buggy-component.tsx, resulting in that error.

Again, I don't think this is an issue that VE can help with, since your usage of the library is incorrect, and we can't easily influence how vercel chooses to surface this error.

@askoufis askoufis added incorrect setup Issue relating to incorrect config or setup and removed pending triage labels May 27, 2024
@GabrielZCode
Copy link
Author

fine man, thanks for you time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
incorrect setup Issue relating to incorrect config or setup
Projects
None yet
Development

No branches or pull requests

2 participants