11import { describe , expect , it } from "vitest" ;
22import * as ts from "typescript" ;
3- import { isAbsolute , join , relative } from "node:path" ;
3+ import { isAbsolute , join , normalize , relative } from "node:path" ;
44import { fileURLToPath } from "node:url" ;
55import { createRequire } from "node:module" ;
66
@@ -33,6 +33,7 @@ function assertFixtureViteVersion(fixtureDir: string, expectedMajor: string): vo
3333function getDiagnosticsForFixture ( fixtureName : string , expectedMajor : string ) : string [ ] {
3434 const fixtureDir = join ( fixturesDir , fixtureName ) ;
3535 const fileName = join ( fixtureDir , "sentry-vite-plugin-type-compat.mts" ) ;
36+ const isVirtualConfigFile = ( path : string ) => normalize ( path ) === normalize ( fileName ) ;
3637
3738 assertFixtureViteVersion ( fixtureDir , expectedMajor ) ;
3839 assertFixtureViteVersion ( pluginViteTypesFixtureDir , "6" ) ;
@@ -52,10 +53,10 @@ function getDiagnosticsForFixture(fixtureName: string, expectedMajor: string): s
5253 // eslint-disable-next-line @typescript-eslint/unbound-method
5354 const getSourceFile = host . getSourceFile ;
5455
55- host . fileExists = ( path ) => path === fileName || ts . sys . fileExists ( path ) ;
56- host . readFile = ( path ) => ( path === fileName ? configSource : ts . sys . readFile ( path ) ) ;
56+ host . fileExists = ( path ) => isVirtualConfigFile ( path ) || ts . sys . fileExists ( path ) ;
57+ host . readFile = ( path ) => ( isVirtualConfigFile ( path ) ? configSource : ts . sys . readFile ( path ) ) ;
5758 host . getSourceFile = ( path , languageVersion , onError , shouldCreateNewSourceFile ) =>
58- path === fileName
59+ isVirtualConfigFile ( path )
5960 ? ts . createSourceFile ( path , configSource , languageVersion , true )
6061 : getSourceFile ( path , languageVersion , onError , shouldCreateNewSourceFile ) ;
6162 host . resolveModuleNames = ( moduleNames , containingFile ) =>
0 commit comments