Open jaredly opened 7 years ago
What options do you have that you'd like to have different between JS and native?
ppx-flags was the one I wanted to be different
I could make that happen. Is it that your codebase uses one ppx but you want to swap the implementation beteeen JS and Native, or that you have different code paths for JS and native that each use their own ppx?
different codepaths
I think i'm running into the same issue. The native build uses Big_int
from batteries
and i'm replacing it in JS with some bindings to bn.js. The problem is I have to add these bindings to bs-dependencies
in bsconfig.json
, but then the native build breaks.
@jaredly if you fixed it, how did you manage to do it? i guess I can have native.json
and js.json
and override bsconfig.json
before compiling but seems like a lot of overhead.
@bsansouci maybe ppx-flags
and bs-dependencies
could benefit of a similar approach than entries
and subdirs
? (i have no idea how hard that would be)
"bs-dependencies": [{
"backend": "native",
"value": [
"bs-bn.js"
],
}],
I just made a separate folder with a bsconfig.json in it, it worked just fine
@jchavarri Could you put the JS part inside a folder say src/js
and add
"sources": [{
"dir": "src,
"subdirs": [{
"dir": "js",
"backend": "js"
}]
}
So that that JS file's only used when building to JS?
i believe it's a dependency. bsconfig doesn't support conditional 3rd-party stuff atm
I just made a separate folder with a bsconfig.json in it, it worked just fine
@jaredly nice, this seems to work, thanks!
Could you put the JS part inside a folder say src/js
@bsansouci As @jaredly says the problem is that this is a dependency in node_modules
, out the reach of the project itself. The compilation fails when it encounters any reference to Js
.
What about “allowed-build-kinds”?
oh, right! that should work in my case (bs-dependencies
). I'll add it to the js lib and let you know if it works, thanks!
Would that work in the ppx-flags
case? 🤔
You mean swap the ppx depending on whether it's JS or native? Not currently, Jared's solution is the way to go!
@bsansouci I tried allowed-build-kinds
but doesn't seem to fix the issue. Maybe that flag works for opam dependencies only? Or I might be doing something wrong.
Supposing I have an app A and a Reason/OCaml library L, this is what i'm doing:
"bs-dependencies": ["L"]
to A's bsconfig.json
"allowed-build-kinds": "js",
to L's bsconfig.json
as L is actually a Reason library with some bindings to JS. Does that make sense?
Edit: finally found the issue thanks to @bsansouci help: I hadn't npm link
ed properly the Reason library, so the changes to bsconfig
weren't being picked 😅
Would be awesome to be able to specify e.g.
-config native.json
, for apps that have a native component (e.g. a server) and a js component (e.g. the client).