@@ -22,14 +22,15 @@ export const knownSvelteConfigNames = [
2222// also use timestamp query to avoid caching on reload
2323const dynamicImportDefault = new Function (
2424'path' ,
25- 'return import(path + "?t=" + Date.now()).then(m => m.default)'
25+ 'timestamp' ,
26+ 'return import(path + "?t=" + timestamp).then(m => m.default)'
2627) ;
2728
2829export async function loadSvelteConfig (
29- viteConfig : UserConfig ,
30- inlineOptions : Partial < Options >
30+ viteConfig ? : UserConfig ,
31+ inlineOptions ? : Partial < Options >
3132) : Promise < Partial < Options > | undefined > {
32- if ( inlineOptions . configFile === false ) {
33+ if ( inlineOptions ? .configFile === false ) {
3334return ;
3435}
3536const configFile = findConfigToLoad ( viteConfig , inlineOptions ) ;
@@ -38,7 +39,10 @@ export async function loadSvelteConfig(
3839// try to use dynamic import for svelte.config.js first
3940if ( configFile . endsWith ( '.js' ) || configFile . endsWith ( '.mjs' ) ) {
4041try {
41- const result = await dynamicImportDefault ( pathToFileURL ( configFile ) . href ) ;
42+ const result = await dynamicImportDefault (
43+ pathToFileURL ( configFile ) . href ,
44+ fs . statSync ( configFile ) . mtimeMs
45+ ) ;
4246if ( result != null ) {
4347return {
4448...result ,
@@ -83,9 +87,9 @@ export async function loadSvelteConfig(
8387}
8488}
8589
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 ) {
8993const abolutePath = path . isAbsolute ( inlineOptions . configFile )
9094? inlineOptions . configFile
9195: path . resolve ( root , inlineOptions . configFile ) ;
0 commit comments