-
Notifications
You must be signed in to change notification settings - Fork 191
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
Make it possible to link runtime JavaScript file together with OCaml libraries #1509
Conversation
e0ec54e
to
d540844
Compare
I've tried out this branch and I still get runtime errors when loading the js files: ![]() I have modified the command line invokation of jsoo like this: ocaml-doc/voodoo@43bdc26 Object.assign
(globalThis.jsoo_runtime,
{caml_make_local_vect: caml_make_local_vect,
Base_unsafe_create_local_bytes: Base_unsafe_create_local_bytes,
caml_csel_value: caml_csel_value,
Base_am_testing: Base_am_testing,
Base_hash_double: Base_hash_double,
Base_hash_string: Base_hash_string,
Base_int_math_int64_pow_stub: Base_int_math_int64_pow_stub,
Base_int_math_int_pow_stub: Base_int_math_int_pow_stub,
Base_int_math_int64_ctz: Base_int_math_int64_ctz,
Base_int_math_nativeint_ctz: Base_int_math_nativeint_ctz,
Base_int_math_int_ctz: Base_int_math_int_ctz,
Base_int_math_int32_ctz: Base_int_math_int32_ctz,
Base_int_math_int64_clz: Base_int_math_int64_clz,
Base_int_math_nativeint_clz: Base_int_math_nativeint_clz,
Base_int_math_int_clz: Base_int_math_int_clz,
Base_int_math_int32_clz: Base_int_math_int32_clz,
Base_caml_exn_is_most_recent_exn: Base_caml_exn_is_most_recent_exn,
Base_clear_caml_backtrace_pos: Base_clear_caml_backtrace_pos,
Base_int_math_int_popcount: Base_int_math_int_popcount}); So does that mean everything is okay up to here and the error is caused by the toplevel?
I checked the wrapping functions are correct. @vouillon is there something else I should check, or is there something that can make the debugging easier? Thanks! |
@gpetiot It is not clear to me whether the error happens while loading a module or afterwards. Maybe you can have some debug output before and after a module is loaded. This is here, right? Are you able to load a module that does not contain any JavaScript code? I would expect the error to happen on the worker side, but it seems to happen on the playground. But maybe something went wrong on the worker and the playground got a bogus message from the worker? You should make sure your code is compiled with |
@gpetiot, can you describe the build and loading process a bit.
|
@hhugo I think the code for loading cma.js files is here: |
@vouillon I added some debug output in js_top_worker (jonludlam/js_top_worker@main...gpetiot:js_top_worker:debug-toplevel) but it doesn't show up in the browser debug console. I also checked that there is no minify and that we compile with @hhugo the toplevel is built at the same time as ocamlorg's playground (https://github.com/ocaml/ocaml.org/blob/main/playground/src/dune) from what I understand. The cma/cmi files are indeed linked during the toplevel initialization: https://github.com/gpetiot/ocaml.org/blob/pkg-toplevel/playground/src/main.ml#L48-L51 in the playground. That works fine when a package doesn't need a Is there a way to support this workflow in the future, or is there a technical obstacle? This is an objective we have for both the tooling team and the ocaml.org team so we would really like to make it happen. edit: I've summarized all the infos from issues/PRs/offline discussions in https://hackmd.io/@gpetiot/ByRuo1JlT to share with Tarides' tooling team |
@gpetiot, it would be much easier to validate this workflow with a simpler setup (E.g. Not using web workers) |
@gpetiot I'm trying to reproduce your issue, but I get this error when running
It seems
I would have expected this command to get the list of runtime files:
And this one to get the directory in which these files can be found:
|
The To get the path of all js files for a set of findlib packages, you can use
|
@vouillon, are you using an unreleased version of dune by any chance ? It is the unreleased dune.3.11 ocaml/opam-repository#24510 that stop emitting the |
@gpetiot, have you made any progress ? |
No I didn't make any progress since my last comment. My team is deprioritizing this for the moment. I will keep trying to fix this on the side, if someone finds a workaround I'm all ears :) |
I took a look at this. It seems to me that it would be simpler to also embed cmis files together with the runtime. |
I've pushed a few changes.
All this is still WIP and needs to be cleaned up but should unlock @gpetiot |
d652481
to
5f693e2
Compare
5f693e2
to
a89faae
Compare
a89faae
to
32256d6
Compare
I've rebased this PR
@vouillon, would you have time to make a pass of review ? |
…ith OCaml libraries Use: js_of_ocaml --toplevel --no-runtime runtime.js library.cma
CHANGES: ## Features/Changes * Library: new Typed_array.Bytes module. ## Bug fixes * Compiler: fix ocsigen/js_of_ocaml#1509
Quick hack to make it possible to include some JavaScript files when compiling an OCaml library.
For now, one has to pass the
--linkall
and--no-runtime
flags:At the moment, the generated code uses some ECMAScript 6 features.
Trying to address #1508