Next.js: HMR breaks when project is run out of a folder starting with "."

Created on 23 Oct 2017  路  3Comments  路  Source: vercel/next.js

  • [x] I have searched the issues of this repository and believe that this is not a duplicate.

Expected Behavior

Following the README.md instructions to run a next.js project, but create the project's folder in a subfolder which starts with a "."

Changing the text in index.js should initiate a recompile which is reflected in the browser.

Current Behavior

Next never recompiles after change are made to index.js. Must ctrl+c to quit, then run npm run dev again.

Steps to Reproduce (for bugs)

Please review video here: https://www.youtube.com/watch?v=HfOiCxw6bKw&feature=youtu.be
note that the project is running out a folder ".nosync" (because of this: https://discussions.apple.com/thread/6811420?start=0&tstart=0)

Context

Simply trying out next. basic HMR is not working correctly.

Your Environment


| Tech | Version |
|---------|---------|
| next |^4.1.3|
| node |8.7.0|
| OS |OSX 10.13|
| browser |Chrome 61|
| etc |npm 5.4.2|

bug

Most helpful comment

I have done a simple test to reproduce the issue and using the following steps:

  • create a folder: ~/next-tests/.hidden/test
  • npm init -y
  • npm i next react react-dom
  • add pages folder and package.json scripts (dev)
  • create pages/index.js with a minimal content (export default () => <div>Hello You</div>)
  • run npm run dev on ~/next-tests/.hidden/test
  • open browser at localhost:3000
  • change pages/index.js and save
  • no reload on browser

Now if I rename the folder to ~/next-tests/not-hidden/test then HMR works properly.

All 3 comments

I have done a simple test to reproduce the issue and using the following steps:

  • create a folder: ~/next-tests/.hidden/test
  • npm init -y
  • npm i next react react-dom
  • add pages folder and package.json scripts (dev)
  • create pages/index.js with a minimal content (export default () => <div>Hello You</div>)
  • run npm run dev on ~/next-tests/.hidden/test
  • open browser at localhost:3000
  • change pages/index.js and save
  • no reload on browser

Now if I rename the folder to ~/next-tests/not-hidden/test then HMR works properly.

This seems to be related to this line https://github.com/zeit/next.js/blob/canary/server/hot-reloader.js#L177 the regex is ignoring any path with a /.

I ran into this problem when I downloaded Next for the first time! Very annoying and almost caused me to walk away. Glad I stuck with it, and I decided to give this another look now :+1:

I've created a PR with more info #4589

This simple change seems to work for me:

const ignored = [
    '**/.*',
    'node_modules'
]
Was this page helpful?
0 / 5 - 0 ratings