Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion sites/svelte.dev/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
## Running locally

Setup a database on [Supabase](https://supabase.com) with the instructions [here](../../db) and set the corresponding environment variables.
A local database is only required in dev mode if you want to test reading and writing saved REPLs on it. Without a local database in dev mode, the REPL will be able to load saved REPLs from the production database, but not save them.

Note also that in dev mode, the REPL will currently only work in Chrome, [as noted in the Vite documentation](https://vitejs.dev/guide/features.html#web-workers), pending support in Firefox for `import` statements in web workers.

If you do want to use a database, set it up on [Supabase](https://supabase.com) with the instructions [here](../../db) and set the corresponding environment variables.

Run the site sub-project:

Expand Down
8 changes: 5 additions & 3 deletions sites/svelte.dev/src/lib/db/client.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { dev } from '$app/env';
import { createClient } from '@supabase/supabase-js';

const SUPABASE_URL = process.env['SUPABASE_URL'];
const SUPABASE_KEY = process.env['SUPABASE_KEY'];
const SUPABASE_URL = process.env.SUPABASE_URL;
const SUPABASE_KEY = process.env.SUPABASE_KEY;

export const client = createClient(SUPABASE_URL, SUPABASE_KEY, { fetch });
export const client =
(!dev || (SUPABASE_URL && SUPABASE_KEY)) && createClient(SUPABASE_URL, SUPABASE_KEY, { fetch });
8 changes: 8 additions & 0 deletions sites/svelte.dev/src/routes/repl/[id]/index.json.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { dev } from '$app/env';
import { client } from '$lib/db/client';
import * as gist from '$lib/db/gist';
import { API_BASE } from '$lib/env';

Expand Down Expand Up @@ -58,6 +60,12 @@ export async function get({ params }) {
};
}

if (dev && !client) {
// in dev with no local Supabase configured, proxy to production
// this lets us at least load saved REPLs
return fetch(`https://svelte.dev/repl/${params.id}.json`);
}

const app = await gist.read(params.id);

if (!app) {
Expand Down