codemod
codemod copied to clipboard
added remx.js codemods
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 themetaAPI closer tolinks, 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
matchesparameter 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
metaV1function, you can pass in themetafunction'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
metaexports with the@remix-run/v1-metapackage 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
metaV1function and this could result in unpredictable behavior. If you want to merge meta across the entire hierarchy, use themetaV1function for all of your route's meta exports. - https://go.codemod.com/W5rzM7B
remix-run_v1_meta-function-args-wrapper
- In v2, the
metafunction no longer receives theparentsDataargument. This is becausemetanow has access to all of your route matches via thematchesargument, which includes loader data for each match.
Additional Details
- To replicate the API of
parentsData, the@remix-run/v1-metapackage provides agetMatchesDatafunction. 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
useNavigationto avoid confusion with the recent React hook by the same name. It also no longer has thetypefield and flattens thesubmissionobject into thenavigationobject itself.
Additional Details
- You can derive the previous
transition.typewith the following examples. Keep in mind, there's probably a simpler way to get the same behavior, usually checkingnavigation.state,navigation.formDataor the data returned from an action withuseActionDatacan get the UX you're looking for. - https://go.codemod.com/bBF5eVZ
fetcher-submission-properties-flattening
- Like
useNavigation,useFetcherhas flattened thesubmissionand removed thetypefield.
Additional Details
- You can derive the previous
fetcher.typewith the following examples. Keep in mind, there's probably a simpler way to get the same behavior, usually checkingfetcher.state,fetcher.formDataor the data returned from an action onfetcher.datacan get the UX you're looking for. - https://go.codemod.com/Z5eYUyV
typescript_2_update-links-function-and-property-names
- Route
linksproperties should all be the React camelCase values instead of HTML lowercase values.
Additional Details
- https://go.codemod.com/KmTxkbz
rename-browser-build-directory
- In your
remix.config.js, renamebrowserBuildDirectorytoassetsBuildDirectory.
Additional Details
- https://go.codemod.com/To1ApaP
webpack_v2_migrate-dev-server-port
- In your
remix.config.js, renamedevServerPorttofuture.v2_dev.port.
Additional Details
- https://go.codemod.com/nZMuPVE
remix_1_replace-response-with-create-readable-stream
- One place this is likely to surface and require a change is your
app/entry.server.tsxfile, where you'll also need to convert the Node[PassThrough](https://nodejs.org/api/stream.html#class-streampassthrough)into a web[ReadableStream](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream)viacreateReadableStreamFromReadable
Additional Details
- https://go.codemod.com/GBuAz5U
nodejs-module-exports-server-build-directory-to-path
- In your
remix.config.js, renameserverBuildDirectorytoserverBuildPathand specify a module path, not a directory.
Additional Details
- https://go.codemod.com/P5CTNhm
@dfordp is attempting to deploy a commit to the Codemod Team on Vercel.
A member of the Team first needs to authorize it.