NextJS on FABs
This is a proof of concept getting Frontend Application Bundles (FABs, see more at https://fab.dev).
FABs are designed to compile any frontend project and deploy them anywhere that can run JS:
Docker on AWS EC2
NextJS is a tricky target for FABs, as it, like a lot of NodeJS server-side JS projects, assumes a fair bit about the environment it runs on. Since version 8, Next has offered two build targets: NodeJS & Serverless. The serverless build has stripped out a lot of the old assumptions and generates a single file per "route" for NextJS. Each of these files shares a lot with each other, and
@fab/nextjs isn't very smart about things at the moment, but it's possible to create a FAB with all of these files inlined and generate a router from the filesystem.
Definitely a proof-of-concept at this stage, but look, it works, and for a while I didn't think it would be able to, so I'm calling that a win!
The Cloudflare Workers and Amazon Lambda@Edge deployers aren't fully open-sourced yet. They're in the process of being extracted from the Linc codebase.
The Now.sh and Heroku deployments haven't been generalised—they're hard-coded into this repo's
npm scripts. But they both use the
fab.zip generated by
npm run build:fab, rather than doing anything with the sourcecode.