Closed parkerziegler closed 5 years ago
Examining this more, I think I uncovered the source of things. In the change from v2
to v3
, the namespace
flag in bsconfig
was turned to true
(it defaults to false
for backwards compatibility: https://bucklescript.github.io/docs/en/build-configuration#name-namespace). This means that the project, by default, is under the Wonka
namespace. So, in order to access everything in wonka.ml
, you actually have to use Wonka.Wonka
(the first Wonka
coming from the namespace, the second coming from wonka.ml
).
A solution would be to revert the namespacing back to false
(i.e. remove it from bsconfig.json
). This seems ok to me, as all of the modules built in this project are prefixed with Wonka_
anyway, so it's very unlikely they'd conflict with any consumer code. Another possibility would be to not include anything in wonka.ml
, but in that case I'm not sure how we'd do the conditional logic around including WonkaJs
in web builds only 🤔
@parkerziegler ah yea that was definitely not intentional. I’ll reverse that :)
In the upgrade from v2 to v3, we lost the ability to just reference
wonka
sources, sinks, and operators directly (i.e. asWonka.subscribe
orWonka.map
). Instead, it now only works if youopen Wonka
at the top of your.re
file and additionally reference sources, sinks, and operators in theirWonka.<name>
form.Reproduction
bsb -init wonka-test -theme basic-reason
(this assumes you already havebs-platform
installed globally).Demo.re
in the boilerplate):yarn build
.Similarly, if you just
open Wonka
and don't reference the module further, you'll get an error. For example, following steps 3 and 4 above with this code:will yield the following error:
I'm thinking there's something about how modules are
include
d that's going awry here, but I'm not 100% sure what it is. But I'll do some investigating when I can and try to see if I can figure out a solution. IIRC this worked fine in v2 so if we need to move back to a structure like that we maybe could? Not sure yet how that affects native stuff.