Skip to content

Commit

Permalink
fix: surface frame on failed Svelte compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
benmccann authored and mihar-22 committed Sep 19, 2021
1 parent cc3e448 commit a747d96
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions src/transformer.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,26 @@ const process = (source, filename, jestOptions) => {
const compiler = (format, options = {}, filename, processedCode, processedMap) => {
const { debug, compilerOptions } = options

const result = svelte.compile(processedCode, {
filename: basename(filename),
css: true,
accessors: true,
dev: true,
format,
sourcemap: processedMap,
...compilerOptions
})
let result;

try {
result = svelte.compile(processedCode, {
filename: basename(filename),
css: true,
accessors: true,
dev: true,
format,
sourcemap: processedMap,
...compilerOptions
})
} catch(error) {
let msg = error.message;
if (error.frame) {
msg += '\n' + error.frame;
}
console.error(msg);
throw error;
}

if (debug) {
console.log(result.js.code)
Expand Down

0 comments on commit a747d96

Please sign in to comment.