Open bryphe opened 5 years ago
Example from @thangngoc89 on loading CMIs on demand:
(Add include JsooTop;
and run
- see jsooTop.cmis.js
loaded)
@thangngoc89 found the hook we can use for this: https://docs.mirage.io/ocaml/Env/Persistent_signature/index.html#val-load
and code snippet:
let backupLoad = Env.Persistent_signature.load^;
let myLoad = (name) => {
switch (backupLoad(name)) {
| Some(a) => a
| None => // Executing the external function to load the JS cmis script, and try again
}
}
Env.Persistent_signature.load := myLoad
The bundle size for our toplevel is pretty huge - clocking in at 7MB. This means initial load of the playground is very slow. Much of this is due to the compiled
CMI
files (which describe the interface of modules - used by the toplevel typechecker).We package a pretty huge amount of these - for the OCaml stdlib, for Revery, and for Revery's dependencies. Ideally, we could load them 'on-demand' so we don't need to download a giant bundle.
A way to do this would be:
jsoo_mkcmis
tool to create a JS CMI