Remix v2ã§éçºãã¦ããã¢ããªãReact Router v7ã«Upgradeãã¾ããï¼
Upgradeã®ã¬ã¤ããç¨æããã¦ããã®ã§ãã®ã¨ããã«ããã°å¤§ä¸å¤«ãªã®ã§ããã å°ãã¤ã¾ã¥ãã¦ãã¾ã£ãã®ã§ã¡ã¢ã§ãã
ã»ã¨ãã©ã®ä¿®æ£ãcodemodã¨ããã©ã¤ãã©ãªã使ã£ã¦èªåã§ä¿®æ£ã§ãã¾ãã ãã®ããé常ã«æ¥½ã«Upgradeã§ãã¾ããã
åæ
ã¡ãªã¿ã«ç§ãéçºãã¦ããã¢ããªã¯ã ãµã¼ãã¼ã®ããã»ã¹ã«å®æããããä»è¾¼ãããã« Remixããã©ã«ãã®Remix App Serverãã Expressã«å¤æ´ãã¦ãã¾ãã ãã¡ããæ å ±ã¨ãã¦è¼ãã¾ããã ããã«ãã£ã¦Upgradeã§ã¤ã¾ã¥ããããã§ã¯ããã¾ããã
ã¾ãWSL2ç°å¢ã§ä½æ¥ãã¦ãã¾ãã
Feature Flagã使ç¨ãã
ã¾ãã¯ã¬ã¤ãã®æé ã®ã¨ãããFeature Flagãæå¹ã«ãã¾ãã ããã¯æä½æ¥ã§ãããªããã°ãªããªãããã§ãã
codemodã§èªåã§ä¿®æ£ãã
大éã®ä¿®æ£ãèªåã§å ¥ãã®ã§ããããããgit commitãã¦ããã¾ãããã
codemodãã¤ãã£ã¦ããã±ã¼ã¸ã®æ´æ°ã¨ã¤ã³ãã¼ãã®æ´æ°ãèªåã§è¡ãã¾ãã
npx codemod remix/2/react-router/upgrade
ãããããã§ã¨ã©ã¼ãçºçãã¾ããã
Error: ENOENT: no such file or directory, scandir '/home/user/.codemod'
ã©ãããcodemodã¯ãã¼ã ãã£ã¬ã¯ããªä»¥ä¸ã«.codemod
ãã£ã¬ã¯ããªãä½æãã¦ããå¿
è¦ãããããã§ãã
$ mkdir $HOME/.codemod
ä¸è¨ã³ãã³ãã§ãã£ã¬ã¯ããªãä½æãã¾ãã
æ°ãåãç´ãã¦å度ã³ãã³ããå®è¡ãã¦ã¿ãã¨ä»¥ä¸ã®è¦åãåºã¾ããã
Error: libsecret-1.so.0: cannot open shared object file: No such file or directory Codemod CLI uses "keytar" to store your credentials securely. Please make sure you have "libsecret" installed on your system. Depending on your distribution, you will need to run the following command Debian/Ubuntu: sudo apt-get install libsecret-1-dev Fedora: sudo dnf install libsecret Arch Linux: sudo pacman -S libsecret
codemod ã¯ãã¦ã¼ã¶ã¼ã®èªè¨¼æ å ±ãå®å ¨ã«ä¿åããããã«ãkeytarãã¨ããã¢ã¸ã¥ã¼ã«ã使ç¨ãã¦ãã¾ãã
ãã®ã¢ã¸ã¥ã¼ã«ã¯å é¨ã§ libsecret ãå¿ è¦ã¨ãã¾ãã
ããããã·ã¹ãã ã«ãã®ã©ã¤ãã©ãªãã¤ã³ã¹ãã¼ã«ããã¦ããªããããã¨ã©ã¼ãçºçãã¦ããããã§ãã
ãã®è¦åã解æ¶ããããã«ä»¥ä¸ã®ã³ãã³ãã§libsecretãã¤ã³ã¹ãã¼ã«ãã¾ããã
sudo apt-get install libsecret-1-dev
ãããããããã¤ã³ã¹ãã¼ã«ãã¦ãã¾ãã¨no such file or directory
ã¨ã©ã¼ã§ã³ãã³ããå®è¡ã§ããªããªã£ã¦ãã¾ãã¾ããã
ã¨ã©ã¼æ å ±ãããã ãã§ãã«ã£ã¡ããã£ã¡ããããªããªã£ã¦ãã¾ãã¾ããã ã¯ã¼ã¯ã¢ã©ã¦ã³ãã¨ãã¦Dockerã§ã³ã³ãããç«ã¦ã¦ãã³ã³ããå ã§libsecretãã¤ã³ã¹ãã¼ã«ããã«codemodãå®è¡ãã¾ããã
react-routerã¨react-router-domã®ãã¼ã¸ã§ã³ã®äºææ§ä¿®æ£
ä¿®æ£ãå®äºããã®ã§ãµã¼ãã¼ãèµ·åãã¦ã¿ãã¨ããã 以ä¸ã®ããã«react-routerã¨react-router-domã®äºææ§ããªãããã¨ã©ã¼ãçºçãã¾ããã
â [ERROR] No matching export in "node_modules/react-router/dist/development/index.mjs" for import "UNSAFE_logV6DeprecationWarnings" node_modules/react-router-dom/dist/index.js:13:36: 13 â import { UNSAFE_mapRouteProperties, UNSAFE_logV6DeprecationWarnings, UNSAFE_DataRouterContext, UNSAFE_DataRouterStateContext, Router, UNSAFE_useRoutesImpl, UNSAFE_NavigationC... âµ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ â [ERROR] No matching export in "node_modules/react-router/dist/development/index.mjs" for import "UNSAFE_useRoutesImpl" node_modules/react-router-dom/dist/index.js:13:134: 13 â ...nWarnings, UNSAFE_DataRouterContext, UNSAFE_DataRouterStateContext, Router, UNSAFE_useRoutesImpl, UNSAFE_NavigationContext, useHref, useResolvedPath, useLocation, useNavig... âµ ~~~~~~~~~~~~~~~~~~~~ â [ERROR] No matching export in "node_modules/react-router/dist/development/index.mjs" for import "UNSAFE_useRouteId" node_modules/react-router-dom/dist/index.js:13:246: 13 â ...tionContext, useHref, useResolvedPath, useLocation, useNavigate, createPath, UNSAFE_useRouteId, UNSAFE_RouteContext, useMatches, useNavigation, useBlocker } from 'react-ro... âµ ~~~~~~~~~~~~~~~~~ â [ERROR] No matching export in "node_modules/react-router/dist/development/index.mjs" for import "AbortedDeferredError" node_modules/react-router-dom/dist/index.js:14:9: 14 â export { AbortedDeferredError, Await, MemoryRouter, Navigate, NavigationType, Outlet, Route, Router, Routes, UNSAFE_DataRouterContext, UNSAFE_DataRouterStateContext, UNSAFE_L... âµ ~~~~~~~~~~~~~~~~~~~~ â [ERROR] No matching export in "node_modules/react-router/dist/development/index.mjs" for import "UNSAFE_useRouteId" node_modules/react-router-dom/dist/index.js:14:237: 14 â ...text, UNSAFE_LocationContext, UNSAFE_NavigationContext, UNSAFE_RouteContext, UNSAFE_useRouteId, createMemoryRouter, createPath, createRoutesFromChildren, createRoutesFromE... âµ ~~~~~~~~~~~~~~~~~ â [ERROR] No matching export in "node_modules/react-router/dist/development/index.mjs" for import "defer" node_modules/react-router-dom/dist/index.js:14:340: 14 â ...reateMemoryRouter, createPath, createRoutesFromChildren, createRoutesFromElements, defer, generatePath, isRouteErrorResponse, json, matchPath, matchRoutes, parsePath, redi... âµ ~~~~~ â [ERROR] No matching export in "node_modules/react-router/dist/development/index.mjs" for import "json" node_modules/react-router-dom/dist/index.js:14:383: 14 â ...sFromChildren, createRoutesFromElements, defer, generatePath, isRouteErrorResponse, json, matchPath, matchRoutes, parsePath, redirect, redirectDocument, renderMatches, rep... âµ ~~~~
ãã£ããreact-routerã¨react-router-domãuninstallãã¦latestãã¤ã³ã¹ãã¼ã«ãããã¨ã§ã¨ã©ã¼ã解æ¶ãã¾ããã
$ npm uninstall react-router react-router-dom $ npm install react-router@latest react-router-dom@latest
ããã§ç¡äºèµ·åã§ãã¾ããï¼
ã¾ã¨ã
Remix v2ã§ã¢ããªãéçºãã¦1ãæç¨åº¦ããçµéãã¦ããªãã®ã«ã ããã«React Router V7ã«Upgradeããªããã°ãªããªãã£ãã®ã§ã ããããä»å¾ãç¶ãã®ã..ãã¨æã£ã¦ãã¾ããã ãããããç°¡åã«Upgradeã§ãããªãããã§ããã Remixã¯ã·ã³ãã«ã§ä½¿ããããã®ã§ãä»å¾ã®è¿½å æ©è½ãã¨ã¦ã楽ãã¿ã§ãã