stylex
stylex copied to clipboard
Importing a .stylex.ts does not work with tsconfig paths settings
The problem
When importing a variable file like is listed in the docs, the build is only succeeding if the import path is a relative path (i.e. ../src/lib/theme/theme.stylex), but fails if the import path uses the tsconfig "paths" setting (i.e. @/lib/theme/theme.stylex when tsconfig paths is { '@/*' : '.src/*'} )
.
With non-relative paths, it gives the Only static values are allowed inside of a stylex.create() call
error message.
How to reproduce
Steps to reproduce:
- Create a next.js app with the default of
paths: { '@/*' : '.src/*'}
in the tsconfig.json file. - Create a file called theme.stylex.ts in
/src/lib/
that defines a color usingexport const colors = stylex.defineVars({test: '#000000'})
- Try to import the colors using
import { colors } from @/lib/theme.stylex
and usecolors.test
in astylex.create
call.
Expected behavior
I would expect this to allow colors
to be used in stylex.create
as specified in the docs.
Environment (include versions). Did this work in previous versions?
- next 14.0.2 using an app router
- @stylexjs/stylex - 0.3.0
- @stylexjs/nextjs-plugin - 0.3.0