Stream: jco

Topic: Difficulties getting started with jco


view this post on Zulip Leon Thomm (Jan 31 2025 at 15:31):

Above error is gone since abandoning aforementioned React tooling. To avoid clutter, I will recycle this thread.

view this post on Zulip Leon Thomm (Jan 31 2025 at 15:31):

The TypeScript interface files generated by jco's transpiler include things like:

export namespace MyNamespaceStuffMyComponent {
  export { MyResourceType };
}
export class MyResourceType {
  ...
}

When I import this file, I see errors. E.g., with Parcel

@parcel/transformer-js: ESM-style module declarations are not permitted in a namespace.

A quick search suggests the above TypeScript code is indeed invalid. Have I missed anything?

view this post on Zulip Victor Adossi (Jan 31 2025 at 17:20):

Hey Leon -- glad you were able to solve some issues with the webpack setup!

view this post on Zulip Victor Adossi (Jan 31 2025 at 17:21):

I think it's worth filing a bug for that on the jco with an example WIT interface and how you were planning on using it.

As far as building components, rollup has been used successfully before to put stuff together

view this post on Zulip Victor Adossi (Jan 31 2025 at 17:22):

There's also the new jco guest-types command, that will specifically not generate a namespace but rather a declare module statement

view this post on Zulip Leon Thomm (Jan 31 2025 at 18:11):

I think it's worth filing a bug for that on the jco with an example WIT interface and how you were planning on using it.

will do, although I still think I'm missing something since this makes it impossible for me to transpile any non-trivial components and I think this issue should have come up long before

As far as building components, rollup has been used successfully before to put stuff together

Interesting. I also tried bundling using Vite, which runs into a Rollup error for presumably the same reason.

view this post on Zulip Victor Adossi (Jan 31 2025 at 19:21):

Interesting -- here's an example that hopefully should help:

https://github.com/wasmCloud/typescript/tree/main/examples/components/http-password-checker

Full disclosure I work for Cosmonic which develops CNCF wasmCloud, but I made that repo as an example of how components should work with node based resolution, TS, and bundling

It doesn't have the nice new jco guest-types usage yet, so it's actually still using namespaces (awkwardly), but hopefully it's a reasonable starting point.

Contribute to wasmCloud/typescript development by creating an account on GitHub.

view this post on Zulip Leon Thomm (Jan 31 2025 at 19:52):

Looks like a good example, thanks! I will have a closer look hopefully soon.


Last updated: Feb 27 2025 at 23:03 UTC