@@ -15,7 +15,7 @@ import assert from 'node:assert';
15
15
import { randomUUID } from 'node:crypto' ;
16
16
import { readFile } from 'node:fs/promises' ;
17
17
import { ServerResponse } from 'node:http' ;
18
- import path from 'node:path' ;
18
+ import { dirname , extname , join , relative } from 'node:path' ;
19
19
import type { Connect , DepOptimizationConfig , InlineConfig , ViteDevServer } from 'vite' ;
20
20
import { BuildOutputFile , BuildOutputFileType } from '../../tools/esbuild/bundler-context' ;
21
21
import { JavaScriptTransformer } from '../../tools/esbuild/javascript-transformer' ;
@@ -200,7 +200,7 @@ export async function* serveWithVite(
200
200
}
201
201
202
202
const { root = '' } = await context . getProjectMetadata ( projectName ) ;
203
- const projectRoot = path . join ( context . workspaceRoot , root as string ) ;
203
+ const projectRoot = join ( context . workspaceRoot , root as string ) ;
204
204
const browsers = getSupportedBrowsers ( projectRoot , context . logger ) ;
205
205
const target = transformSupportedBrowsersToTargets ( browsers ) ;
206
206
@@ -262,7 +262,7 @@ function handleUpdate(
262
262
if ( record . updated ) {
263
263
updatedFiles . push ( file ) ;
264
264
const updatedModules = server . moduleGraph . getModulesByFile (
265
- normalizePath ( path . join ( server . config . root , file ) ) ,
265
+ normalizePath ( join ( server . config . root , file ) ) ,
266
266
) ;
267
267
updatedModules ?. forEach ( ( m ) => server ?. moduleGraph . invalidateModule ( m ) ) ;
268
268
}
@@ -389,15 +389,15 @@ export async function setupServer(
389
389
390
390
// Path will not exist on disk and only used to provide separate path for Vite requests
391
391
const virtualProjectRoot = normalizePath (
392
- path . join ( serverOptions . workspaceRoot , `.angular/vite-root/${ randomUUID ( ) } /` ) ,
392
+ join ( serverOptions . workspaceRoot , `.angular/vite-root/${ randomUUID ( ) } /` ) ,
393
393
) ;
394
394
395
395
const { builtinModules } = await import ( 'node:module' ) ;
396
396
397
397
const configuration : InlineConfig = {
398
398
configFile : false ,
399
399
envFile : false ,
400
- cacheDir : path . join ( serverOptions . cacheOptions . path , 'vite' ) ,
400
+ cacheDir : join ( serverOptions . cacheOptions . path , 'vite' ) ,
401
401
root : virtualProjectRoot ,
402
402
publicDir : false ,
403
403
esbuild : false ,
@@ -462,20 +462,20 @@ export async function setupServer(
462
462
const [ importerFile ] = importer . split ( '?' , 1 ) ;
463
463
464
464
source = normalizePath (
465
- path . join ( path . dirname ( path . relative ( virtualProjectRoot , importerFile ) ) , source ) ,
465
+ join ( dirname ( relative ( virtualProjectRoot , importerFile ) ) , source ) ,
466
466
) ;
467
467
}
468
468
if ( source [ 0 ] === '/' ) {
469
469
source = source . slice ( 1 ) ;
470
470
}
471
471
const [ file ] = source . split ( '?' , 1 ) ;
472
472
if ( outputFiles . has ( file ) ) {
473
- return path . join ( virtualProjectRoot , source ) ;
473
+ return join ( virtualProjectRoot , source ) ;
474
474
}
475
475
} ,
476
476
load ( id ) {
477
477
const [ file ] = id . split ( '?' , 1 ) ;
478
- const relativeFile = normalizePath ( path . relative ( virtualProjectRoot , file ) ) ;
478
+ const relativeFile = normalizePath ( relative ( virtualProjectRoot , file ) ) ;
479
479
const codeContents = outputFiles . get ( relativeFile ) ?. contents ;
480
480
if ( codeContents === undefined ) {
481
481
if ( relativeFile . endsWith ( '/node_modules/vite/dist/client/client.mjs' ) ) {
@@ -530,7 +530,7 @@ export async function setupServer(
530
530
// Parse the incoming request.
531
531
// The base of the URL is unused but required to parse the URL.
532
532
const pathname = pathnameWithoutServePath ( req . url , serverOptions ) ;
533
- const extension = path . extname ( pathname ) ;
533
+ const extension = extname ( pathname ) ;
534
534
535
535
// Rewrite all build assets to a vite raw fs URL
536
536
const assetSourcePath = assets . get ( pathname ) ;
@@ -586,7 +586,7 @@ export async function setupServer(
586
586
! url ||
587
587
// Skip if path is like a file.
588
588
// NOTE: We use a regexp to mitigate against matching requests like: /browse/pl.0ef59752c0cd457dbf1391f08cbd936f
589
- / ^ \. [ a - z ] { 2 , 4 } $ / i. test ( path . extname ( url . split ( '?' ) [ 0 ] ) )
589
+ / ^ \. [ a - z ] { 2 , 4 } $ / i. test ( extname ( url . split ( '?' ) [ 0 ] ) )
590
590
) {
591
591
next ( ) ;
592
592
@@ -607,9 +607,9 @@ export async function setupServer(
607
607
document : html ,
608
608
route,
609
609
serverContext : 'ssr' ,
610
- loadBundle : ( path : string ) =>
610
+ loadBundle : ( uri : string ) =>
611
611
// eslint-disable-next-line @typescript-eslint/no-explicit-any
612
- server . ssrLoadModule ( path . slice ( 1 ) ) as any ,
612
+ server . ssrLoadModule ( uri . slice ( 1 ) ) as any ,
613
613
// Files here are only needed for critical CSS inlining.
614
614
outputFiles : { } ,
615
615
// TODO: add support for critical css inlining.
0 commit comments