codymikol / karma-webpack

Karma webpack Middleware
MIT License
829 stars 222 forks source link

Temp directory path is included in #489

Closed DanielSchaffer closed 10 months ago

DanielSchaffer commented 3 years ago

Expected Behavior

The actual relative path to the source file appears in the source paths shown in stack traces.

Actual Behavior

The source path includes the temp directory used by karma-webpack, as well as a webpack: prefix (e.g. /var/folders/q1/s7h94rm52tg13mgk63qyl06c0000gn/T/_karma_webpack_361378/webpack:)

image

How Do We Reproduce?

See repro in this repository: https://github.com/DanielSchaffer/karma-webpack-source-path-repro

Run yarn and then yarn test.

Notes

My repro uses a single "bundle" approach rather than including each test file separately. There are two reasons for this - first, it allows the coverage report to include source files even if they aren't referenced via a test, which is important to be able to find source files that are completely untested. More importantly, the separate file approach has a significant amount of performance overhead with anything other than very small projects due to the difference in how Webpack ends up getting used for compilation.

When debugging, I tried manually setting my own output.path in the Webpack config, and then setting karma's urlRoot config to the same value - this produced the correct source paths, but it also broke something that prevented Karma's debug.html from being served.

A possible approach to fixing this may be finding a way to include the commons and runtime files referenced in lib/karma-webpack/framework.js without requiring Webpack's output path to be configured - possibly by using the same temp path but without setting that path in the Webpack configuration.

DanielSchaffer commented 3 years ago

Update - I was able to work around this by disabling the chunking in my Webpack configuration:

optimization: {
  splitChunks: false,
},
codymikol commented 10 months ago

As karma is now deprecated and coming up on EOL, we are no longer planning on any significant enhancements to this project and are instead going to focus on security updates, stability, and a migration path forward as karma's lifecycle comes to an end.

Thank you for supporting and using this project!