Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Binaryen on transform #2832

Merged
merged 2 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions cli/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,14 +240,18 @@ export function createMemoryStream(fn?: (chunk: Uint8Array | string) => void): M
/** Compatible TypeScript compiler options for syntax highlighting etc. */
export const tscOptions: Record<string,unknown>;

import { Program, Parser, Module } from "../src";
import binaryen from "../lib/binaryen";
import { Program, Parser } from "../src";

/** Compiler transform base class. */
export abstract class Transform {

/** Program reference. */
readonly program: Program;

/** Binaryen reference. */
readonly binaryen: typeof binaryen;

/** Base directory. */
readonly baseDir: string;

Expand Down Expand Up @@ -276,5 +280,5 @@ export abstract class Transform {
afterInitialize?(program: Program): void | Promise<void>;

/** Called when compilation is complete, before the module is being validated. */
afterCompile?(module: Module): void | Promise<void>;
afterCompile?(module: binaryen.Module): void | Promise<void>;
}
1 change: 1 addition & 0 deletions cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,7 @@ export async function main(argv, options) {
if (typeof transform === "function") {
Object.assign(transform.prototype, {
program,
binaryen,
baseDir,
stdout,
stderr,
Expand Down
10 changes: 7 additions & 3 deletions scripts/build-dts.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
},
});

Expand Down
Loading