rescript-compiler
rescript-compiler copied to clipboard
Compile module Text to another thing than $$Text
After posting on the forum, I create this issue to have a better compilation for module like "Text" or "String" or "Boolean" to better version than $$Text See more info here : https://forum.rescript-lang.org/t/why-text-is-compiled-to-text/2453
This should only be about when you're looking to use the value from something other than ReScript, right? So the problem is at the export boundary when the intention is to use the code from JS/TS.
It is indeed a problem only when we want to use the code with JS/TS, This snippet
module TextComponent = {
let make = () => React.string("text")
};
let \"Text" = TextComponent.make
transpile to
// Generated by ReScript, PLEASE EDIT WITH CARE
function make(param) {
return "text";
}
var TextComponent = {
make: make
};
var $$Text = make;
export {
TextComponent ,
$$Text ,
}
/* No side effect */
A better output could be:
// Generated by ReScript, PLEASE EDIT WITH CARE
function make(param) {
return "text";
}
var TextComponent = {
make: make
};
var $$Text = make;
export {
TextComponent ,
Text: $$Text ,
}
/* No side effect */