rescript-relay
generated code, references values from module A in module B but it uses those values inside %raw
. A simple reduction of this idea is:
let node_TestRefetchingRefetchQuery = TestRefetchingRefetchQuery.node;
let node = %raw(json` {
"argumentDefinitions": [
{
"operation": node_TestRefetchingRefetchQuery,
}`);
this is just part of the code. The contents of raw are taken from an external tool and post processed so we cannot really “just rewrite it in rescript”.
The code above compiles to something like:
import * as TestRefetchingRefetchQuery from "./TestRefetchingRefetchQuery.bs";
var node$1 = ({
"argumentDefinitions": [
{
"operation": node_TestRefetchingRefetchQuery,
});
var node_TestRefetchingRefetchQuery = TestRefetchingRefetchQuery.node;
Note the order of values is reversed. I attempted to workaround it by generating code like:
let node = {
let node_TestRefetchingRefetchQuery = TestRefetchingRefetchQuery.node;
%raw(json` {
"argumentDefinitions": [
{
"operation": node_TestRefetchingRefetchQuery,
}`);
}
But then node_TestRefetchingRefetchQuery
is unused and compiles to nothing. Is there a way to keep that value in the compiled output? To reiterate, my goal is to leverage Bucklescript to resolve the import for a given module.