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

The examples do not work outside of the bonsai project #41

Closed
dysinger opened this issue Oct 11, 2023 · 6 comments
Closed

The examples do not work outside of the bonsai project #41

dysinger opened this issue Oct 11, 2023 · 6 comments
Labels
forwarded-to-js-devs This report has been forwarded to Jane Street's internal review system.

Comments

@dysinger
Copy link

dysinger commented Oct 11, 2023

Here's the simplest example:

  • Set your switch up with the janestreet opam overlay
  • Copy ./examples/hello_world to your own project.
  • Add Bonsai as a dependency to your dune-based project
  • Build the project with dune

You'll end up with errors like the following:
image

@dysinger
Copy link
Author

I will make a reference to #24 here but that issue is over a year old and, I think, somewhat unrelated to current problems.

@github-iron github-iron added the forwarded-to-js-devs This report has been forwarded to Jane Street's internal review system. label Oct 11, 2023
@Enoumy
Copy link

Enoumy commented Oct 11, 2023

Hello!

Does changing them to intead use bonsai.web (intead of bonsai_web) and bonsai.ppx_bonsai (intead of ppx_bonsai) make things build?

My current understanding of how dune works is that libraries have two kinds of names; a "name" and a "public_name". Libraries within the same project can refer to things by their "name", but libraries outside of the project must refer to things via their "public_name". The public name for both of these is defined within [1] and [2]

I am not fully confident this fixes the build for your case (I'd still need to reproduce this locally), but please let us know/follow up if it does/doesn't.

[1] https://github.com/janestreet/bonsai/blob/master/ppx_bonsai/src/dune
[2] https://github.com/janestreet/bonsai/blob/master/web/dune

@dysinger
Copy link
Author

Thanks for the tip. I made those changes and some others and got the hello world example to work in my project.

image

Notice I had to add virtual_dom to the libraries in the dune file as well. Additionally, I had to add an open statement in main.ml for the library. After doing so it complied without error.

@Enoumy
Copy link

Enoumy commented Oct 24, 2023

As I think that your question has been answered, I will be closing this issue. Please feel free to re-open it if you have anything follow up question/want to re-open discussion. Thanks!

@Enoumy Enoumy closed this as completed Oct 24, 2023
@dysinger
Copy link
Author

I think it would be good to have clear examples that compile and work. That problem isn't solved and there isn't a ticket for it. @Enoumy

@TyOverby
Copy link
Member

The examples build if you're building them out of this repository. They do not work if you copy them into your own project. This is because they have different names that you can use to reference them in dune, and you just kinda need to know this. I agree it's not great, but it's not clear what changes should be made on our end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
forwarded-to-js-devs This report has been forwarded to Jane Street's internal review system.
Projects
None yet
Development

No branches or pull requests

4 participants