fridays / next-routes

Universal dynamic routes for Next.js
MIT License
2.47k stars 230 forks source link

Support Next.js v8 #274

Closed jaydenseric closed 5 years ago

jaydenseric commented 5 years ago

next-routes imports from next/link:

https://github.com/fridays/next-routes/blob/1.4.2/src/index.js#L4

But in Next.js v8.0.0-canary.3 that file contains ESM, presumably because Next.js expects it will always be imported within a Next.js project via a Webpack build:

https://unpkg.com/next@8.0.0-canary.3/dist/client/link.js

That causes this runtime error on the server:

[redacted]/node_modules/next/dist/client/link.js:2
import { resolve, format, parse } from 'url';
       ^

SyntaxError: Unexpected token {

Presumably import NextRouter from 'next/router' would have the same issue.

jaydenseric commented 5 years ago

@timneutkens would you consider this a Next.js v8 bug?

Side note; you can ship ESM and CJS side by side using .js/.mjs, and Webpack (along with Node.js in --experimental-modules mode) will resolve the .mjs file first.

timneutkens commented 5 years ago

This is still on my list of things to fix on the Next.js side. However next-routes is importing next/link inside the custom server, which is slightly weird/wrong anyway.

EduardoHidalgo commented 5 years ago

this issue was fixed by 8.0.0-canary.7 (: i validated.

amankakar commented 5 years ago

thank @EduardoHidalgo you have saved my day..

fridays commented 5 years ago

Thank you! Yeah Link in the custom server doesn't make sense, it's not used there at all, it's just in the same file. PR welcome

corysimmons commented 5 years ago

Can this be closed since it works in 8?

EduardoHidalgo commented 5 years ago

Yes 😀