Code Monkey home page Code Monkey logo

Comments (17)

jayrmotta avatar jayrmotta commented on May 18, 2024 47
const devConfig = require('./webpack.dev.config');

const commonsChunkPluginIndex = devConfig.plugins.findIndex(plugin => plugin.chunkNames);
devConfig.plugins.splice(commonsChunkPluginIndex, 1);

// ...

webpack: devConfig,

// ...

I had to do this because my webpack.dev.config inherits from a common one which loads the CommonsChunkPlugin. This is not pretty but it's working 😄

from karma-webpack.

simple10 avatar simple10 commented on May 18, 2024 24

I was also running into this when using CommonsChunkPlugin in webpack. Disabling CommonsChunkPlugin when running in karma works.

from karma-webpack.

sokra avatar sokra commented on May 18, 2024 12

CommonsChunkPlugin is not compatible with karma-webpack. Just remove it.

CommonsChunkPlugin is only an optimization, it doesn't have effect on the executation.

from karma-webpack.

CobeLapierre avatar CobeLapierre commented on May 18, 2024 6

You can solve this problem by changing the order of your files loaded into your Karma browser.

karma.conf.js

files: [
'build/shared.js',
'build/*/.js',
]
Shared (in my case) is the file where "webpackJsonp" is defined. By putting this one at the top of the files it will be loaded before the other js files. Solving the error of CommonChunksPlugin.

from karma-webpack.

jotaoncode avatar jotaoncode commented on May 18, 2024 4

It seems that @carbosound1 could be right. I saw a little implementation of what he says. Although it would be great If @carbosound1 share a repo with CommonsChunksPlugins working correctly with karma, so he can bring to light how to solve this issue.

from karma-webpack.

DaveEmmerson avatar DaveEmmerson commented on May 18, 2024 1

@carbosound1 is definitely correct. If you just look at your bundles and find the one that defines webpackJsonp, then put that first in your karma config's files, you're fine. The one passed to the CommonChunksPlugins constructor in the webpack config did the trick here.

from karma-webpack.

joshwiens avatar joshwiens commented on May 18, 2024 1

The ability to use commons chunk will be covered in v3 and by use, I mean not having to remove it for those that don't want to run multiple webpack configs. As Tobias said above, CommonsChunk has not real effect on execution.

There is an open issue for this already in the milestone & @jayrmotta has a viable work around here - #24 (comment)

from karma-webpack.

sokra avatar sokra commented on May 18, 2024

Can you post your configuration?

from karma-webpack.

rodleviton avatar rodleviton commented on May 18, 2024

I am having the same issue and removing CommonsChunkPlugin temporarily fixes issue. Any idea how to make this work with CommonsChunkPlugin?

from karma-webpack.

sokra avatar sokra commented on May 18, 2024

Any idea how to make this work with CommonsChunkPlugin?

CommonsChunkPlugin doesn't change the behavior, it's only for optimized loading. So disabling is propably the best way.

from karma-webpack.

OEvgeny avatar OEvgeny commented on May 18, 2024

I have this issue too. Tried to use CommonsChunkPlugin to separate third party libraries from tests, but no luck.

from karma-webpack.

mrsum avatar mrsum commented on May 18, 2024

So, maybe somebody know how can i organize separated vendors.js and *.spec.js files?
I think it's good for performance cause if project has more than 100 specs file, and all files has contains all vendors code with test describes and testable code – in my case is ~2mb per each file.
Simple calculations will representative. 2 * 100 ~= 200mb of code where 98% lines will be duplicate.

from karma-webpack.

joeyrobert avatar joeyrobert commented on May 18, 2024

I've seen this error when using webpack-split-by-path also. Not sure if that uses CommonsChunksPlugins under the hood, but removing it fixes the issue.

from karma-webpack.

begincalendar avatar begincalendar commented on May 18, 2024

I'm also using webpack-split-by-path, but I'm not using the CommonsChunkPlugin.

I think the problem for me is that I can't specify the vendor bundle in the files config option, because it doesn't exist at the time when Karma tries to find it, but instead is created after webpack pre-processing.

@joeyrobert How are you using webpack-split-by-path and ensuring that the vendor bundle gets loaded before anything else?

from karma-webpack.

BuonOmo avatar BuonOmo commented on May 18, 2024

There is an open issue for this already in the milestone

For these who are trying to find it in order to suscribe the issue, it is #22.

from karma-webpack.

DmitryGonchar avatar DmitryGonchar commented on May 18, 2024

@jayrmotta Why not use plugin instanceof webpack.optimize.CommonsChunkPlugin instead of detecting type by whether it has a property?

from karma-webpack.

albancho avatar albancho commented on May 18, 2024

I did this piece of code to remove a list of plugins (only one for now, but who knows...), based on plugin.constructor.name:

const disabledPluginNames = [
  'CommonsChunkPlugin'
]
let generatedCommonConfig = commonConfig(envOptions);
generatedCommonConfig.plugins = generatedCommonConfig.plugins.filter(plugin => !disabledPluginNames.some(pluginName => pluginName === plugin.constructor.name));
return generatedCommonConfig;

from karma-webpack.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.