-
Notifications
You must be signed in to change notification settings - Fork 319
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
Getting an Error when passing a defined variable to a stylex.create #71
Comments
Have you tried removing the |
As far as I can tell, this is an issue with the StyleX's Babel plugin uses |
I wonder why these tools haven't standardized on Node.js subpath imports instead Related issue: #40 |
I wonder why it works when using dynamic styles like here: export const styles = stylex.create({
container: () => ({
backgroundColor: staticColors.colorsBaseWhite,
}),
}); But doesn't work when using static styles, If it's a compiler issue I would assume it wouldn't work in both situations |
Dynamic styles can't be compiled, that's why it works, the container function is executed at runtime. |
hi @necolas can i work on this, i can provide with better solution for this. |
Note: functions generate "dynamic styles". I.e, it sets styles at runtime by setting inline styles. Excessive use of dynamic styles is a performance pitfall. It should definitely not be used for importing variable which can imported statically. @Jilesh980 What changes do you propose? |
Hello @nmn i am working on to fix the issue which is getting on compilation so that better output is produced with CSS. |
Yes, @Jilesh980 I'm asking about some basic details on how you're solving this issue. I don't want you to waste your time using an approach we cannot support. |
changing this worked, thanks for clarifying 🚀
This didnt seem to have an effect, however we did change it to style.ts as stated in the docs |
Closing this issue as we're already tracking the issue with NextJS aliases. |
Title; Compilation Error, with Stylex. Values allowed inside the stylex.create() function
Environment;
Operating System; Ubuntu 22.04 (WSL)
Next.js Version; 14.0.2
Stylex Version; 0.3.0
Webpack Version; (Included with Next.js)
Description;
I encountered an issue while trying to compile a Next.js project that uses Stylex for styling. The build process. Displays an error message stating that only static values can be used inside the
stylex.create()
function call. This problem occurs even though I followed the documentation, which instructs to define variables usingstylex.defineVars()
and use them withinstylex.create()
.like so:
and used it like so:
Steps to Reproduce;
stylex.defineVars()
in a file calledtokens.stylex.ts
.stylex.create()
call in a component.build
command to compile the project.Expected Result;
The project should successfully compile, with Stylex processing the CSS variable definitions and applying them as intended.
Actual Result;
The build process encounters an error that states;
This error indicates that there might be dynamic values being passed to
stylex.create()
which is not supported.Additional Information;
The Next.js configuration has been customized to utilize the
@stylexjs/webpack plugin
for StyleX.Due to the issue, with Google Fonts and the Next.js StyleX plugin it was decided to use the Webpack plugin
Note: It is observed that the compilation works when
stylex.create()
is used with a function that returns the style object, as shown below:However, this approach is contrary to the examples provided in the Stylex documentation where
stylex.create()
is directly given an object. The expected usage, as per the documentation, which is currently not working, is:This inconsistency between the documentation and the actual working solution suggests a potential issue with the library's handling of variable definitions within
stylex.create()
calls.Thanks for reviewing the issue, we are looking forward to use this in our app,
Samplead Team
The text was updated successfully, but these errors were encountered: