Skip to content
This repository has been archived by the owner on Nov 24, 2024. It is now read-only.

defineRoute codemod checklist #2

Open
17 of 34 tasks
KubaJastrz opened this issue Jun 24, 2024 · 0 comments
Open
17 of 34 tasks

defineRoute codemod checklist #2

KubaJastrz opened this issue Jun 24, 2024 · 0 comments
Assignees

Comments

@KubaJastrz
Copy link
Owner

KubaJastrz commented Jun 24, 2024

defineRoute

Upstream development in remix-run/react-router#11596

  • Move all known exports into defineRoute default export
    • Default export -> Component
      • Function component
      • Class component (it this even supported by Remix?)
      • Remove useLoaderData and inject loaderData param (code)
      • Remove useActionData and inject actionData param (code)
      • Add params param? Not sure if needed in the codemod, as components in the old code didn't have access to this (source)
      • Do something about useFetcher<typeof action> (example)
    • Named exports = everything else (keep unknown export untouched)
      • loader -> serverLoader
      • clientLoader
      • action -> serverAction
      • clientAction
      • meta
        • rename argument data -> loaderData (code)
      • links
      • ErrorBoundary
      • HydrateFallback
      • headers - deprecated in Single Fetch
      • handle - likely unsupported by defineRoute
      • Remove all type annotation in function arguments (like LoaderFunctionArgs)
  • Order all exports based on the predefined order (to satisfy TS generics)
  • Add params field #4
  • Add clientLoaderHydrate field (code)
  • Special handling for defineRootRoute (code)

Other:

  • Find all route files with npx remix routes --json
  • Read app from config somehow, it is hardcoded for now
  • Add import for defineRoute
  • Remove all unnecessary imports?
  • Package into something executable by npx
  • Warn about non-standard use of typeof loader/typeof action (example)
  • Detect indentation (tabs vs spaces, length of spaces)
  • Support experimental unstable_defineAction and unstable_defineLoader?

Bugs:

@KubaJastrz KubaJastrz self-assigned this Jun 24, 2024
@KubaJastrz KubaJastrz pinned this issue Jun 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant