@@ -22,14 +22,15 @@ export const knownSvelteConfigNames = [
22
22
// also use timestamp query to avoid caching on reload
23
23
const dynamicImportDefault = new Function (
24
24
'path' ,
25
- 'return import(path + "?t=" + Date.now()).then(m => m.default)'
25
+ 'timestamp' ,
26
+ 'return import(path + "?t=" + timestamp).then(m => m.default)'
26
27
) ;
27
28
28
29
export async function loadSvelteConfig (
29
- viteConfig : UserConfig ,
30
- inlineOptions : Partial < Options >
30
+ viteConfig ? : UserConfig ,
31
+ inlineOptions ? : Partial < Options >
31
32
) : Promise < Partial < Options > | undefined > {
32
- if ( inlineOptions . configFile === false ) {
33
+ if ( inlineOptions ? .configFile === false ) {
33
34
return ;
34
35
}
35
36
const configFile = findConfigToLoad ( viteConfig , inlineOptions ) ;
@@ -38,7 +39,10 @@ export async function loadSvelteConfig(
38
39
// try to use dynamic import for svelte.config.js first
39
40
if ( configFile . endsWith ( '.js' ) || configFile . endsWith ( '.mjs' ) ) {
40
41
try {
41
- const result = await dynamicImportDefault ( pathToFileURL ( configFile ) . href ) ;
42
+ const result = await dynamicImportDefault (
43
+ pathToFileURL ( configFile ) . href ,
44
+ fs . statSync ( configFile ) . mtimeMs
45
+ ) ;
42
46
if ( result != null ) {
43
47
return {
44
48
...result ,
@@ -83,9 +87,9 @@ export async function loadSvelteConfig(
83
87
}
84
88
}
85
89
86
- function findConfigToLoad ( viteConfig : UserConfig , inlineOptions : Partial < Options > ) {
87
- const root = viteConfig . root || process . cwd ( ) ;
88
- if ( inlineOptions . configFile ) {
90
+ function findConfigToLoad ( viteConfig ? : UserConfig , inlineOptions ? : Partial < Options > ) {
91
+ const root = viteConfig ? .root || process . cwd ( ) ;
92
+ if ( inlineOptions ? .configFile ) {
89
93
const abolutePath = path . isAbsolute ( inlineOptions . configFile )
90
94
? inlineOptions . configFile
91
95
: path . resolve ( root , inlineOptions . configFile ) ;
0 commit comments