You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm building my design system in a dedicated package in a mono-repository. Everything was working perfectly until we try to use the theme variable in the main application (not only in the design system package).
The main application is a Remix application. In its root.tsx file I import my theme class (generated with createTheme())
The issue is when I trigger when I use the CSS variable of my theme:
import{AcmeLegacyVars}from'@acme/guidelines';import{style}from'@vanilla-extract/css';exportconstsomeStyle=style({borderBottom: `1px solid ${AcmeLegacyVars.colors.gray[500]}`,// <-- This make the build to get stuck with no error message});
I declare my theme like this:
// Most of the theme tokens have been removed to improve readability.exportconst[acmeLegacyThemeClass,AcmeLegacyVars]=createTheme({colors: {gray: {'500': '#9ca3af',},},});
My issue is that I could use the acmeLegacyThemeClass but not the AcmeLegacyVars in my application.
$ yarn dev
Loading environment variables from .env
💿 Building...
💿 Built in 720ms
Waiting for app server (95e66e5a)
> remix-serve build/index.js
Remix dev server ready
Remix App Server started at http://localhost:3000 (http://192.168.1.32:3000)
App server took 273ms
GET / 200 - - 23.179 ms
💿 File changed: app/routes/someStyle.css.ts
💿 File changed: app/routes/someStyle.css.ts
💿 Rebuilding... # <-- Stuck here
Validations
Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
Getting something very similar in our monorepo (Vanilla Extract component library -> Gatsby site). If we force the Gatsby site to use the package straight from the registry, rather than symlinked the issue goes away.
TL;DR Exporting react components and styles from the same entrypoint causes issues with react refresh due to how it uses TitleCase names to detect components, and this might also be tripping up Remix.
I tested this theory by removing all component exports from @acme/guidelines's index.ts file. This resulted in a remix build/dev server that worked fine, but obviously didn't use the components.
A common solution to this is to expose your styles in a separate entrypoint to your components. I tried to get this working but just adding a styles.ts file to the UI package and importing directly from @acme/guidelines/src/styles but Remix didn't like this. It did however at least result in a successful build, but the server couldn't import the file correctly.
I also tried converting everything to type: "module" and setting up package.json exports, but I couldn't get Remix to play nice with pure ESM.
Describe the bug
I'm building my design system in a dedicated package in a mono-repository. Everything was working perfectly until we try to use the theme variable in the main application (not only in the design system package).
The main application is a Remix application. In its
root.tsx
file I import my theme class (generated withcreateTheme()
)This is working.
The issue is when I trigger when I use the CSS variable of my theme:
I declare my theme like this:
My issue is that I could use the
acmeLegacyThemeClass
but not theAcmeLegacyVars
in my application.Am I doing something wrong?
Reproduction
https://github.com/armandabric/vanilla-extract-import-vars-bug
System Info
Used Package Manager
yarn
Logs
Validations
The text was updated successfully, but these errors were encountered: