@@ -123,6 +123,9 @@ export async function updateTemplates (options?: { filter?: (template: ResolvedN
123123 return await tryUseNuxt ( ) ?. hooks . callHook ( 'builder:generateApp' , options )
124124}
125125
126+ const EXTENSION_RE = / \b \. \w + $ / g
127+ // Exclude bridge alias types to support Volar
128+ const excludedAlias = [ / ^ @ v u e \/ .* $ / , / ^ # i n t e r n a l \/ n u x t / ]
126129export async function _generateTypes ( nuxt : Nuxt ) {
127130 const rootDirWithSlash = withTrailingSlash ( nuxt . options . rootDir )
128131 const relativeRootDir = relativeWithDot ( nuxt . options . buildDir , nuxt . options . rootDir )
@@ -225,9 +228,6 @@ export async function _generateTypes (nuxt: Nuxt) {
225228
226229 const aliases : Record < string , string > = nuxt . options . alias
227230
228- // Exclude bridge alias types to support Volar
229- const excludedAlias = [ / ^ @ v u e \/ .* $ / , / ^ # i n t e r n a l \/ n u x t / ]
230-
231231 const basePath = tsConfig . compilerOptions ! . baseUrl
232232 ? resolve ( nuxt . options . buildDir , tsConfig . compilerOptions ! . baseUrl )
233233 : nuxt . options . buildDir
@@ -260,7 +260,7 @@ export async function _generateTypes (nuxt: Nuxt) {
260260 } else {
261261 const path = stats ?. isFile ( )
262262 // remove extension
263- ? relativePath . replace ( / \b \. \w + $ / g , '' )
263+ ? relativePath . replace ( EXTENSION_RE , '' )
264264 // non-existent file probably shouldn't be resolved
265265 : aliases [ alias ] !
266266
@@ -289,7 +289,7 @@ export async function _generateTypes (nuxt: Nuxt) {
289289 tsConfig . compilerOptions ! . paths [ alias ] = await Promise . all ( paths . map ( async ( path : string ) => {
290290 if ( ! isAbsolute ( path ) ) { return path }
291291 const stats = await fsp . stat ( path ) . catch ( ( ) => null /* file does not exist */ )
292- return relativeWithDot ( nuxt . options . buildDir , stats ?. isFile ( ) ? path . replace ( / \b \. \w + $ / g , '' ) /* remove extension */ : path )
292+ return relativeWithDot ( nuxt . options . buildDir , stats ?. isFile ( ) ? path . replace ( EXTENSION_RE , '' ) /* remove extension */ : path )
293293 } ) )
294294 }
295295
@@ -349,6 +349,7 @@ function renderAttr (key: string, value?: string) {
349349 return value ? `${ key } ="${ value } "` : ''
350350}
351351
352+ const RELATIVE_WITH_DOT_RE = / ^ ( [ ^ . ] ) /
352353function relativeWithDot ( from : string , to : string ) {
353- return relative ( from , to ) . replace ( / ^ ( [ ^ . ] ) / , './$1' ) || '.'
354+ return relative ( from , to ) . replace ( RELATIVE_WITH_DOT_RE , './$1' ) || '.'
354355}
0 commit comments