@@ -6,6 +6,8 @@ import { ready } from '../common/index.js';
6
6
let vm ;
7
7
/** @type {Promise<import('$lib/types').Adapter> | undefined } */
8
8
let instance ;
9
+ /** @type {Map<string, string> } latest contents of some special files for comparison */
10
+ const file_contents = new Map ( ) ;
9
11
10
12
/**
11
13
* @param {import('$lib/types').Stub[] } stubs
@@ -35,6 +37,19 @@ async function _create(stubs) {
35
37
/** @type {Set<string> } Paths of the currently loaded file stubs */
36
38
let current = new Set ( ) ;
37
39
40
+ for ( const stub of stubs ) {
41
+ if (
42
+ stub . type === 'file' &&
43
+ ( stub . name === '/src/__client.js' ||
44
+ stub . name === '/src/app.html' ||
45
+ stub . name === '/package.json' ||
46
+ stub . name === '/vite.config.js' ||
47
+ stub . name === '/svelte.config.js' )
48
+ ) {
49
+ file_contents . set ( stub . name , stub . contents ) ;
50
+ }
51
+ }
52
+
38
53
const tree = convert_stubs_to_tree ( stubs ) ;
39
54
40
55
const common = await ready ;
@@ -192,10 +207,12 @@ async function _create(stubs) {
192
207
}
193
208
}
194
209
195
- await vm . loadFiles ( convert_stubs_to_tree ( stubs ) ) ;
210
+ stubs = stubs . filter (
211
+ ( stub ) => stub . type !== 'file' || file_contents . get ( stub . name ) !== stub . contents
212
+ ) ;
196
213
214
+ await vm . loadFiles ( convert_stubs_to_tree ( stubs ) ) ;
197
215
await promise ;
198
-
199
216
await new Promise ( ( f ) => setTimeout ( f , 200 ) ) ; // wait for chokidar
200
217
201
218
resolve ( ) ;
0 commit comments