@@ -6,7 +6,7 @@ import createDebug from 'debug'
66import type { EncodedSourceMap } from '@jridgewell/trace-mapping'
77import type { DebuggerOptions , FetchResult , ViteNodeResolveId , ViteNodeServerOptions } from './types'
88import { shouldExternalize } from './externalize'
9- import { normalizeModuleId , toArray , toFilePath } from './utils'
9+ import { normalizeModuleId , toArray , toFilePath , withTrailingSlash } from './utils'
1010import { Debugger } from './debug'
1111import { withInlineSourcemap } from './source-map'
1212
@@ -106,7 +106,7 @@ export class ViteNodeServer {
106106 }
107107
108108 async resolveId ( id : string , importer ?: string , transformMode ?: 'web' | 'ssr' ) : Promise < ViteNodeResolveId | null > {
109- if ( importer && ! importer . startsWith ( this . server . config . root ) )
109+ if ( importer && ! importer . startsWith ( withTrailingSlash ( this . server . config . root ) ) )
110110 importer = resolve ( this . server . config . root , importer )
111111 const mode = transformMode ?? ( ( importer && this . getTransformMode ( importer ) ) || 'ssr' )
112112 return this . server . pluginContainer . resolveId ( id , importer , { ssr : mode === 'ssr' } )
@@ -182,7 +182,7 @@ export class ViteNodeServer {
182182 const cacheDir = this . options . deps ?. cacheDir
183183
184184 if ( cacheDir && id . includes ( cacheDir ) ) {
185- if ( ! id . startsWith ( this . server . config . root ) )
185+ if ( ! id . startsWith ( withTrailingSlash ( this . server . config . root ) ) )
186186 id = join ( this . server . config . root , id )
187187 const timeout = setTimeout ( ( ) => {
188188 throw new Error ( `ViteNodeServer: ${ id } not found. This is a bug, please report it.` )
0 commit comments