Skip to content

Commit b994d1d

Browse files
authored
fix: better cache, avoid tailwind crashing everything (#1411)
better cache, avoid tailwind crashing everything
1 parent 9956e56 commit b994d1d

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

packages/repl/src/lib/workers/bundler/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,11 @@ async function get_bundle(
457457
if (id === `${VIRTUAL}/${ESM_ENV}`) return;
458458
if (id.endsWith('.svelte')) return;
459459

460-
add_tailwind_candidates(this.parse(code));
460+
try {
461+
// Don't let a parser/tailwind error crash the bundler
462+
// Can happen for files that begin with a bash shebang
463+
add_tailwind_candidates(this.parse(code));
464+
} catch {}
461465
}
462466
}
463467
],

packages/repl/src/lib/workers/compiler/index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ self.window = self;
1010

1111
declare var self: Window & typeof globalThis & { svelte: typeof import('svelte/compiler') };
1212

13-
const cache: Record<string, any> = {};
13+
const cache: Record<string, Promise<any>> = {};
1414

1515
addEventListener('message', async (event) => {
1616
const { id, file, version, options } = event.data as {
@@ -20,7 +20,11 @@ addEventListener('message', async (event) => {
2020
options: ExposedCompilerOptions;
2121
};
2222

23-
const { can_use_experimental_async, svelte } = (cache[version] ??= await load_svelte(version));
23+
cache[version] ??= load_svelte(version);
24+
cache[version].catch(() => {
25+
delete cache[version];
26+
});
27+
const { can_use_experimental_async, svelte } = await cache[version];
2428

2529
if (!file.name.endsWith('.svelte') && !svelte.compileModule) {
2630
// .svelte.js file compiled with Svelte 3/4 compiler

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy