Closed Phault closed 2 months ago
Thanks for reporting. It should be mapping them by name but perhaps we have a regression here. There is a trick we do where we need to sort the exports then map them by index. So there might be a regression there. We will look into it and fix.
Say I have the following two exports defined:
I bundle
src/index.ts
to/dist/index.js
with esbuild using cjs format and es2020 as target, then build the wasm using extism-js like with dist/index.js and src/index.d.ts.If I then call the
start
wasm export, surprise:end
will be logged:Part of the reason in this case, is that esbuild sorts the exports alphabetically in the module.exports object. So
end
is suddenly defined first, but it still points to theend
function nonetheless:Now the order in the declaration doesn't match module.exports though, so something in the wasm building step seems to rely on the order being 1:1.