BuckleScript library exposing another


I have one BuckleScript library/module X that depends on another Y. The module Y should be exposed by X (i.e. x.ml contains the line module Y = Y and has library Y as a dependency in package.json and bsconfig.json). But Y isn’t visible to projects that depend on X – attempting to compile them gives The module X.Y is an alias for module Y, which is missing. How can I fix this?

One thing I tried was replacing module Y = Y with module Y = struct include Y end. This kind of works, but it doesn’t seem to include the submodules for Y – I get the same error message about the module X.Y.Z. And it doesn’t seem like the right thing to do anyway.


Let’s call Z the project that uses X. So, in Z, if you add both X and Y as dependencies in bsconfig.json, does the error go away?


That error goes away but I get another stranger one saying that x.cmi and y.cmi “make inconsistent assumptions over interface I”, where I is a library that is only used in X via the dependency on Y (which uses I directly).


Does this error go away on a clean build of Z:

npx bsb -clean-world
npx bsb -make-world


It does initially, but then when I run npm install && npm start although the first build works I get the error as soon as I trigger a rebuild (even if it’s just writing a file without changes).


What does the npm start command run?


bsb -make-world -w -ws _ (the default for a react-hooks project)


So in my experience running bsb -make-world with every code change tends to screw up the intermediate compiled files. Can you try with bsb -w -ws _ instead? I.e. only run bsb -make-world if some dependencies actually change.


Thanks, interesting! But sadly the same thing happens with that.


Interesting … so the build succeeds the first time round but fails subsequently. It would be good to have a minimal repro example of this to play with.


So I put together an example, and for some reason switching from local copies of libraries to npm registry ones solved it! Not really sure why that happened, but I’m not complaining. If you’re interested, the project was porting ppx_yojson_conv to BuckleScript.