5

I'm writing a node application, where I would like to mix Reason and raw JavaScript.

This section in the bucklescript documentation describes it

When user has an existing JS project, it makes sense to output the JS file in the same directory as vanilla JS, the schema added a key called in-source so that generate JS file next to ML file.

I assume that this is in the bsconfig.json file? But what value should the key have? The schema documentation does not mention this option.

I'm running Bucklescript version 1.9.1 - so the functionality should be available (available since 1.9.0).

How do I use the in-source option?

My bsconfig.json file looks like this:

{
  "name": "re-server",
  "version": "0.1.0",
  "bsc-flags": ["-bs-super-errors"],
  "in-source": true,  // I tried adding the key here
  "sources": [{
    "dir": "src",
    "in-source": true  // I tried adding the key here
  }
  ],
  "bs-dependencies" : [
    "bs-express"
  ]
}
glennsl
  • 28,186
  • 12
  • 57
  • 75
Pete
  • 12,206
  • 8
  • 54
  • 70

1 Answers1

4

It should be in the "package-specs" section:

{
  ...
  "package-specs" : [{
    "module": ...,
    "in-source": true
  }]
}

So your bsconfig.json should look like:

{
  "name": "re-server",
  "version": "0.1.0",
  "bsc-flags": ["-bs-super-errors"],
  "package-specs" : [{
    "module": "commonjs",
    "in-source": true
  }],
  "sources": [{
    "dir": "src"
  }
  ],
  "bs-dependencies" : [
    "bs-express"
  ]
}
glennsl
  • 28,186
  • 12
  • 57
  • 75
  • I'll make sure to submit a documentation fix for this, too. – glennsl Oct 15 '17 at 18:20
  • Great, I had to add a `"module": "commonjs"` too inside the package spec object for it to compile, but now it's fine. Did you update the schema-doc already? Because now I can find it - but you have to click to drill down to the option to see it. – Pete Oct 15 '17 at 20:10
  • It's always been there, just hiding very well ;) I haven't updated the schema, just the manual. I'll add "module" too. Thought it was optional, but apparently not. – glennsl Oct 15 '17 at 20:38