I’m considering doing this because I do spend a lot of time actually reading the JS output to ensure I understand how the bindings I’m writing are being compiled, but I’m wondering if there are any caveats here.
The output js will be changed once you editing the res file.
Right, I’m thinking running it constantly such that when the output changes, prettier runs again. I guess that could cause some double-refresh situations with the dev server, but that doesn’t seem like the end of the world.
I’ll give it a shot and report back.
js-post-build hook might be useful for this.
I wonder whether it passes the updated js file path or maybe its content somehow to the hook.
I also considering doing this. Since with vitejs, rescript and wallaby, everything is blazingly fast. It’s not a big deal
What’s your setup with Wallaby? I mean, ReScript has no source maps.
I run it locally on js output. Sourcemaps?
I was under the impression what Wallaby requires source maps to even work. It should totally require them for test coverage, but maybe not for running the tests.
No, it doesn’t require sourcemaps for anything. The only problem of using it with Rescript, that you need to completely switch to generated output, when debugging some failing test. But it’s how rescript works
Here is my package.json with my config for jest and wallaby
{
"name": "karada",
"description": "Web app for Ashiso Project",
"author": "Kevin Abatan <abatan.k@ashiso.io>",
"type": "module",
"scripts": {
"re:build": "rescript build -with-deps",
"clean": "rescript clean -with-deps && rm -rf dist && rm -rf lib",
"vite:preview": "rescript build -with-deps && vite preview",
"test:unit": "NODE_OPTIONS=--experimental-vm-modules jest test/unit",
"test:contract": "NODE_OPTIONS=--experimental-vm-modules jest test/contract --testTimeout 30000",
"pact:publish": "pact-broker publish pact/pacts -t $GIT_BRANCH -a $GIT_COMMIT -b $PACT_BROKER_BASE_URL -k $PACT_BROKER_TOKEN",
"pact:can-i-deploy": "pact-broker can-i-deploy -a karada -k $PACT_BROKER_TOKEN --version $GIT_COMMIT --to-environment production",
"pact:record-deployment": "pact-broker record-deployment -a karada -k $PACT_BROKER_TOKEN --version $GIT_COMMIT --environment production"
},
"dependencies": {
"daisyui": "~2.15.2",
"lightweight-charts": "~3.8.0",
"luxon": "~2.4.0",
"ramda": "~0.28.0",
"react": "~18.1.0",
"react-dom": "~18.1.0",
"react-redux": "~8.0.2",
"redux": "~4.2.0",
"redux-observable": "~2.0.0",
"rescript": "~9.1.4",
"reselect": "~4.1.5",
"rxjs": "~7.5.5"
},
"devDependencies": {
"@glennsl/rescript-jest": "~0.9.1",
"@pact-foundation/pact": "~9.17.3",
"@redux-devtools/extension": "~3.2.2",
"@rescript/react": "~0.10.3",
"@ryyppy/rescript-promise": "~2.1.0",
"@tailwindcss/typography": "^0.5.2",
"@vitejs/plugin-react": "~1.3.2",
"autoprefixer": "~10.4.7",
"cssnano": "~5.1.10",
"jest": "~28.1.0",
"jest-jasmine2": "~28.1.0",
"postcss": "~8.4.14",
"postcss-import": "~14.1.0",
"rescript-jzon": "~1.3.0",
"rescript-webapi": "~0.6.1",
"tailwindcss": "~3.0.24",
"vite": "~2.9.9"
},
"jest": {
"moduleFileExtensions": [
"mjs",
"js"
],
"testMatch": [
"**/test/**/*.test.mjs"
],
"testRunner": "jest-jasmine2",
"verbose": true
},
"wallaby": {
"autoDetect": true,
"files": [
"src/**/*.mjs"
],
"tests": [
"test/unit/*.test.mjs"
],
"env": {
"type": "node",
"params": {
"runner": "--experimental-vm-modules"
}
}
}
}