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

Switch over to the WABT bindings generated by wit-pack #40

Merged
merged 3 commits into from
Nov 11, 2022

Conversation

Michael-F-Bryan
Copy link

No description provided.

@Michael-F-Bryan
Copy link
Author

Michael-F-Bryan commented Oct 3, 2022

@Michael-F-Bryan
Copy link
Author

I've updated this to use the wasmer/wabt package from wapm.io on my computer, but it looks like I've lost write access to the repo. @syrusakbary can you add me to the repo again?

Also, how do I test this?

@Michael-F-Bryan Michael-F-Bryan marked this pull request as ready for review November 1, 2022 07:44
@syrusakbary
Copy link
Member

npm run test should test things locally @Michael-F-Bryan

@syrusakbary
Copy link
Member

It currently fails:

➜  vscode-wasm git:(generated-bindings) npm run test

> [email protected] test
> npm run compile && node ./node_modules/vscode/bin/test


> [email protected] compile
> tsc -p ./

node_modules/@wasmer/wabt/src/bindings/bindings/bindings.d.ts:22:13 - error TS2503: Cannot find namespace 'WebAssembly'.

22   instance: WebAssembly.Instance;
               ~~~~~~~~~~~

node_modules/@wasmer/wabt/src/bindings/bindings/bindings.d.ts:79:11 - error TS2503: Cannot find namespace 'WebAssembly'.

79   module: WebAssembly.Module | BufferSource | Promise<Response> | Response | WebAssembly.Instance,
             ~~~~~~~~~~~

node_modules/@wasmer/wabt/src/bindings/bindings/bindings.d.ts:79:32 - error TS2304: Cannot find name 'BufferSource'.

79   module: WebAssembly.Module | BufferSource | Promise<Response> | Response | WebAssembly.Instance,
                                  ~~~~~~~~~~~~

node_modules/@wasmer/wabt/src/bindings/bindings/bindings.d.ts:79:55 - error TS2304: Cannot find name 'Response'.

79   module: WebAssembly.Module | BufferSource | Promise<Response> | Response | WebAssembly.Instance,
                                                         ~~~~~~~~

node_modules/@wasmer/wabt/src/bindings/bindings/bindings.d.ts:79:67 - error TS2304: Cannot find name 'Response'.

79   module: WebAssembly.Module | BufferSource | Promise<Response> | Response | WebAssembly.Instance,
                                                                     ~~~~~~~~

node_modules/@wasmer/wabt/src/bindings/bindings/bindings.d.ts:79:78 - error TS2503: Cannot find namespace 'WebAssembly'.

79   module: WebAssembly.Module | BufferSource | Promise<Response> | Response | WebAssembly.Instance,
                                                                                ~~~~~~~~~~~

node_modules/@wasmer/wabt/src/bindings/index.d.ts:3:10 - error TS2440: Import declaration conflicts with local declaration of 'Bindings'.

3 import { Bindings } from "./bindings/bindings";
           ~~~~~~~~

node_modules/@wasmer/wabt/src/bindings/index.d.ts:3:10 - error TS2652: Merged declaration 'Bindings' cannot include a default export declaration. Consider adding a separate 'export default Bindings' declaration instead.

3 import { Bindings } from "./bindings/bindings";
           ~~~~~~~~

node_modules/@wasmer/wabt/src/bindings/index.d.ts:10:14 - error TS2503: Cannot find namespace 'WebAssembly'.

10     imports: WebAssembly.Imports,
                ~~~~~~~~~~~

node_modules/@wasmer/wabt/src/bindings/index.d.ts:15:13 - error TS2503: Cannot find namespace 'WebAssembly'.

15     module: WebAssembly.Module,
               ~~~~~~~~~~~

node_modules/@wasmer/wabt/src/bindings/index.d.ts:25:22 - error TS2652: Merged declaration 'Bindings' cannot include a default export declaration. Consider adding a separate 'export default Bindings' declaration instead.

25 export default class Bindings {
                        ~~~~~~~~

node_modules/@wasmer/wabt/src/index.d.ts:14:29 - error TS2503: Cannot find namespace 'WebAssembly'.

14     imports: Record<string, WebAssembly.ModuleImports>,
                               ~~~~~~~~~~~

node_modules/@wasmer/wabt/src/index.d.ts:19:13 - error TS2503: Cannot find namespace 'WebAssembly'.

19     module: WebAssembly.Module,
               ~~~~~~~~~~~


Found 13 errors.

@syrusakbary
Copy link
Member

I've added the "dom" lib to the lib field inside of tsconfig.json.

And then we got other error:

➜  vscode-wasm git:(generated-bindings) npm run test

> [email protected] test
> npm run compile && node ./node_modules/vscode/bin/test


> [email protected] compile
> tsc -p ./

node_modules/@wasmer/wabt/src/bindings/index.d.ts:3:10 - error TS2440: Import declaration conflicts with local declaration of 'Bindings'.

3 import { Bindings } from "./bindings/bindings";
           ~~~~~~~~

node_modules/@wasmer/wabt/src/bindings/index.d.ts:3:10 - error TS2652: Merged declaration 'Bindings' cannot include a default export declaration. Consider adding a separate 'export default Bindings' declaration instead.

3 import { Bindings } from "./bindings/bindings";
           ~~~~~~~~

node_modules/@wasmer/wabt/src/bindings/index.d.ts:25:22 - error TS2652: Merged declaration 'Bindings' cannot include a default export declaration. Consider adding a separate 'export default Bindings' declaration instead.

25 export default class Bindings {
                        ~~~~~~~~


Found 3 errors.

After fixing the file manually importing Bindings as BaseBindings I got things compiling:

// @ts-ignore
import { Wasi } from "@wasmer/wasi";
import { Bindings as BaseBindings } from "./bindings/bindings";

/**
 * Options used when initializing the bindings.
 */
export type LoadOptions = {
    /** Additional imports to be provided to the WebAssembly module */
    imports: WebAssembly.Imports,
    /**
     * A user-specified WebAssembly module to use instead of the one bundled
     * with this package.
     */
    module: WebAssembly.Module,
};
/**
* Extended options used when loading a WASI library.
 */
export type WasiLoadOptions = LoadOptions & {
    /** An initialized `@wasmer/wasi` object. */
    wasi: Wasi,
};

export default class Bindings {
    bindings(options?: Partial<WasiLoadOptions>): Promise<BaseBindings>;
}

@Michael-F-Bryan
Copy link
Author

The npm run test command currently fails because we've got no test/ directory. I'm assuming that just means someone deleted the repo's tests in the past. I'm inclined to merge this as it is now because everything builds, and I'll fix #41 in a separate PR.

@Michael-F-Bryan Michael-F-Bryan merged commit 5777736 into master Nov 11, 2022
@Michael-F-Bryan Michael-F-Bryan deleted the generated-bindings branch November 11, 2022 15:02
@Michael-F-Bryan Michael-F-Bryan added the sprint-mvp Wasmer Pack's MVP sprint label Nov 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sprint-mvp Wasmer Pack's MVP sprint
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants