Using the Remix Example - i’m getting the error ReferenceError: Buffer is not defined
when including the loader()
function
also can we get an example using shared layout?
Hi @efficient_pelican , we tried reproducing with some recent versions of remix but could not do so. What version of remix and what platform runtime are you using? Do you have an example repo that you can point us to?
Regarding shared layout, do you mean you are trying to exempt the plasmic dash host page from shared layout that is global to the rest of the pages in The app? If so, you can do this from your route view by checking the URL and opting out, like shown here: https://github.com/plasmicapp/plasmic/blob/master/examples/hydrogen-oxygen-with-model-renderer/app/root.tsx#L88
thanks for reply - i’m using latest version of remix + plasmic
yarn dev
only works if i comment this out in /app/routes/_index.tsx
:
export const loader = async () => {
const plasmicData = await PLASMIC.fetchComponentData("/")
return json(plasmicData)
}
node v18.16.0
i invited plasmicops
to https://github.com/DINGORODEO/hey-gang-hydrogen/ incase that’s helpful to see
Strange, I see the error in this repo, but it never occurs in our other Hydrogen example repos.
One question - where are you trying to deploy your Hydrogen app?
Oxygen ideally
Loader is not compatible with Oxygen unfortunately, so even if you surmount this issue, the main problem is the restrictions within CF Workers environments around eval()
- you would need to switch to using build-time codegen instead (see this example Hydrogen repo)
oh interesting - doesn’t seem to bad. are there any pros/cons to this?
There are some benefits with respect to bundling/performance, auditability/debuggability, and compatibility with platforms like Oxygen
The main downside is that it requires you kick off a build on publish (via say a webhook), instead of being able to treat the Plasmic designs as data loaded and cached via API, and the DX is not quite as polished yet as loader
what do you mean about “treating plasmic designs as data loaded”
That’s referring to how loader-react works - it loads the code from Plasmic’s APIs “at runtime” (in a loader/getStaticProps/getServerSideProps) and evals it
With build-time codegen, you are loading the code from Plasmic’s APIs at build time instead and writing them out as source files on disk
Do all design changes require full rebuild?
With codegen yes
That one is still very early WIP! But it intended to be an alternative to loader that doesn’t depend on eval/codegen and is suitable if you are using Plasmic more like a CMS (not using dynamic values, etc.)
is this something i should look into or not suitable for me?
also, these examples in repo don’t fetch any data from plasmic. I don’t see any docs on how to do that with buildtime codegen