I use create-rescript-app to create a rescript project demo.
The “scripts” in package.json is as below.
"res:clean": "rescript clean",
"res:dev": "rescript build -w",
"build": "vite build",
"preview": "vite preview"
My problem is if use “dev” script only, .mjs files are not updated. if use “res:dev” only, no webserver is started. I have to open 2 terminals to run both scripts for my development.
My question is that if it is possible to use only 1 script to enable both .res file watching & webserver for development.
Thanks for any advice.
If you use rescript-vscode, it should do the file watching automatically (for simple, non-monorepos at least).
If you really need to run everything in one Terminal, you could use
npm-run-all to run them from the same terminal with the run-p command.
Here is an example setup: https://github.com/cca-io/quick-translate/blob/main/package.json
rescript-vscode works for me. Thank you!
There’s also the
concurrently package. Example
package.json from one of my projects:
"watch:rescript": "rescript build -with-deps -w",
"watch:relay": "rescript-relay-compiler -w",
"dev": "concurrently 'yarn:watch:*'"
Is it fast? I was under the impression that the ReScript team would prefer you to run the compiler standalone so as not to slow down the feedback loop.
I didn’t mean the loader feature. Basically the plugin does is spawning a
rescript build -w process on dev,
rescript build process on build. So no need to use either
concurrently for it.
+ And it is also helpful when using rescript-vitest
I had issues when trying it out with Vitest. When running tests with coverage it would hang and not exit until it timed out.
Did you try rescript-vitest? Could you open an issue and explain more about the problem?
I was using that, yes.
Sorry, different project. This project was using vite-plugin-rescript with unit tests written in TypeScript.
Let me see if I can create a small repo with the issue.