npmreasonbucklescript

How to correctly setup a local ReasonMl / Bucklescript dependencies


New to ReasonML, and I probably don't understand the bucklescript documentation for setting up a module as a dependency.

  1. ReasonML project, compiles correctly, with the file MyUtils.re in directory ~/ml/myutils/src.
  2. second ReasonML project in ~/ml/project2/src, file Demo.re starts with

    open MyUtils;

I installed the first project: I tried both

npm install -g 

inside ~/ml/myutils, and npm install ../myutils --save inside ~/ml/project2

the module looks installed globally :

 npm list -g | grep myutils

├─┬ myutils@0.1.3 -> /home/user/ml/myutils

and also locally

 npm list | grep myutils

└─┬ myutils@0.1.3 -> /home/user/ml/myutils

bsconfig.json

"bs-dependencies": [
"@glennsl/bs-json",
"myutils"

],

package.json

 "dependencies": {
"@glennsl/bs-json": "^5.0.2",
"myutils": "file:../myutils"

}

but npm run build :

We've found a bug for you!
  /home/user/ml/project2/src/Demo.re 2:6-12

  1 │
  2 │ open MyUtils;
  3 │
  4 │

  The module or file MyUtils 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?

I tried adding file:../myutils to bsconfig.json: no change

What am I doing wrong?


Solution

  • @gash go check bsconfig.json of myutils. Set "namespace": false

    If Myutils namespace is true. it will probably create extra module layer for you.

    Something like MyUtils.MyUtils