diff --git a/packages/alfa-cli/bin/alfa/command/audit/run.ts b/packages/alfa-cli/bin/alfa/command/audit/run.ts index a2cb2e913a..0fa52771e3 100644 --- a/packages/alfa-cli/bin/alfa/command/audit/run.ts +++ b/packages/alfa-cli/bin/alfa/command/audit/run.ts @@ -26,7 +26,7 @@ export const run: Command.Runner = async ({ flags, args: { url: target }, }) => { - const formatter = Formatter.load(flags.format); + const formatter = await Formatter.load(flags.format); if (formatter.isErr()) { return formatter; diff --git a/packages/alfa-formatter/package.json b/packages/alfa-formatter/package.json index 38d64dfb57..47b447ba03 100644 --- a/packages/alfa-formatter/package.json +++ b/packages/alfa-formatter/package.json @@ -19,8 +19,7 @@ ], "dependencies": { "@siteimprove/alfa-act": "^0.2.0", - "@siteimprove/alfa-result": "^0.2.0", - "@types/node": "^14.0.11" + "@siteimprove/alfa-result": "^0.2.0" }, "devDependencies": { "@siteimprove/alfa-test": "^0.2.0" diff --git a/packages/alfa-formatter/src/formatter.ts b/packages/alfa-formatter/src/formatter.ts index 09eb5384c5..1c4f545d57 100644 --- a/packages/alfa-formatter/src/formatter.ts +++ b/packages/alfa-formatter/src/formatter.ts @@ -1,18 +1,16 @@ -/// - import { Outcome } from "@siteimprove/alfa-act"; -import { Result, Ok, Err } from "@siteimprove/alfa-result"; +import { Result, Err } from "@siteimprove/alfa-result"; -export type Formatter = ( +export type Formatter = ( input: I, outcomes: Iterable> ) => string; export namespace Formatter { - export function load( + export async function load( name: string, defaultScope: string = "@siteimprove" - ): Result, string> { + ): Promise, string>> { let scope: string | undefined; if (name.startsWith("@")) { @@ -32,7 +30,9 @@ export namespace Formatter { for (const pattern of patterns) { try { - return Ok.of(require(pattern).default()); + const module = await import(pattern); + + return Result.of(module.default()); } catch { continue; }