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
5 changes: 5 additions & 0 deletions .changeset/brave-fans-sneeze.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix: add empty stack to `CompileDiagnostic` to show error on build
3 changes: 3 additions & 0 deletions packages/svelte/src/compiler/utils/compile_diagnostic.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ function get_code_frame(source, line, column) {
* @typedef {{
* code: string;
* message: string;
* stack?: string;
* filename?: string;
* start?: Location;
* end?: Location;
Expand All @@ -50,6 +51,8 @@ function get_code_frame(source, line, column) {
/** @implements {ICompileDiagnostic} */
export class CompileDiagnostic {
name = 'CompileDiagnostic';
// adding an empty stack so that vite will show the file and frame during build
stack = '';

/**
* @param {string} code
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export default test({
^`,
message: 'Unexpected end of input',
name: 'CompileError',
stack: '',
position: [30, 30],
start: {
character: 30,
Expand Down
2 changes: 2 additions & 0 deletions packages/svelte/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1458,6 +1458,7 @@ declare module 'svelte/compiler' {
type ICompileDiagnostic = {
code: string;
message: string;
stack?: string;
filename?: string;
start?: Location;
end?: Location;
Expand Down Expand Up @@ -2286,6 +2287,7 @@ declare module 'svelte/types/compiler/interfaces' {
type ICompileDiagnostic = {
code: string;
message: string;
stack?: string;
filename?: string;
start?: Location;
end?: Location;
Expand Down