Open troederjs opened 3 months ago
First note that joo_global_object
should be avoided, support will be removed at some point. One should use globalThis
instead.
It seems to me that vscode-ocaml-platform is part of the problem here. It should not update the global object,it should defined its own stubs.
What is the correct way to access a JS stub without making it available on some global context like globalThis
?
https://ocsigen.org/js_of_ocaml/latest/manual/linker gives some information.
In short,
//Provides: customAdd
function customAdd(a,b){
return a + b
}
external add : int -> int -> int = "customAdd"
Describe the bug If two separate ocaml libraries have JS stubs which define the same symbol ion
joo_global_object
(e.g. two different versions of src-bindings/node/dune in the OCaml VSCode extension) they will conflict when both libraries are loaded by differentJs_of_ocaml
executable.This happens because
joo_global_object
is theglobalThis
, and so the two values override each other.Normally, when running a single application this is not a problem since we can control all the dependencies and ensure they don't conflict. But specifically in the case of the VSCode extension, this causes issues when there are two
Js_of_ocaml
extensions that use incompatible versions of the nodejs binding stubs.Expected behavior Both
Js_of_ocaml
executable should be able to run independently in the same JS environment.