88
99import { readFile } from 'node:fs/promises' ;
1010import { join } from 'node:path' ;
11- import type { Connect , InlineConfig , SSROptions , ServerOptions } from 'vite' ;
11+ import type * as Vite from 'vite' with {
12+ 'resolution-mode' : 'import' ,
13+ } ;
1214import type { ComponentStyleRecord } from '../../../tools/vite/middlewares' ;
1315import {
1416 ServerSsrMode ,
@@ -30,7 +32,7 @@ async function createServerConfig(
3032 ssrMode : ServerSsrMode ,
3133 preTransformRequests : boolean ,
3234 cacheDir : string ,
33- ) : Promise < ServerOptions > {
35+ ) : Promise < Vite . ServerOptions > {
3436 const proxy = await loadProxyConfiguration (
3537 serverOptions . workspaceRoot ,
3638 serverOptions . proxyConfig ,
@@ -47,7 +49,7 @@ async function createServerConfig(
4749 break ;
4850 }
4951
50- const server : ServerOptions = {
52+ const server : Vite . ServerOptions = {
5153 preTransformRequests,
5254 warmup : {
5355 ssrFiles,
@@ -101,7 +103,7 @@ function createSsrConfig(
101103 prebundleLoaderExtensions : EsbuildLoaderOption | undefined ,
102104 thirdPartySourcemaps : boolean ,
103105 define : ApplicationBuilderInternalOptions [ 'define' ] ,
104- ) : SSROptions {
106+ ) : Vite . SSROptions {
105107 return {
106108 // Note: `true` and `/.*/` have different sematics. When true, the `external` option is ignored.
107109 noExternal : / .* / ,
@@ -139,11 +141,11 @@ export async function setupServer(
139141 templateUpdates : Map < string , string > ,
140142 prebundleLoaderExtensions : EsbuildLoaderOption | undefined ,
141143 define : ApplicationBuilderInternalOptions [ 'define' ] ,
142- extensionMiddleware ?: Connect . NextHandleFunction [ ] ,
144+ extensionMiddleware ?: Vite . Connect . NextHandleFunction [ ] ,
143145 indexHtmlTransformer ?: ( content : string ) => Promise < string > ,
144146 thirdPartySourcemaps = false ,
145- ) : Promise < InlineConfig > {
146- const { normalizePath } = await import ( 'vite' ) ;
147+ ) : Promise < Vite . InlineConfig > {
148+ const { normalizePath } = ( await import ( 'vite' as string ) ) as typeof Vite ;
147149
148150 // Path will not exist on disk and only used to provide separate path for Vite requests
149151 const virtualProjectRoot = normalizePath (
@@ -161,13 +163,13 @@ export async function setupServer(
161163 externalMetadata . explicitBrowser . length === 0 && ssrMode === ServerSsrMode . NoSsr ;
162164 const cacheDir = join ( serverOptions . cacheOptions . path , serverOptions . buildTarget . project , 'vite' ) ;
163165
164- const configuration : InlineConfig = {
166+ const configuration : Vite . InlineConfig = {
165167 configFile : false ,
166168 envFile : false ,
167169 cacheDir,
168170 root : virtualProjectRoot ,
169171 publicDir : false ,
170- esbuild : false ,
172+ oxc : false ,
171173 mode : 'development' ,
172174 // We use custom as we do not rely on Vite's htmlFallbackMiddleware and indexHtmlMiddleware.
173175 appType : 'custom' ,
0 commit comments