diff --git a/.changeset/little-ligers-look.md b/.changeset/little-ligers-look.md
new file mode 100644
index 000000000..62a6686f8
--- /dev/null
+++ b/.changeset/little-ligers-look.md
@@ -0,0 +1,5 @@
+---
+'@sveltejs/vite-plugin-svelte': patch
+---
+
+update svelte-hmr and enable partial hmr accept by default (fixes #134)
diff --git a/packages/e2e-tests/hmr/__tests__/hmr.spec.ts b/packages/e2e-tests/hmr/__tests__/hmr.spec.ts
index d1fc383f9..241ed8ff5 100644
--- a/packages/e2e-tests/hmr/__tests__/hmr.spec.ts
+++ b/packages/e2e-tests/hmr/__tests__/hmr.spec.ts
@@ -4,6 +4,7 @@ import {
getEl,
getText,
editFileAndWaitForHmrComplete,
+ hmrCount,
untilMatches,
sleep,
getColor,
@@ -54,6 +55,10 @@ test('should respect transforms', async () => {
if (!isBuild) {
describe('hmr', () => {
const updateHmrTest = editFileAndWaitForHmrComplete.bind(null, 'src/components/HmrTest.svelte');
+ const updateModuleContext = editFileAndWaitForHmrComplete.bind(
+ null,
+ 'src/components/partial-hmr/ModuleContext.svelte'
+ );
const updateApp = editFileAndWaitForHmrComplete.bind(null, 'src/App.svelte');
const updateStore = editFileAndWaitForHmrComplete.bind(null, 'src/stores/hmr-stores.js');
@@ -136,6 +141,18 @@ if (!isBuild) {
expect(await getText(`#hmr-test-3 .counter`)).toBe('0');
});
+ test('should work when editing script context="module"', async () => {
+ expect(await getText(`#hmr-with-context`)).toContain('x=0 y=1 slot=1');
+ expect(await getText(`#hmr-without-context`)).toContain('x=0 y=1 slot=');
+ expect(hmrCount('UsingNamed.svelte'), 'updates for UsingNamed.svelte').toBe(0);
+ expect(hmrCount('UsingDefault.svelte'), 'updates for UsingDefault.svelte').toBe(0);
+ await updateModuleContext((content) => content.replace('y = 1', 'y = 2'));
+ expect(await getText(`#hmr-with-context`)).toContain('x=0 y=2 slot=2');
+ expect(await getText(`#hmr-without-context`)).toContain('x=0 y=2 slot=');
+ expect(hmrCount('UsingNamed.svelte'), 'updates for UsingNamed.svelte').toBe(1);
+ expect(hmrCount('UsingDefault.svelte'), 'updates for UsingDefault.svelte').toBe(0);
+ });
+
test('should work with emitCss: false in vite config', async () => {
await editViteConfig((c) => c.replace('svelte()', 'svelte({emitCss:false})'));
expect(await getText(`#hmr-test-1 .counter`)).toBe('0');
diff --git a/packages/e2e-tests/hmr/src/App.svelte b/packages/e2e-tests/hmr/src/App.svelte
index 995c1e178..399824ca6 100644
--- a/packages/e2e-tests/hmr/src/App.svelte
+++ b/packages/e2e-tests/hmr/src/App.svelte
@@ -2,6 +2,7 @@
import StaticImport from './components/StaticImport.svelte';
import Dependency from 'e2e-test-dep-svelte-simple';
import HmrTest from './components/HmrTest.svelte';
+ import PartialHmr from './components/partial-hmr/PartialHmr.svelte';
const jsTransform = '__JS_TRANSFORM_1__';
let dynamicImportComponent;
function importDynamic() {
@@ -25,6 +26,9 @@
+
+
+