Description
What problem does this feature solve?
I strongly believe that an option to disable cache busting for hot-reload would solve a problem that many are having.
In loader.js:81
the this.sourceMap
always triggers the cache busting of filenames, even when trying to generate code-coverage. Where one would want to have:
- Precise filenames (without the
"?[cache-key]"
thing) - An actual SourceMap
So, at the end, ironically, when source-map is enabled in webpack, vue-loader
informs wrong filenames to code-coverage reports. For example:
/path/to/project/src/components/MyComponent.vue?7b4a5b1a
// instead of
/path/to/project/src/components/MyComponent.vue
Forcing people to do "workarounds" to get the real filename. For example:
https://github.com/mattlewis92/karma-coverage-istanbul-reporter/pull/3/files#diff-ff384da5c93b71dffa19fa30af8e2a2cR48
End user experience
Today the setup to get proper code-coverage of vue components is more complicated than it should.
With an option to disable cache busting in source-map filenames, code-coverage of .vue
files would be as easy as $ nyc mocha-webpack test/**/*.spec.js
with a reasonable simple webpack config (even without karma).
Evidence that this is a problem
There are many people struggling with this 😢 (my team included):
- https://stackoverflow.com/questions/42282102/error-output-with-karma-instanbul-coverage-reports
- https://stackoverflow.com/questions/44145417/nyc-istanbul-with-vue-vue-components
- https://github.com/mattlewis92/karma-coverage-istanbul-reporter/issues/2
- https://stackoverflow.com/questions/44454099/istanbul-instrumenter-loader-coverage-issues-dont-match-source
- Error: Unable to lookup source webpack-contrib/istanbul-instrumenter-loader#46
- https://forum.vuejs.org/t/question-about-code-coverage-with-istanbul/5270
- Problem with sourcemaps #620
(and probably others)
What does the proposed API look like?
options: {
cacheBusting: false // true by default (:
}
...
Because source-map !==
cache busting for hot-reload 😅