Skip to content

Commit

Permalink
Merge pull request #76 from benmccann/frame
Browse files Browse the repository at this point in the history
Surface frame on failed Svelte compilation
  • Loading branch information
sebastianrothe authored Sep 15, 2021
2 parents 893065c + 8fa3b49 commit 08658d5
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 08658d5

Please sign in to comment.