@redwoodjs/sdk
Version:
Build fast, server-driven webapps on Cloudflare with SSR, RSC, and realtime
17 lines (16 loc) • 659 B
JavaScript
import memoize from "lodash/memoize";
const modules = import.meta.glob("/src/app/**/*.{ts,tsx}");
export const loadModule = memoize(async (moduleName) => {
return await modules[moduleName]();
});
export const getModuleExport = async (id) => {
const [file, name] = id.split("#");
const module = await loadModule(file);
return module[name];
};
// context(justinvdm, 2 Dec 2024): re memoize(): React relies on the same promise instance being returned for the same id
export const ssrWebpackRequire = memoize(async (id) => {
const [file, name] = id.split("#");
const module = await loadModule(file);
return { [id]: module[name] };
});