1- import { join , relative , isAbsolute } from 'path' ;
1+ import { join , isAbsolute } from 'path' ;
22import type { Adapter } from '@vanilla-extract/css' ;
33import { transformCss } from '@vanilla-extract/css/transformCss' ;
44import type { ModuleNode , InlineConfig as ViteConfig } from 'vite' ;
@@ -16,7 +16,7 @@ type Composition = Parameters<Adapter['registerComposition']>[0];
1616
1717const globalAdapterIdentifier = '__vanilla_globalCssAdapter__' ;
1818
19- const scanModule = ( entryModule : ModuleNode , root : string ) => {
19+ const scanModule = ( entryModule : ModuleNode ) => {
2020 const queue = new Set ( [ entryModule ] ) ;
2121 const cssDeps = new Set < string > ( ) ;
2222 const watchFiles = new Set < string > ( ) ;
@@ -26,10 +26,8 @@ const scanModule = (entryModule: ModuleNode, root: string) => {
2626 continue ;
2727 }
2828
29- const relativePath = moduleNode . id && relative ( root , moduleNode . id ) ;
30-
31- if ( relativePath && cssFileFilter . test ( relativePath ) ) {
32- cssDeps . add ( relativePath ) ;
29+ if ( moduleNode . id && cssFileFilter . test ( moduleNode . id ) ) {
30+ cssDeps . add ( moduleNode . id ) ;
3331 }
3432 if ( moduleNode . file ) {
3533 watchFiles . add ( moduleNode . file ) ;
@@ -151,7 +149,7 @@ class NormalizedMap<V> extends Map<string, V> {
151149
152150 #normalizePath( filePath : string ) {
153151 return normalizePath (
154- isAbsolute ( filePath ) ? relative ( this . root , filePath ) : filePath ,
152+ isAbsolute ( filePath ) ? filePath : join ( this . root , filePath ) ,
155153 ) ;
156154 }
157155
@@ -319,7 +317,7 @@ export const createCompiler = ({
319317
320318 const cssImports = [ ] ;
321319
322- const { cssDeps, watchFiles } = scanModule ( moduleNode , root ) ;
320+ const { cssDeps, watchFiles } = scanModule ( moduleNode ) ;
323321
324322 for ( const cssDep of cssDeps ) {
325323 const cssDepModuleId = normalizePath ( cssDep ) ;
@@ -388,9 +386,7 @@ export const createCompiler = ({
388386 } ,
389387 getCssForFile ( filePath : string ) {
390388 filePath = isAbsolute ( filePath ) ? filePath : join ( root , filePath ) ;
391- const rootRelativePath = relative ( root , filePath ) ;
392-
393- const moduleId = normalizePath ( rootRelativePath ) ;
389+ const moduleId = normalizePath ( filePath ) ;
394390 const result = cssCache . get ( moduleId ) ;
395391
396392 if ( ! result ) {
@@ -399,7 +395,7 @@ export const createCompiler = ({
399395
400396 return {
401397 css : result . css ,
402- filePath : rootRelativePath ,
398+ filePath : filePath ,
403399 resolveDir : root ,
404400 } ;
405401 } ,
0 commit comments