Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added remx.js codemods #1313

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

added remx.js codemods #1313

wants to merge 1 commit into from

Conversation

dfordp
Copy link

@dfordp dfordp commented Sep 6, 2024

v1 → v2

  • Link to Official Upgrade Guide: [[Insert Link](https://v3-migration.vuejs.org/)]

add-matches-param-and-array-return-to-meta-export

  • Instead of returning an object from meta, you will now return an array of descriptors and manage the merge yourself. This brings the meta API closer to links, and it allows for more flexibility and control over how meta tags are rendered.

Additional Details

  • Return type: Now returns an array of descriptors instead of an object.
  • Function parameters: Added matches parameter to access route hierarchy information.
  • Object structure: Replaced object literal with an array of objects, each representing a meta descriptor.
  • https://go.codemod.com/ShZuosf

remix_1_add-meta-v1-wrapper

  • Using the metaV1 function, you can pass in the meta function's arguments and the same object it currently returns. This function will use the same merging logic to merge the leaf route's meta with its direct parent route meta before converting it to an array of meta descriptors usable in v2.

Additional Details

  • You can update your meta exports with the @remix-run/v1-meta package to continue using v1 conventions.
  • Note that this function will not merge meta across the entire hierarchy by default  because you may have some routes that return an array of objects directly without the metaV1 function and this could result in unpredictable behavior. If you want to merge meta across the entire hierarchy, use the metaV1 function for all of your route's meta exports.
  • https://go.codemod.com/W5rzM7B

remix-run_v1_meta-function-args-wrapper

  • In v2, the meta function no longer receives the parentsData argument. This is because meta now has access to all of your route matches via the matches argument, which includes loader data for each match.

Additional Details

  • To replicate the API of parentsData, the @remix-run/v1-meta package provides a getMatchesData function. It returns an object where the data for each match is keyed by the route's ID.
  • https://go.codemod.com/ZtaTcfa

remix_1_use-route-error-codemod


remix-run_1_use-transition-to-use-navigation

  • This hook is now called useNavigation to avoid confusion with the recent React hook by the same name. It also no longer has the type field and flattens the submission object into the navigation object itself.

Additional Details

  • You can derive the previous transition.type with the following examples. Keep in mind, there's probably a simpler way to get the same behavior, usually checking navigation.statenavigation.formData or the data returned from an action with useActionData can get the UX you're looking for.
  • https://go.codemod.com/bBF5eVZ

fetcher-submission-properties-flattening

  • Like useNavigationuseFetcher has flattened the submission and removed the type field.

Additional Details

  • You can derive the previous fetcher.type with the following examples. Keep in mind, there's probably a simpler way to get the same behavior, usually checking fetcher.statefetcher.formData or the data returned from an action on fetcher.data can get the UX you're looking for.
  • https://go.codemod.com/Z5eYUyV

typescript_2_update-links-function-and-property-names

  • Route links properties should all be the React camelCase values instead of HTML lowercase values.

Additional Details


rename-browser-build-directory

  • In your remix.config.js, rename browserBuildDirectory to assetsBuildDirectory.

Additional Details


webpack_v2_migrate-dev-server-port

  • In your remix.config.js, rename devServerPort to future.v2_dev.port.

Additional Details


remix_1_replace-response-with-create-readable-stream

Additional Details


nodejs-module-exports-server-build-directory-to-path

  • In your remix.config.js, rename serverBuildDirectory to serverBuildPath and specify a module path, not a directory.

Additional Details

Copy link

vercel bot commented Sep 6, 2024

@dfordp is attempting to deploy a commit to the Codemod Team on Vercel.

A member of the Team first needs to authorize it.

@CLAassistant
Copy link

CLAassistant commented Sep 6, 2024

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants