File tree 2 files changed +13
-5
lines changed
2 files changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -220,7 +220,7 @@ async function loadConfig(): Promise<Config> {
220
220
if ( ! existsSync ( CONFIG_FILE ) ) {
221
221
return { } ;
222
222
}
223
- const { loadServerFile } = await import ( './lib/utils/vite-loader.js' ) ;
223
+ const { loadServerModule } = await import ( './lib/utils/vite-loader.js' ) ;
224
224
const file = pathToFileURL ( path . resolve ( CONFIG_FILE ) ) . toString ( ) ;
225
- return ( await loadServerFile ( file ) ) . default ;
225
+ return ( await loadServerModule < { default : Config } > ( file ) ) . default ;
226
226
}
Original file line number Diff line number Diff line change @@ -3,7 +3,11 @@ import type { RunnableDevEnvironment } from 'vite';
3
3
4
4
import { fileURLToFilePath } from '../utils/path.js' ;
5
5
6
- export const loadServerFile = async ( fileURL : string ) => {
6
+ export const loadServerModule = async < T > ( idOrFileURL : string ) : Promise < T > => {
7
+ if ( idOrFileURL === 'waku' || idOrFileURL . startsWith ( 'waku/' ) ) {
8
+ // HACK `external: ['waku']` doesn't do the same
9
+ return import ( idOrFileURL ) as T ;
10
+ }
7
11
const vite = await createViteServer ( {
8
12
server : { middlewareMode : true , watch : null } ,
9
13
appType : 'custom' ,
@@ -21,6 +25,10 @@ export const loadServerFile = async (fileURL: string) => {
21
25
) ;
22
26
const mod = await (
23
27
vite . environments . config as RunnableDevEnvironment
24
- ) . runner . import ( fileURLToFilePath ( fileURL ) ) ;
25
- return mod ;
28
+ ) . runner . import (
29
+ idOrFileURL . startsWith ( 'file://' )
30
+ ? fileURLToFilePath ( idOrFileURL )
31
+ : idOrFileURL ,
32
+ ) ;
33
+ return mod as T ;
26
34
} ;
You can’t perform that action at this time.
0 commit comments