bsansouci / bsb-native

Build system for OCaml/Reason
Other
245 stars 10 forks source link

Should ignore modules that are not used #70

Closed WhoAteDaCake closed 5 years ago

WhoAteDaCake commented 5 years ago

Currently if i have a library that has optional functionality that depends on JavaScript you will not be able to build native code.

For example: When using wonka which provides JavaScript event handling, I won't be able to build code that doesn't even use JavaScript bindings:

let example = [1, 2, 3, 4, 5, 6];

/* Curently forced to inject wonka as bs-native can't be compiled properly */
Wonka.fromList(example)
|> Wonka.filter(x => x mod 2 === 0)
|> Wonka.map(x => x * 2)
|> Wonka.forEach(x => print_endline(string_of_int(x)));

Will throw:

  27 │    */
  28 │ let fromDomEvent:
  29 │   (Dom.element, string, signalT(Dom.event) => unit) => unit;
  30 │ 
  31 │ /* Accepts a period in milliseconds and creates a listenable source

  The module or file Dom can't be found.
bsansouci commented 5 years ago

Thanks for reporting this issue. There's a way to do this currently, by includeing different implementation modules hidden under a #if BSB_BACKEND = "native" check. See reprocessing's hot reloading implementation.

I'd love to find a better way to do this.

WhoAteDaCake commented 5 years ago

Ahh I see, thank you for the response