From 52dac8f2a7db7bafc656f156a915c3a43383865e Mon Sep 17 00:00:00 2001 From: Richard Harris Date: Sun, 17 Mar 2019 16:51:19 -0400 Subject: [PATCH] rebundle when files are created/renamed --- site/src/components/Repl/Input/ComponentSelector.svelte | 4 +++- site/src/components/Repl/index.svelte | 9 +++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/site/src/components/Repl/Input/ComponentSelector.svelte b/site/src/components/Repl/Input/ComponentSelector.svelte index 7933306b0a..6c30c34eba 100644 --- a/site/src/components/Repl/Input/ComponentSelector.svelte +++ b/site/src/components/Repl/Input/ComponentSelector.svelte @@ -5,7 +5,7 @@ export let handle_select; - const { components, selected, request_focus } = getContext('REPL'); + const { components, selected, request_focus, rebundle } = getContext('REPL'); let editing = null; @@ -35,6 +35,8 @@ // focus the editor, but wait a beat (so key events aren't misdirected) setTimeout(request_focus); + + rebundle(); } function remove(component) { diff --git a/site/src/components/Repl/index.svelte b/site/src/components/Repl/index.svelte index aa9a9fed93..1a750cceb2 100644 --- a/site/src/components/Repl/index.svelte +++ b/site/src/components/Repl/index.svelte @@ -59,11 +59,17 @@ let module_editor; let output; + function rebundle() { + workers.bundler.postMessage({ type: 'bundle', components: $components }); + } + setContext('REPL', { components, selected, bundle, + rebundle, + navigate: item => { const match = /^(.+)\.(\w+)$/.exec(item.filename); if (!match) return; // ??? @@ -93,8 +99,7 @@ // recompile selected component output.update($selected); - // regenerate bundle (TODO do this in a separate worker?) - workers.bundler.postMessage({ type: 'bundle', components: $components }); + rebundle(); dispatch('change', { components: $components