1

Is there a way to compile ReScript with just the CLI?

In other words, without the bsconfig.json?

Ideally, I would like to be able to just call the CLI and be able to compile into ES6, declare external dependencies, etc.

Nick
  • 5,108
  • 2
  • 25
  • 58

1 Answers1

0

The rescript compiler executable is called bsc, and I believe mroe or less takes the same options as ocamlc.

Assuming you have rescript installed locally, and two source files main.res and foo.res where Main depends on Foo, and with no other dependencies, you can compile them to commonjs modules by invoking the following commands:

npx bsc foo.res > foo.js
npx bsc -I . main.res > main.js

Unfortunately I don't think you can compile directly to es6 without bsconfig.json. The compiler option to do so is -bs-package-output es6, but that requires passing both -bs-package-name and a bsconfig.json file.

glennsl
  • 28,186
  • 12
  • 57
  • 75