-
Notifications
You must be signed in to change notification settings - Fork 197
Closed
Labels
Description
Describe the bug
Let's say we have the simplest possible OCaml program:
let () =
print_endline "Hello, World!"Which we compile using jsoo:
(executable
(name hello)
(modes js)
(modules hello)
(js_of_ocaml
(flags
--opt 3
--enable deadcode
--enable globaldeadcode
))
)Although the program performs no file operations, the generated code still requires node:fs and contains filesystem functions, even on the highest optimization level, even when asked to eliminate all dead code, even with --profile release.
This is extremely problematic for deployments to React Native platforms, where the module does not exist.
Expected behavior
Filesystem functions should not be included unless actually used.
As an alternative, the module could be loaded lazily.
Versions
ocamlc: 5.2.1
js_of_ocaml: 5.9.1