Places Diary #3: Side Quests
After parting ways with Prisma, I dedicated time to shoring up a few other aspects of the project.
Type-safe SQL queries
Initially opting for raw SQL queries post-Prisma, I’ve now refactored once more to use Kysely, a lightweight SQL query builder. It still uses better-sqlite3
under the hood, but adds type-safe SQL queries and exposes the database schema to the TypeScript compiler for autocompletion based on the database schema. This helps prevent common errors like typos and referencing non-existant columns.
Migrations
Replacing Prisma also meant needing to find a new way to handle migrations. Thankfully, Kysely provides examples for handling migrations. That paired with a script to execute them on each deploy addressed the remaining gaps from removing Prisma.
Remix v1 to Remix v2 (plus ESM and Vite)
I also updated from Remix v1 to v2. Remix’s “Future Flags” made it pretty straightforward to adopt v2 changes while still on v1 and then seamlessly make the upgrade to v2 once I had each new feature working.
Remix v2 uses ESM as the default server module output, so I adopted that as well. The templates create-remix
uses to create a new project are in the Remix repo, so it was simple enough to copy the ESM server modules from the Express template over the CJS modules that needed to be updated.
Once on v2, I replaced Remix’s compiler with Vite, which Remix plans to make its default in the future. Remix’s compiler requires a workaround for bundling ESM server modules. Moving to Vite allowed me to quit tracking the dependencies that Remix needed to bundle differently since Vite supports both ESM and CJS dependencies.
One Annoying Issue
The move to Vite has introduced one annoying issue. Occasionally after making a change, the dev server will show 504 (Outdated Optimize Dep)
errors in Safari’s console (it doesn’t seem to affect Chromium browsers). This results in interactive features not working until cached data is cleared for localhost
(Safari → Settings → Privacy → Manage Website Data). Everything works fine in production, so I will track the issue at GitHub and hope it gets resolved soon.
Now back to new features…
Interested in trying Places?
If you are interested in trying Places, sign up for the waitlist and be among the first to know when it’s ready.
Other Posts In This Series
All Posts