Skip to content

Commit

Permalink
Merge pull request #246 from mainmatter/dbeer/240-improve-error-handl…
Browse files Browse the repository at this point in the history
…ing-of-async-transform

Improve error handling of the async transform
  • Loading branch information
paoloricciuti authored Dec 6, 2024
2 parents 7434ea0 + 2251c9d commit bf0c71b
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions packages/core/vite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type {
CallExpression,
FunctionExpression,
ImportDeclaration,
Program,
} from 'acorn';
import type { Plugin } from 'vite';

Expand All @@ -25,11 +26,16 @@ export async function asyncTransform(): Promise<Plugin> {
name: 'sheepdog-async-transform',
async transform(code, id) {
try {
const ast = parse(code, {
ecmaVersion: 'latest',
locations: true,
sourceType: 'module',
});
let ast: Program;
try {
ast = parse(code, {
ecmaVersion: 'latest',
locations: true,
sourceType: 'module',
});
} catch {
return;
}
let task_fn_name: string;
const transform_fn_names = new Set<string>();
// let's walk once to find the name (we were using a promise before but that's just messy)
Expand Down

0 comments on commit bf0c71b

Please sign in to comment.