Compiling a React to an IIFE with Rollup to execute and render in a headless browser
lessonDuration 5m 43s
We take the opengraph image we wrote in codesandbox and copy it into our serverless function. We use Rollup to compile the component into an IIFE (immediately invoked function expression) that can run in our headless browser environment and cover a wide set of rollup plugins that we need for compatibility. We end the lesson having successfully screenshot our opengraph react component from our Netlify Function **Note**: Due to Netlify changing their handling, the path in `fs.readFileSync` is affected. Update to: ```js const script = fs.readFileSync(path.resolve(__dirname, "image.js"), "utf-8"); ```