From 48202597de47aa657c0131b48c44b96427a86871 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Wed, 10 Apr 2024 12:30:28 -0400 Subject: [PATCH] chore: allow preview site to work offline in local dev (#11091) --- sites/svelte-5-preview/src/lib/workers/bundler/index.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sites/svelte-5-preview/src/lib/workers/bundler/index.js b/sites/svelte-5-preview/src/lib/workers/bundler/index.js index 80e14badbf..5a289fff7d 100644 --- a/sites/svelte-5-preview/src/lib/workers/bundler/index.js +++ b/sites/svelte-5-preview/src/lib/workers/bundler/index.js @@ -260,6 +260,9 @@ async function get_bundle(uid, mode, cache, local_files_lookup) { name: 'svelte-repl', async resolveId(importee, importer) { if (uid !== current_id) throw ABORT; + + if (importee === 'esm-env') return importee; + const v5 = is_v5(); const v4 = !v5 && is_v4(); @@ -358,6 +361,10 @@ async function get_bundle(uid, mode, cache, local_files_lookup) { async load(resolved) { if (uid !== current_id) throw ABORT; + if (resolved === 'esm-env') { + return `export const BROWSER = true; export const DEV = true`; + } + const cached_file = local_files_lookup.get(resolved); if (cached_file) return cached_file.source;