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

Document how imports work #103

Open
rylev opened this issue Apr 10, 2024 · 4 comments
Open

Document how imports work #103

rylev opened this issue Apr 10, 2024 · 4 comments
Labels
documentation Improvements or additions to documentation

Comments

@rylev
Copy link

rylev commented Apr 10, 2024

As noted in #88, it is not obvious how imports work. While I understand the hesitation to document this extensively as things are likely to change in the future, it makes it very hard for new comers to ComponentizeJS to use the tool if there is absolutely no documentation about how to call imports.

@guybedford
Copy link
Collaborator

Yes, ideally this is also resolved by generating types or boilerplates via #48, as that would allow editor integration without needing to check reference documentation.

For reference documentation, the first step here is to fully document the WIT type structure used in the Jco project, for which I've posted bytecodealliance/jco#418.

With the WIT types fully defined there, the definition of imports here is then simply "import the corresponding WIT type by its fully qualified import name".

@rylev
Copy link
Author

rylev commented Apr 11, 2024

the definition of imports here is then simply "import the corresponding WIT type by its fully qualified import name".

I think this deserves to be documented now even before the other pieces are in place (albeit perhaps not so tersely as this particular description). From experience, once I know how to import a module that is generated from corresponding wit types, it's a lot easier to intuit how wit types are being translated into JavaScript syntax. The missing piece that took me the longest to figure out was what actually needs to go in the module string in an import statement. While the choice is obvious in hindsight, having it documented would have been very helpful even if a thorough explanation of how wit is translated into JavaScript was not included.

At the very least, including an import in the example would go a long way. At least then, it becomes possible to cargo cult.

@guybedford
Copy link
Collaborator

Good point, definitely, let's update the example to use an import.

@guybedford guybedford added the documentation Improvements or additions to documentation label Apr 11, 2024
@guybedford
Copy link
Collaborator

I've added a simple example here in 519256f.

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

No branches or pull requests

2 participants