parcel-bundler / parcel

The zero configuration build tool for the web. 📦🚀
https://parceljs.org
MIT License
43.38k stars 2.27k forks source link

Parcel watcher does not update / reload on second save #2716

Closed evgmel closed 4 years ago

evgmel commented 5 years ago

🐛 bug report

I had to upgrade my ParcelJS version from 1.9.3 to 1.11.0 and Babel from 6th to 7th version, because some of Babel plugins were available only on 7th version. But now when I run parcel index.html it does not make an update properly. Parcel only watches for the first changes save, makes HMR and then if I make some changes at THE SAME file again it does not affect anything. If I change another file, Parcel detects changes and makes reload, but the previous file changes does not apply at all. I have VueJS project with Pug templates (if it can be useful).

🎛 Configuration (.babelrc, package.json, cli command)

.babelrc:

{
  "presets": [
    "@babel/preset-env"
  ],
  "env": {
    "test": {
      "plugins": [
        "@babel/plugin-proposal-object-rest-spread",
        "transform-dynamic-import"
      ]
    }
  },
  "plugins": [
    "@babel/plugin-proposal-object-rest-spread",
    "@babel/plugin-syntax-dynamic-import"
  ]
}

package.json

"devDependencies": {
    "@babel/core": "^7.3.4",
    "@babel/plugin-proposal-object-rest-spread": "^7.3.4",
    "@babel/plugin-syntax-dynamic-import": "^7.2.0",
    "@babel/preset-env": "^7.3.4",
    "@vue/component-compiler-utils": "2.0.0",
    "babel-jest": "^24.1.0",
    "babel-plugin-transform-dynamic-import": "^2.1.0",
    "dotenv": "^6.2.0",
    "eslint": "^5.9.0",
    "eslint-plugin-jest": "^22.0.0",
    "eslint-plugin-vue": "^5.0.0-beta.4",
    "husky": "^1.1.4",
    "jest": "^24.1.0",
    "jest-localstorage-mock": "^2.4.0",
    "log4js": "^3.0.6",
    "node-env-run": "^3.0.2",
    "parcel-bundler": "^1.11.0",
    "pug": "2.0.3",
    "vue-template-compiler": "2.5.16"
  },
  "dependencies": {
    "@bugsnag/js": "^5.1.0",
    "@bugsnag/plugin-vue": "^5.1.0",
    "axios": "0.18.0",
    "lodash": "^4.17.11",
    "material-design-icons-iconfont": "3.0.3",
    "papaparse": "4.5.0",
    "ramda": "0.25.0",
    "sortablejs": "^1.7.0",
    "vue": "2.5.16",
    "vue-analytics": "^5.16.1",
    "vue-hot-reload-api": "2.3.0",
    "vue-router": "3.0.2",
    "vue2-filters": "^0.4.1",
    "vuetify": "1.3.8",
    "vuex": "3.0.1",
    "vuex-persist": "^2.0.0"
  }

🤔 Expected Behavior

I expect ParcelJS to update the necessary files when I save file that has changes. HMR should reload necessary modules automatically at the browser.

😯 Current Behavior

When I start parcel index.html, it waits for the first change of any file and then does HMR, changes are shown at the browser. But if I change the same file for the second and subsequent times nothing triggers the update, ParcelJS just waiting for something:

$ parcel index.html
Server running at http://localhost:1234 
✨  Built in 14.02s.
✨  Built in 638ms.

Now I need to restart parcel index.html command to have changes applied.

💁 Possible Solution

I just can guess that it could be caused not only by ParcelJS upgrade, but also by Babel components upgrade from 6th version to 7th one.

🔦 Context

My previous .babelrc content:

{
  "presets": [
    "env"
  ],
  "plugins": [
    "transform-object-rest-spread"
  ]
}

package.json dev dependencies before upgrade:

"devDependencies": {
    "@vue/component-compiler-utils": "2.0.0",
    "babel-core": "^6.26.3",
    "babel-jest": "23.4.0",
    "babel-plugin-transform-object-rest-spread": "6.26.0",
    "babel-preset-env": "1.7.0",
    "dotenv": "^6.2.0",
    "eslint": "^5.9.0",
    "eslint-plugin-jest": "^22.0.0",
    "eslint-plugin-vue": "^5.0.0-beta.4",
    "husky": "^1.1.4",
    "jest": "23.4.1",
    "jest-localstorage-mock": "^2.4.0",
    "log4js": "^3.0.6",
    "node-env-run": "^3.0.2",
    "parcel-bundler": "1.9.3",
    "pug": "2.0.3",
    "vue-template-compiler": "2.5.16"
  }

💻 Code Sample

Just any index.html file that includes separate JS file.

🌍 Your Environment

Software Version(s)
Parcel v.1.11.0
Node v10.15.1
Yarn v1.13.0
Operating System Linux Mint 19 Cinnamon
SGrondin commented 5 years ago

This appears to be a problem in chokidar. This PR fixed the problem for us: https://github.com/paulmillr/chokidar/pull/791

We're using a custom fork, with this PR applied to it.

mitar commented 5 years ago

This is documented: https://parceljs.org/hmr.html#safe-write

BTW. But yea, I dislike the idea that one should disable safe write.

evgmel commented 5 years ago

@SGrondin, @mitar Thanks for your answers! Disabling of 'Safe write' in PHPStorm preferences made it work. Hope, that future releases will fix that issue =)

devongovett commented 5 years ago

FYI, we're working on a new watcher for Parcel 2 which should be much more reliable. https://github.com/parcel-bundler/watcher

thedynabyte commented 5 years ago

@devongovett Hi there. I guess the FSEvents is the reason the watcher won't work right on Linux. Is there a published alpha of Parcel 2 maybe?

Thank you

boazblake commented 5 years ago

whats the status on this?

boazblake commented 4 years ago

Bump

On Mon, Feb 3, 2020 at 18:03 github-actions[bot] notifications@github.com wrote:

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/parcel-bundler/parcel/issues/2716?email_source=notifications&email_token=AA5IIM7U3LGI46JQR7KE3U3RBCWEDA5CNFSM4G3XQLBKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEKV3N2Q#issuecomment-581678826, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA5IIMYZYO7RAPSO64EIX23RBCWEDANCNFSM4G3XQLBA .

DeMoorJasper commented 4 years ago

@boazblake does it still happen in Parcel 2? We built a new watcher

Sent with GitHawk

samhh commented 4 years ago

@DeMoorJasper I'm a different person, but Parcel 2 seems to be working for me on Linux with (n)vim where Parcel 1 wasn't before. :smile:

DeMoorJasper commented 4 years ago

@SamHH awesome, I'll just assume it is fixed for everyone in that case.

Gonna close this, it's been inactive for 2 weeks anyway

v1d3rm3 commented 3 years ago

It's not working on Windows.

carderne commented 3 years ago

Seems like I'm experiencing this on parcel v1.22.5 on Linux.

thosakwe commented 3 years ago

Also getting this on 1.12.4 on Linux. Any known workarounds?

EDIT: Never mind, it turned out that I needed to disable safe write in my editor (vim): https://parceljs.org/hmr.html#safe-write