Skip to content

Commit 9a75416

Browse files
committed
see if this speeds up things
1 parent 9f7ad72 commit 9a75416

File tree

1 file changed

+19
-2
lines changed
  • src/lib/client/adapters/webcontainer

1 file changed

+19
-2
lines changed

src/lib/client/adapters/webcontainer/index.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import { ready } from '../common/index.js';
66
let vm;
77
/** @type {Promise<import('$lib/types').Adapter> | undefined} */
88
let instance;
9+
/** @type {Map<string, string>} latest contents of some special files for comparison */
10+
const file_contents = new Map();
911

1012
/**
1113
* @param {import('$lib/types').Stub[]} stubs
@@ -35,6 +37,19 @@ async function _create(stubs) {
3537
/** @type {Set<string>} Paths of the currently loaded file stubs */
3638
let current = new Set();
3739

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+
3853
const tree = convert_stubs_to_tree(stubs);
3954

4055
const common = await ready;
@@ -192,10 +207,12 @@ async function _create(stubs) {
192207
}
193208
}
194209

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+
);
196213

214+
await vm.loadFiles(convert_stubs_to_tree(stubs));
197215
await promise;
198-
199216
await new Promise((f) => setTimeout(f, 200)); // wait for chokidar
200217

201218
resolve();

0 commit comments

Comments
 (0)