Skip to content

Commit

Permalink
chore: allow preview site to work offline in local dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich-Harris committed Apr 7, 2024
1 parent 6b7f116 commit 5419e25
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions sites/svelte-5-preview/src/lib/workers/bundler/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 5419e25

Please sign in to comment.