-
Notifications
You must be signed in to change notification settings - Fork 16
Description
Overview
Ran into this bug while adding new export to a wasm module written in the JS PDK. I forgot to update the .d.ts
file and ended up with a very difficult to triage bug. It may be easier to just check the exports in the compiled JS against the .d.ts
and throw an exception if they don't match.
Setup
// index.d.ts
declare module "main" {
export function pre(): I32;
export function post(): I32;
}
// index.ts
export function pre() {
// noop
console.log("I am pre");
}
export function chunk() {
// noop
console.log("I am chunk");
}
export function post() {
// noop
console.log("I am post");
}
Reproduction
Compiled using esbuild per the PDK guide. Call the compiled wasm module's pre and post methods from within an application. I used the node.js SDK for consistency in platform.
Expected
Calling the pre
and post
from within extism bindings (node.js) should output their corresponding strings.
Actual
- Logs
I am pre
- Logs
I am chunk
I can't say for sure what's happening here because I'm not sure at what point the .d.ts and exports are matched, but it seems like the order of functions inside of the index.ts
matters if the exports don't match the .d.ts
file.