Next-routes: Support Next.js v8

Created on 9 Jan 2019  路  7Comments  路  Source: fridays/next-routes

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/[email protected]/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.

Most helpful comment

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

All 7 comments

@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.

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.

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

thank @EduardoHidalgo you have saved my day..

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

Can this be closed since it works in 8?

Yes 馃榾

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mocheng picture mocheng  路  5Comments

nishtacular picture nishtacular  路  3Comments

apapacy picture apapacy  路  4Comments

adrianha picture adrianha  路  3Comments

baires picture baires  路  6Comments