Note
Project has been deprecated, as the underlying design for typesafe routes has changed in the mean time.
First demo: https://x.com/kuba_jastrz/status/1798783656305025372
Before:
After:
This is only a concept image, the actual codemod doesn't fully work like this yet. It's close though 😄
I don't know how to package this yet, but you can run it locally:
git clone https://github.com/KubaJastrz/typesafe-remix-codemod
cd typesafe-remix-codemod
cargo run ./remix-app # or path to any other remix app
The codemod finds all route files with npx -y @remix-run/dev routes --json
and iterates over them with oxc_parser.
It makes transformations in two passes per file. The first one is to modify the existing function bodies and remove the useLoaderData
/useActionData
hook calls. The second pass is to replace all Remix exports with the new defineRoute
default export.
# run against local remix app
cargo run ./remix-app
cargo run ./epic-stack
# revert codemod changes
git restore ./remix-app
git restore ./epic-stack
# test
cargo test
# review snapshots
cargo insta review
Progress is being tracked in Issue #2.