Why does the generated JS files says "PLEASE EDIT WITH CARE"

Whenever a ReScript file is compiled, the generated JS output always has

// Generated by ReScript, PLEASE EDIT WITH CARE

But on the official website https://rescript-lang.org/ it says the ReScript is very easy to unadopt i.e. if we adopt ReScript and change our minds half way, we could still keep the generated JS files and it will continue to function. But then obviously, we would have to edit the generated JS files in one or the other situation to continue building the product/app whatever.

I feel this contradicts the output comment above. I mean if ReScript really leans on clean JS output, maybe the comment is not needed ?

But then obviously, we would have to edit the generated JS files in one or the other situation to continue building the product/app whatever.

Editing the generated JS file is an escape hatch. It could be useful when you need a bug fix to make immediately. You should edit it with care otherwise when rescript file changes are changed, those changes are lost

Just imagine you’d modify a generated JS file and then make a change in the original ReScript file and all the changes are lost. I’d be really mad as a user.

If you want to unadopt, you’d first remove the compiler from your toolchain, check in the JS build artifacts and then probably regex replace the header in each file afterwards to prevent confusion.

So I guess the key takeaway is that the output JS is only for learning and optimization purposes and editing them is a bad practice ?

As long as you are using ReScript, you shouldn’t hand-edit the output JS files (unless you have absolutely no other option and urgently need to change something in it, in which case you should set up a script that does the edit every time the file is output by ReScript, otherwise the changes will disappear the next time it is).

// Generated by ReScript, PLEASE EDIT WITH CARE. Any changes will be overwritten if ReScript is used again.

1 Like