rescript-logger
rescript-logger copied to clipboard
Feature Request: A way of turning off generation of absolute path in js files
I'm checking in .bs.js files in to version control and i don't want system specific info inside the repo, because it changes as e.g. a college recompiles the files and would have changed files to commit even though he didn't change anything. Right now we are rebuilding with RS_LOG=off before committing to work around this issue.
Browser$ReScriptLogger.debug({
rootModule: "SomeModule",
subModulePath: /* [] */0,
value: "make",
fullPath: "SomeModule.make",
filePath: "absolute_file_path/SomeModule.res" // <--- I want this to be relative
}, "Home");
I researched a little and found that ppxlib seems to have a way for stripping a prefix (see file_path.ml#L3) I thought maybe i could pass it like
"ppx-flags": [
["rescript-logger/ppx", "-prefix=./"]
]
I know that is principally possible. graphql_ppx for example offers this (graphql_ppx#configuration) I could be misunderstanding the ppxlib sources of course :sweat_smile: But i wasn't able to find out if or how i could pass a prefix argument. If that would work and you know how, please tell me.
I attempted to solve this before the current release but the only sane way I see is to introduce another env variable with absolute path to the root folder of a project. Or to remove filePath property from public API.
Figuring out where the root folder is within PPX is not an option since PPX doesn't have such information out of the box and we have to perform a search for something like bsconfig.json on each PPX invocation. It's too pricy for such non-critical feature.
"ppx-flags": [
["rescript-logger/ppx", "-prefix=./"]
]
This wouldn't help as well b/c ./ doesn't give any valuable info to PPX since it's a relative path. To be able to turn absolute path to a module within PPX into relative, it needs absolute path to the root folder and it doesn't make sense including it in the config since it is checked into version control. Hence env var.
I attempted to solve this before the current release but the only sane way I see is to introduce another env variable with absolute path to the root folder of a project.
I think an env variable is a good solution.
Or to remove filePath property from public API.
For me it would be ok, but i think also it could be a valuable information to have
This wouldn't help as well b/c
./
I don't know if you had a look at file_path.ml in ppxlib, if you did, do you think i should have passed the absolute path maybe?
As far as i remember, passing options caused errors and rescript-logger has to allow this first. I think, if -prefix works the way i mentioned, could be a nice solution. Anyway providing the prefix via env variable would still be necessary, cause using env variables inside bsconfig.json is not super-easy, at least i couldn't find a way by googling quickly.
This makes the lib unusable for us. We migrated everything to it and will have to switch everything back to simple console logs again because .bs.js files constantly changing all the time with every developer's specific filesystem path and checked in to git. No way to avoid checking in .bs.js files. Major disappointment because it seemed everything was working great until another developer on the team made a commit and we noticed this was happening. Now we regret everything.
I removed filePath in v3.0.0.