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

Vite plugin shows a RerenceError when running test with vitest #1298

Closed
2 tasks done
lfantone opened this issue Jan 29, 2024 · 1 comment · Fixed by #1300
Closed
2 tasks done

Vite plugin shows a RerenceError when running test with vitest #1298

lfantone opened this issue Jan 29, 2024 · 1 comment · Fixed by #1300
Labels
bug Issue is caused by a bug in a Vanilla Extract package vite Issue related to vite

Comments

@lfantone
Copy link

lfantone commented Jan 29, 2024

Describe the bug

After upgrading to the latest @vanilla-extract/[email protected] all our test started failing with __vanilla_globalCssAdapter__ is not defined.

The test are running under vitest. Downgrading to a lower version the tests are working fine.

In the other hand, building with vite works fine (or at least doesn't throw any error in the output)

Reproduction

https://codesandbox.io/p/devbox/586t6n

System Info

System:
    OS: macOS 14.2.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 1.37 GB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.11.0 - ~/.volta/tools/image/node/20.11.0/bin/node
    Yarn: 4.0.2 - ~/.volta/tools/image/yarn/1.22.19/bin/yarn
    npm: 10.2.4 - ~/.volta/tools/image/node/20.11.0/bin/npm
  Browsers:
    Chrome: 121.0.6167.85
    Edge: 121.0.2277.83
    Safari: 17.2.1
  npmPackages:
    @vanilla-extract/css: ^1.14.1 => 1.14.1
    @vanilla-extract/recipes: ^0.5.1 => 0.5.1
    @vanilla-extract/vite-plugin: ^4.0.0 => 4.0.0
    vite: ^5.0.12 => 5.0.12

Used Package Manager

yarn

Logs

FAIL  |adg-components| src/atoms/tag/tag.test.jsx [ src/atoms/tag/tag.test.jsx ]
ReferenceError: __vanilla_globalCssAdapter__ is not defined
 ❯ src/theme/theme.css.ts:3:20
      1| import { createTheme, createThemeContract } from '@vanilla-extract/css';
      2| 
      3| import { tokens as darkColors } from './dark-colors.js';
       |                    ^
      4| import { tokens as lightColors } from './light-colors.js';
      5| import { toThemeContract } from './utils.js';
 ❯ src/atoms/tag/tag.css.ts:4:31

Validations

@lfantone lfantone changed the title Vite plugin Vite plugin shows a RerenceError when running test with vitest Jan 29, 2024
@mrm007
Copy link
Contributor

mrm007 commented Jan 29, 2024

Thanks for reporting. This should be fixed in #1300.

Check out this CodeSandbox: https://codesandbox.io/p/github/mrm007/vanilla-extract-vite-plugin-v4-vitest/main

You can try it out for yourself by installing this snapshot:

yarn add @vanilla-extract/vite-plugin@vite-plugin-skip-vitest-plugins

@mrm007 mrm007 added vite Issue related to vite bug Issue is caused by a bug in a Vanilla Extract package and removed pending triage labels Jan 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue is caused by a bug in a Vanilla Extract package vite Issue related to vite
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants