Closed zth closed 2 years ago
Could you elaborate on what this is used for? Why do we need special module resolution rather than allowing Rescript/Vite/Node (i.e. our environment) to do this for us?
In short:
Dynamically importing via %relay.deferredComponent
, we only know what module to import, but there's no way to know where the generated ReScript file for that module (which is what we'll want Vite to import) is located. And ReScript does not (yet) give us tools to look that up. So that's what findGeneratedModule
does, it takes what %relay.deferredComponent
outputs, which is roughly import("@rescriptModule/WhateverModule")
and looks up where WhateverModule.mjs
is located, so we can point Vite to the right file.
Makes sense?
Oh right okay! Yeah because Rescript usually makes the import * as RescriptModule from "../calculated/module/path.ext"
but we can not make it do the same for a import("../calculated/module/path")
Yeah makes sense!
Logic exists in both the RescriptRelayVitePlugin and in
lookup.mjs
. Figure out why and dry up.