parcel: JavaScript file hash doesn't change when dependency filename changed
π bug report
I noticed that a new JavaScript file was generated with the same name as the old one, even though its contents had changed.
π Configuration (.babelrc, package.json, cli command)
I created a sample project in this repository:
https://github.com/dobesv/parcel-import-bug
π€ Expected Behavior
If the contents of a generated JavaScript file change in any significant way, so should the hash in its filename.
π― Current Behavior
As you can see in the below transcript, the contents of the generated JavaScript file are modified, but its hash doesnβt change.
$ echo a>template5.html
$ parcel build index.html -d dist-a
β¨ Built in 1.24s.
dist-a/parcel-import-bug.a9b3581e.js 299.6 KB 19.34s
dist-a/controller.1cfadc83.js 87.37 KB 220ms
dist-a/controller.343f9052.js 1.23 KB 173ms
dist-a/index.html 245 B 5ms
dist-a/parcel-import-bug.bfb7fe78.urls 31 B 102ms
dist-a/test.ae9c52ee.css 20 B 12ms
dist-a/template5.7deadfab.html 2 B 193ms
dist-a/parcel-import-bug.bfb7fe78.json 0 B 103ms
dist-a/controller.343f9052.map 0 B 209ms
dist-a/parcel-import-bug.e3817f33.map 0 B 19.26s
dist-a/controller.1cfadc83.map 0 B 255ms
$ echo b>template5.html
$ parcel build index.html -d dist-b
β¨ Built in 1.30s.
dist-b/parcel-import-bug.a9b3581e.js 299.6 KB 20.44s
dist-b/controller.1cfadc83.js 87.37 KB 227ms
dist-b/controller.343f9052.js 1.23 KB 182ms
dist-b/index.html 245 B 3ms
dist-b/parcel-import-bug.bfb7fe78.urls 31 B 102ms
dist-b/test.ae9c52ee.css 20 B 15ms
dist-b/template5.fc4c8ece.html 2 B 190ms
dist-b/parcel-import-bug.bfb7fe78.json 0 B 101ms
dist-b/controller.343f9052.map 0 B 217ms
dist-b/parcel-import-bug.e3817f33.map 0 B 20.34s
dist-b/controller.1cfadc83.map 0 B 260ms
(env) 13:40:40 ~/parcel-import-bug
$ diff dist-a/parcel-import-bug.a9b3581e.js dist-b/parcel-import-bug.a9b3581e.js
474,475c474,475
< module.exports={html:"/template5.7deadfab.html"};
< },{"./template5.html":[["template5.7deadfab.html",198],198]}],202:[function(require,module,exports) {
---
> module.exports={html:"/template5.fc4c8ece.html"};
> },{"./template5.html":[["template5.fc4c8ece.html",198],198]}],202:[function(require,module,exports) {
π Possible Solution
Not clear yet why this is the case. Maybe the hash in the filename isnβt calculated from the file contents, but something else?
π¦ Context
When deploying a new version of the app, I assume that the filenames will change when their contents do, and set long cache expiry times on those files. If this assumption is broken, our app fails to load or various other weird problems can occur.
π» Code Sample
https://github.com/dobesv/parcel-import-bug
π Your Environment
Software | Version(s) |
---|---|
Parcel | 1.8.1 |
Node | 9.11.1 |
npm/Yarn | 1.6.0 |
Operating System | Ubuntu Xenial (Linux Mint) |
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 8
- Comments: 24 (15 by maintainers)
Commits related to this issue
- Use monkey patcher to always rename the js files in case of dependency changes https://github.com/parcel-bundler/parcel/pull/2179 https://github.com/parcel-bundler/parcel/issues/1481 — committed to Opetushallitus/koski by jrantanen 3 years ago
- Use monkey patcher to always rename the js files in case of dependency changes https://github.com/parcel-bundler/parcel/pull/2179 https://github.com/parcel-bundler/parcel/issues/1481 — committed to Opetushallitus/koski by jrantanen 3 years ago
- Use monkey patcher to always rename the js files in case of dependency changes https://github.com/parcel-bundler/parcel/pull/2179 https://github.com/parcel-bundler/parcel/issues/1481 — committed to Opetushallitus/koski by jrantanen 3 years ago
I have submitted a fix but it has not been accepted or rejected. Not sure what else to do here. I do wonder why so few people are complaining about this issue, though. Maybe itβs not as bad as it seems and thereβs just something we few are doing wrong.
this is a huge issue ; it makes caching with code splitting impossible.
Closing. Please use parcel 2.
I created a plugin for this as a temporary workaround for anyone affected by this issue. https://github.com/dobesv/parcel-plugin-bundle-deep-hash
https://github.com/parcel-bundler/parcel/pull/2179
My suggestion, to be frank, is to not use Parcel. I have this one project that uses parcel and I regret using it. Iβve been using Webpack in other projects and itβs better in every way except initial setup effort.