diff --git a/cli/index.d.ts b/cli/index.d.ts index 16e070529e..58c7fb4ef6 100644 --- a/cli/index.d.ts +++ b/cli/index.d.ts @@ -240,7 +240,8 @@ export function createMemoryStream(fn?: (chunk: Uint8Array | string) => void): M /** Compatible TypeScript compiler options for syntax highlighting etc. */ export const tscOptions: Record; -import { Program, Parser, Module } from "../src"; +import binaryen from "../lib/binaryen"; +import { Program, Parser } from "../src"; /** Compiler transform base class. */ export abstract class Transform { @@ -248,6 +249,9 @@ export abstract class Transform { /** Program reference. */ readonly program: Program; + /** Binaryen reference. */ + readonly binaryen: typeof binaryen; + /** Base directory. */ readonly baseDir: string; @@ -276,5 +280,5 @@ export abstract class Transform { afterInitialize?(program: Program): void | Promise; /** Called when compilation is complete, before the module is being validated. */ - afterCompile?(module: Module): void | Promise; + afterCompile?(module: binaryen.Module): void | Promise; } diff --git a/cli/index.js b/cli/index.js index 91634a8c01..b7b4a836e5 100644 --- a/cli/index.js +++ b/cli/index.js @@ -450,6 +450,7 @@ export async function main(argv, options) { if (typeof transform === "function") { Object.assign(transform.prototype, { program, + binaryen, baseDir, stdout, stderr, diff --git a/scripts/build-dts.js b/scripts/build-dts.js index 07215c9be9..0493075824 100644 --- a/scripts/build-dts.js +++ b/scripts/build-dts.js @@ -373,9 +373,13 @@ export function generateCli() { prefix, stdout, resolveModuleImport: ({ importedModuleId, currentModuleId }) => { - return currentModuleId == "cli/index" && importedModuleId == "../src" - ? prefix + "/src/index" - : null; + if (currentModuleId == "cli/index" && importedModuleId == "../src") + return prefix + "/src/index"; + + if (importedModuleId == "binaryen") + return "binaryen"; + + return null; }, });