Intergrating PPX into bsb

bsb

#1

Hi,

I have some questions concerning the usage of PPXs.

A) Is it possible to use PPXs from native ocaml to be used in bucklescript (on windows)?
I do see sometimes a (as it seems) PPX for bucklescript but that more like a bucklescript specific ones like ppx-tea-jsx.
B) If A) is possible is there some tutorial/docs out there describing the process of integrating this into bsb?
C) are there any docs available on how to write a PPX specifically for BuckleScript?

Thx


#2

Bucklescript only accepts binary for ppx at the moment so distributing it might be a problem (compiling and packaing for all 3 platforms)

Other than that, nothing special for writing a ppx that works with Bucklescript, just target ocaml 4.02.3


#3

I am not sure I understand.

Lets assume the following

  • Build system is Windows (which in itself is challenging with Ocaml)
  • The target system is JS

Do PPXs work under these conditions?

ciao robertj
PS: Why version 4.02.3?


#4

Heyy! If you’d like a pretty simple setup, you should be able to use bsb-native!
The readme has some explanation for how to have a ppx inside your codebase: https://github.com/bsansouci/bucklescript/blob/master/README.md#ppx-support

Basically all you need is a bit of config stuff in your bsconfig.json and put your ppx code in a separate folder.

Here’s the tutorial I always use for writing a ppx: https://whitequark.org/blog/2014/04/16/a-guide-to-extension-points-in-ocaml/ (Scroll to the Example)