Skip to content

Commit

Permalink
refactor(betterer 🔧): handle transpiling differently so can generate …
Browse files Browse the repository at this point in the history
…a hash for config files
  • Loading branch information
phenomnomnominal committed Oct 13, 2024
1 parent 49256dd commit cc799e8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
5 changes: 1 addition & 4 deletions packages/betterer/src/fs/import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ interface ModulePrivate {
}

type ESBuild = typeof import('esbuild');
type BuildResult = Awaited<ReturnType<ESBuild['build']>>;

export async function importTranspiledHashed(importPath: string): Promise<[unknown, string]> {
const esbuild = await importESBuild();
Expand Down Expand Up @@ -97,9 +96,7 @@ async function importFrom(importPath: string, esbuild: ESBuild): Promise<[unknow
const result = await importDefault(outfile);
return [result, hash];
} catch (error) {
const failure = error as BuildResult;
const [first] = failure.errors;
throw new BettererError(first ? first.text : (error as Error).message);
throw new BettererError((error as Error).message);
} finally {
try {
await cleanup();
Expand Down
3 changes: 2 additions & 1 deletion test/__snapshots__/config-invalid.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ Error: could not import config from "fixtures/config-invalid/.betterer.ts". 😔
Error: could not import "fixtures/config-invalid/.betterer.ts". 😔
Error: Unexpected end of file
Error: Build failed with 1 error:
fixtures/config-invalid/.betterer.ts:1:35: ERROR: Unexpected end of file
",
]
`;
3 changes: 2 additions & 1 deletion test/__snapshots__/config-no-esbuild.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ Error: could not import config from "fixtures/config-no-esbuild/.betterer.tsx".
Error: could not import "fixtures/config-no-esbuild/.betterer.tsx". 😔
Error: Expected identifier but found "{"
Error: Build failed with 1 error:
fixtures/config-no-esbuild/.betterer.tsx:4:1: ERROR: Expected identifier but found "{"
",
]
`;

0 comments on commit cc799e8

Please sign in to comment.