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

Web failing to instantiate #16

Open
kayhhh opened this issue Jun 18, 2024 · 1 comment
Open

Web failing to instantiate #16

kayhhh opened this issue Jun 18, 2024 · 1 comment

Comments

@kayhhh
Copy link

kayhhh commented Jun 18, 2024

I have a simple schema:

package example:schema;

world my-world {
  export my-interface;
}

interface my-interface {
  resource my-res {
    constructor();
    my-method: func(value: f32);
  }
}

I am able to use it in native builds, but run into an error with the web build:
Asynchronously instantiate main module TypeError: import object field '[export]example:schema/my-interface' is not an Object

Full code: https://github.com/kayhhh/wasm-bridge-example/tree/5e9165141f47344b75b82644f63f5db0430fcaed

I have gotten some of the test examples in this repo working, but with certain schemas like this I get errors.

@kayhhh
Copy link
Author

kayhhh commented Jun 19, 2024

Hmm, working backwards from a working example, it looks like the following WIT is good:

package component-test:wit-protocol;

interface companies {
  resource company-res {
    constructor(name: string, max-salary: u32);
    get-name: func() -> string;
    set-name: func(name: string);
    get-max-salary: func() -> u32;
  }
}

interface employees {
  resource employee-res {
    constructor(name: string, min-salary: u32);
    get-name: func() -> string;
    set-name: func(name: string);
    get-min-salary: func() -> u32;
  }
}

world resources {
  import companies;
  
  export employees;

  import log: func(message: string);
}

But if I remove import companies from resources, and its associated host implementation, I start getting the same not an Object error in web.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant