hozana / next-translate-routes

Flexible and translated routes for Next.js without custom server
MIT License
115 stars 30 forks source link

Add Next 13 support #52

Closed semy closed 1 year ago

semy commented 2 years ago

At the moment I get the following error when I update to NextJS 13.0.3:

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string or an instance of Buffer or URL. Received undefined at Object.readdirSync (node:fs:1446:10) at getAllRoutesFiles (/Users/.../node_modules/next-translate-routes/plugin/routesFiles.js:46:39)

netdown commented 2 years ago

src/plugins/routesFiles.ts line 17 should be changed to: directoryPath = findPagesDir(process.cwd()).pagesDir,

Note that this is the TS file, if you want to make a temporary and dirty fix, you must change the compiled js file.

EDIT: The same in parsePages.ts file line 59: var directoryPath = propDirectoryPath || (0, find_pages_dir_1.findPagesDir)(process.cwd()).pagesDir;

cvolant commented 2 years ago

I fixed the directoryPath issue in 1.9.1, but it is unfortunately not enough to really support next 13, even though it may seem to while navigating.

Next 13 introduce 2 new features that need a lot of work on next-translate-routes: app/ directory, and optimistic navigation (don't ask me what is it...). The first step is optimistic navigation, so that we can update next and benefit from bug fixes, event if we cannot use app/directory for now. Any help on that would be much appreciated, even if it is "merely" explaining here what is optimistic navigation.

cvolant commented 1 year ago

Next 13 is now supported, but not the /app folder yet.

Please open a new issue if you experience some bugs with Next 13 using /pages folder.