Parcel: 馃檵watch bundle add "poll" option

Created on 16 Jan 2018  路  8Comments  路  Source: parcel-bundler/parcel

In Docker container on Windows, it cannot rebuild when files changed, so I need poll files to know whether they are changed. It is similar to webpack watch's option "poll".

refrence: https://webpack.js.org/configuration/watch/#watchoptions-poll

馃 Expected Behavior

Just like webpack, I can config a param named "poll",which is a millisecond.

馃槸 Current Behavior

Now there is no option.

馃敠 Context

馃實 Your Environment

| Software | Version(s) |
| ---------------- | ---------- |
| Parcel | 0.0.1
| Node | 8.9.3
| npm/Yarn | 5.5.1
| Operating System | windows 10

Help Wanted Feature

Most helpful comment

It is possible to set polling for chokidar via environment variables. I am in a similiar situation where I need to work on a windows machine with a docker development setup.

An example for setting polling via docker-compose.yml:

version: '2'
services:
  web:
    build: .
    command: yarn start
    ports:
     - "1234:1234"
     - "49359:49359"
    volumes:
    - .:/code
    environment:
    - CHOKIDAR_USEPOLLING=1

see chokidar docs

It is also possible to set the polling interval CHOKIDAR_INTERVAL=1

All 8 comments

Can we automatically detect the need to poll somehow? I would prefer not adding a million options if we can choose the right default automatically.

Without getting pretty deep into the weeds, it may be hard to detect the conditions where you would need to use polling. The problem is that inotify WILL work, but it will only see local changes. So for example, if you exec into the container and touch a file, it will catch it, but if you change it externally nothing will happen.

The best solution I can imagine would be UNIX specific and would basically consist of the following:

  • When watching a file, detect the mount point it is nearest.
  • Detect the filesystem of the mountpoint.
  • If the filesystem is known to have broken inotify support, punt back to polling for that file. Examples: cifs, nfs, vboxsf will all have trouble with inotify.

This may actually be worth an option though...

It is possible to set polling for chokidar via environment variables. I am in a similiar situation where I need to work on a windows machine with a docker development setup.

An example for setting polling via docker-compose.yml:

version: '2'
services:
  web:
    build: .
    command: yarn start
    ports:
     - "1234:1234"
     - "49359:49359"
    volumes:
    - .:/code
    environment:
    - CHOKIDAR_USEPOLLING=1

see chokidar docs

It is also possible to set the polling interval CHOKIDAR_INTERVAL=1

@marcklei - that's a great find, thanks for sharing! Parcel also supports dotenv if you'd rather define the environment variable alongside you project as opposed to your machine configuration.

Wow, I looked at the Chokidar source code and 100% missed this even though I was looking for it. Thanks for the tip, this is hugely useful for me!

Closing in favor of using CHOKIDAR_USEPOLLING=1 which seems favorable to the flag anyways since it can be set in a config file.

@brandon93s even with CHOKIDAR_USEPOLLING though, hot reloading does not work. Does anyone have any solution to that?

@brandon93s even with CHOKIDAR_USEPOLLING though, hot reloading does not work. Does anyone have any solution to that?

Maybe this can work for you.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

devongovett picture devongovett  路  3Comments

oliger picture oliger  路  3Comments

termhn picture termhn  路  3Comments

davidnagli picture davidnagli  路  3Comments

466023746 picture 466023746  路  3Comments