karma-webpack icon indicating copy to clipboard operation
karma-webpack copied to clipboard

merging cacheGroups causes confusion

Open knilink opened this issue 4 years ago • 1 comments

  • Operating System: MacOS 10.15.7
  • Node Version: 14.15.0
  • NPM Version: 6.14.0
  • webpack Version: 5.11.1
  • karma-webpack Version: 5.0.0

Expected Behavior

https://github.com/ryanclark/karma-webpack/blob/e2423b47ec59059bc1808c670affa64d0f5aa8b7/lib/karma-webpack/controller.js#L34

  • GIVEN newOptions.splitChunks.cacheGroups = {myChunk: {...}}
  • WHEN merging with karma-webpack's default webpack option
  • EXPECT options.splitChunks.cacheGroups to be {myChunk: {...}}

Actual Behavior

  • ACTUAL options.splitChunks.cacheGroups is {myChunk: {...}, commons: {..}}

Context

I'm currently debugging some sourcemap issues with coffeescript(doesn't seem to support eval sourcemap) after upgrading to webpack 5 and discovered that karma-sourcemap-loader wouldn't process split chunks which are not listed in karma preprocessors. Before, I only split out vendor files and the rest stayed in the entry chunks so it's fine. With [email protected], the commons chunk in the default config split the rest of the code from the entry and break the source map.

It may not exactly be a bug but I find it really confusing. Also, doesn't seem to have a way to unset the default one.

related issue https://github.com/ryanclark/karma-webpack/issues/489

knilink avatar Feb 10 '21 06:02 knilink

Hello,

same issue here, i want to get rid of commons cache group, and it does not seems to work.

i tried this to enforce my webpack config :

const webpackConfig = require('./webpack.config.test.js');

let DefaultWebpackOptionsFactory = require('karma-webpack/lib/webpack/defaults');

DefaultWebpackOptionsFactory.create = () => {
    return webpackConfig;
};

require.cache[require.resolve('karma-webpack/lib/webpack/defaults')].exports = DefaultWebpackOptionsFactory;

edit:

when using this solution, be sure to do webpack: {} in your karma config, to not have issue when merging

lk77 avatar Feb 22 '21 09:02 lk77

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!

codymikol avatar Oct 22 '23 01:10 codymikol