Having trouble using third party modules/packages

bsb

#1

I installed a third party module: https://github.com/scull7/bs-validation

This one works and I added it to “bs-dependencies” despite instructions saying to add to “dependencies”.

However when using this module it doesn’t seem to detect or load it: https://github.com/scull7/bs-result

I keep getting the error “Unbound module Result” whereas the Validation module works fine.


#2

Can you paste your bsconfig.json file here? Also the full error output from running npx bsb on the command line in the project root directory?


#3

Which version of bsb are you using? Result should be shipped by default


#4

Here is my bsconfig. Then I run “yarn add bs-result”

{
  "name": "project",
  "version": "0.1.0",
  "sources": {
    "dir": "src",
    "subdirs": true
  },
  "package-specs": {
    "module": "es6-global",
    "in-source": true
  },
  "suffix": ".bs.js",
  "bs-dependencies": ["bs-result"],
  "warnings": {
    "error": "+101"
  },
  "namespace": true,
  "refmt": 3,
  "gentypeconfig": {
    "language": "typescript",
    "shims": {},
    "debug": {
      "all": false,
      "basic": false
    }
  }
}

Version

> yarn bsb -v
8.2.0

If I move the node_modules/bs-result/src folder to my project root then it detects the module and works.

[3/3] Building src/modules/message/Message-Bidcore.cmj
FAILED: src/modules/message/Message-Bidcore.cmj src/modules/message/Message-Bidcore.cmi /.../src/modules/message/Message.bs.js 
/.../node_modules/bs-platform/darwin/bsc.exe -bs-package-name bidcore -bs-ns Bidcore  -bs-package-output es6-global:src/modules/message -bs-suffix -I ... truncated ... -I src/modules -I src -warn-error +101  -bs-gentype /.../node_modules/gentype/gentype.exe -o src/modules/message/Message-Bidcore.cmj src/modules/message/Message.reast

  We've found a bug for you!
  /.../src/modules/message/Message.re 51:15-26
  
  49 ┆   let fFailure = errs => F.concat(errs, msgs);
  50 ┆   /* result |> Result.bimap(fSuccess, fFailure); */
  51 ┆   result |> Result.bimap(fSuccess, fFailure);
  52 ┆ };
  53 ┆ 
  
  The module or file Result can't be found.
  - If it's a third-party dependency:
    - Did you list it in bsconfig.json?
    - Did you run `bsb` instead of `bsb -make-world`
      (latter builds third-parties)?
  - Did you include the file's directory in bsconfig.json?

#5

It looks like that package hasn’t been updated in a while – it may not be compatible with the latest version of bs-platform


#6

As the error says, did you run bsb -make-world after installing the third party dependency? I find I need to run make world after every yarn invocation, it wipes out files it doesn’t know about (particularly the compiled .bs.js files).

I was able to compile bs-result on an older project I added it to as an easy test case, but when I upgraded to 8.2.0 it fails due to this configuration setting:

"bsc-flags": [ "-bs-super-errors", "-bs-sort-imports" ],

That fails to compile with unknown option: '-bs-sort-imports'. You might be able to PR a fix, but given the age of the repository you may have to fork it instead. If you’re looking for monadic ReasonML helpers perhaps try relude?


#7

Yes my default command is “bsb -make-world”. It is the one giving the error that Result.bimap cannot be found.

Relude looks like what I need, although I got bs-result to work just by copying over the two files from bs-result out of node_modules and into my project.