-
Notifications
You must be signed in to change notification settings - Fork 12
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
Variables not Working #39
Comments
Please share a repository that reproduces the issue. |
Here is an example: https://github.com/netuno-org/cluar/tree/main/website Then there is a StyleX basic implementation here: https://github.com/netuno-org/cluar/tree/main/website/src/base/Cookies
With this, if you try to use variables, the error will occur. You probably can't run the code directly because you need some injections created when the backend starts. But you should replicate the error using the same I remember testing with NodeJS using PNPM and NPM, the error also occurred. Finally, this project is now with BUN, Vite/SWC, and I installed with PNPM. |
I'm seeing the same error on an |
I am having the same problem, but only when the file is imported using an |
Which can be solved by using StyleX's import * as path from "node:path";
import tsconfig from "./tsconfig.json";
// ...
const stylexAliases = Object.fromEntries(
Object.entries(tsconfig.compilerOptions.paths).map(([alias, paths]) => [
alias,
paths.map((p) => path.resolve(import.meta.dirname, p)),
])
);
export default defineConfig({
plugins: [
tsconfigPaths(),
styleX({
aliases: stylexAliases,
}),
],
}); |
I think the |
This does seem to solve the problem, but on mac this is not needed, which tells me this might still actually be an issue if |
@dszmaj7 , judging by your error above, that does not look like a vite import error for "styles/index.ts" file, since it detects the re-exported file ".../...stylex.ts" in the error. You would get the same error when importing Please see rules for when importing variables: https://stylexjs.com/docs/learn/theming/using-variables/#rules-when-using-variables |
On a mac and tried the tsconfig config solution with no luck. I am also using vite-tsconfig-paths. As a work around I'm simply directly linking to the file and that seems to work. Not using barrel files and directly importing a named export form a This workaround is fine for now, but when I have time I'll try to come back and see if I can reproduce it in a blank repo. Versions are
|
Hi,
It is impossible to use variables because when using variables raises the error:
[plugin:vite-plugin-stylex] /index.stylex.js: Only static values are allowed inside of a stylex.create() call.
My
tokens.stylex.js
:Using the
colors.primary
variable:The text was updated successfully, but these errors were encountered: