fridays / next-routes

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

HMR not working when integrating next-routes #64

Closed adrianha closed 7 years ago

adrianha commented 7 years ago

Hi, I'm facing an issue that HMR is not working when using next-routes. It will do full reload instead. I already followed the example given on the readme.

Here's my implementation:

routes.js

const nextRoutes = require('next-routes');
const routes = module.exports = nextRoutes();

const localeRegExp = '(/id|/en)?';
routes.add('index', localeRegExp);
routes.add('search', `${localeRegExp}/search/:urlName`);

server.js

const routes = require('./routes');
const handler = routes.getRequestHandler(app);
const server = express();

app.prepare()
.then(() => {
  server
  .use(handler)
  .listen(3000, function (err) {
    console.log('err', err);
  })
})

Any idea about this?

fridays commented 7 years ago

Try to move the slashes out of the regex:

const localeRegExp = ':locale(id|en)?';
routes.add('index', `/${localeRegExp}`);
routes.add('search', `/${localeRegExp}/search/:urlName`);
adrianha commented 7 years ago

Hi @fridays , the issue is still occurred.. When i changed content on pages/index.js, it will do full-reload

fridays commented 7 years ago

Please provide a sample repo @adrianha

adrianha commented 7 years ago

Heres the sample repo: https://github.com/adrianha/next-routes-demo If i made changes on pages/index, it will do full reload.. @fridays You can run the repo by using: npm run dev:custom

fridays commented 7 years ago

Thanks for reporting this, please update to version 1.0.39

adrianha commented 7 years ago

Great! Thank you very much @fridays !