Skip to content

fix: convert compile error on hmr #592

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 22, 2023
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
5 changes: 5 additions & 0 deletions .changeset/small-oranges-give.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/vite-plugin-svelte': patch
---

show correct error overlay for compiler errors during hot update
3 changes: 2 additions & 1 deletion packages/vite-plugin-svelte/src/handle-hot-update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { log, logCompilerWarnings } from './utils/log';
import { SvelteRequest } from './utils/id';
import { VitePluginSvelteCache } from './utils/vite-plugin-svelte-cache';
import { ResolvedOptions } from './utils/options';
import { toRollupError } from './utils/error';

/**
* Vite-specific HMR handling
Expand Down Expand Up @@ -32,7 +33,7 @@ export async function handleHotUpdate(
cache.update(compileData);
} catch (e) {
cache.setError(svelteRequest, e);
throw e;
throw toRollupError(e, options);
}

const affectedModules = [...modules];
Expand Down
6 changes: 1 addition & 5 deletions packages/vite-plugin-svelte/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,7 @@ export function svelte(inlineOptions?: Partial<Options>): Plugin[] {
}
const svelteRequest = requestParser(ctx.file, false, ctx.timestamp);
if (svelteRequest) {
try {
return handleHotUpdate(compileSvelte, ctx, svelteRequest, cache, options);
} catch (e) {
throw toRollupError(e, options);
}
return handleHotUpdate(compileSvelte, ctx, svelteRequest, cache, options);
}
},
async buildEnd() {
Expand Down