-
Notifications
You must be signed in to change notification settings - Fork 220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: use shared bundles #380
Conversation
@daKmoR FYI, this:
can be replaced by |
Does this fix #22 as well? |
uh nice I didn't knew :)
yes, CommonsChunkPlugin got "replaced/renamed" to splitChunks which is used in this implementation |
@daKmoR I'm beginning to test your branch out on our projects. I'll be commenting as I find issues. Right off the bat, using Mac (Sierra), I had to create
Once I did that, karma started running, but it seems like it's not respecting some of our custom path resolves, failing most of our tests. Still investigating if that's something caused by our setup as we are running karma through our own custom cli app, instead of directly from a project (think vue-cli), so it could be our fault. |
@dogoku thx for testing it :) I hope fix: make sure tmp folder exists solves the temp folder issue. Also I didn't deep merge custom options yet - so every option you set on karmaconfig.webpack was not applied yet. That should work after fix: allow for deep nested webpack options. => this adds a dependency to merge - it was the first thing I found - if we have a different preference which lib to use for deep left merging just let me know. |
@daKmoR thanks for the update, I'll give it a go and let you know. For merging configs, I'd suggest using https://www.npmjs.com/package/webpack-merge It's a smarter version of merge that handles functions in a much better way. If however you feel that's an overkill, a deep merge like the one you are using might be enough as well |
I'm trying your latest change, but now webpack is complaining that the configuration object is not valid, in regards to the plugins. I suspect what's happening is that the merge utility you are using is not handling the plugins correctly. Update 1: Using webpack-merge, I was able to proceed to the next step: updateWebpackOptions(newOptions) {
// this.__webpackOptions = merge.recursive(
// true,
// this.__webpackOptions,
// newOptions
// );
this.__webpackOptions = webpackMerge(
this.__webpackOptions,
newOptions
);
} I can now see everything compiling (and more importantly splitting), but Karma thinks that there are no tests to run. Will continue debugging and let you know. Update 2: Finally, some good news :D The issue of no tests being detected, was my code's issue. So with that aside, I am successfully running and passing over 80% of my tests. |
nice 👍 will change it later today 💪
awesome 🎉 |
Alright, so a few more things: Actual good news:
Potential good news:
Actual issues:1) Passing a pattern that matches a single file to {
files: [
{ pattern: 'test/unit/services/user-service/user-service-test.js' }
],
preprocessors: {
'test/unit/services/user-service/user-service-test.js': ['webpack']
},
} At the very least 2 files need to be matched by the patterns passed to preprocessor. E.g {
files: [
{ pattern: 'test/unit/services/user-service/user-service-test.js' }
],
preprocessors: {
// A glob that matches atleast 2 files
'test/unit/**/*-test.js': ['webpack'],
// OR 2 individual entries
'test/unit/services/user-service/user-service-test.js': ['webpack'],
'test/unit/services/data-service/data-service-test.js': ['webpack']
},
} 2) All files matched by the patterns in From the 2nd example above, Perhaps, we can cross-reference Potential issues1) Watch mode was not waiting for all plugins to finish work and resulted in webpack compiling multiple times whenever I saved This one is hard to explain, I need to spend more time debugging our custom plugins to make sure it's not them, before I can give you a clear case to work against. 2) Bundle sizes seem bigger than what they should, (some chunks are over 2MB) I'm guessing it's That's all for now. I'll update this post, as I have more details on each problem. |
Having an issue with a Typescript project. The bugIn The cause
SolutionIt seems that using |
First, thank you for this awesome test feedback 💪
Use it via via 238744d
fixed via 8f08ba4
yeah seems I was a little eager with that one... turned the logic around... get all files first and then filter by preprocessor patterns via 34b2342
which plugins are we talking about here? other karma preprocessors? or webpack plugins?
that seems weird - all the common parts (incl. babel polyfill should be within the commons.js) so commons.js should be big but each test file should only contain stuff unique to it |
@matthieu-foucault
that could be "problematic" how do you do the typescript processing? is it a karma preprocessor or a separate build process? |
Seeing these warnings down the line: |
With a webpack loader ( |
yes pls :) I don't have a typescript project using karma at hand 🙈 |
@daKmoR the latest version fixed both problems I mentioned above, build seems considerably faster now, and since very few chunks are generated 👍 I am now trying to make the output of webpack less verbose, but so far it's ignoring any |
@daKmoR : here's a minimal example allowing you to test the issue with Typescript: https://github.com/matthieu-foucault/ts-karma-webpack-test |
via bf966f0 it's now mimicking the webpack-cli for stats so you can configure whatever you want 👍 What do you think would be good defaults? stats: {
modules: false,
colors: true,
},
thx will take a look 🤗 |
@matthieu-foucault via 5a05452 it now forces *.js files by default and also allows you to add your own via solution inspired by karma-coffee-preprocessor |
Personally, I like to turn off logging during tests, using |
Did we now reach a point where it makes sense to update this PR to become merge worthy (e.g. update Readme, clean up history, anything else?) |
I'd say it's a good enough beta. We have managed to make all our tests green (the ones failing where not cleaning up properly). Our stack includes: mocha, chai, chai-as-promised, sinon-chai, rewiremock (which requires a webpack plugin), custom webpack plugins (for localisation, config injection, etc). Being able to run all of that means it should handle most things we throw at it. There's still a couple of things I want to test when in debug (watch) mode, but I have been busy with a different issue. The question becomes, when can we release this, given v4 is still in RC and given the Typescript rewrite initiative |
I agree, not an RC yet
Whenever you want, it's a beta. v4 still has some bugs I would like to fix (#100, #337, #272), but I have no issue with v5 moving forward before v4 is released |
It will all be squashed into one commit, so don't worry about cleaning up history. |
733dbe1
to
6c73423
Compare
I feel more comfortable doing it myself 🙈
did that and updated readme - anything else? => if not it would be really nice to have a 5.0.0 alpha/beta/... release |
Looks good. I'll make an |
BREAKING CHANGE: webpack needs to be added to frameworks ``` // old: frameworks: ['mocha'], // new: frameworks: ['mocha', 'webpack'], ``` BREAKING CHANGE: old alternative usage is no longer recommended BREAKING CHANGE: webpack-dev-middleware removed BREAKING CHANGE: default webpack configuration changed drastically
6c73423
to
997c955
Compare
did a small Readme change
uh nice looking forward to it :) |
thanks both for your hard work <3 |
Alright! It's available under the |
thx for the release :) and that sound like a very awesome move forward :) count me in :) |
greetings from 2020, does this approach work well from folks who have tried it? Wondering if it's better to switch to the forever-beta |
Yes, it has been working for us without any issues for a while now. It's been so long I forgot it was in beta still... |
This PR contains a:
Motivation / Use-Case
Refactor karma-webpack to create bundles not in isolation.
For the full story pls see this issue: #379
Breaking Changes
Additional Info
I am aware that this is a huge refactor and while working on this feature I sort of already expected that it will end up with something like this. Again pls check the issue for how we ended up here.
This also removed the build step (don't think it's needed anymore) so we can easily test it as follows.
Howto test
easiest way:
Possible ways to move forward
I see still some mandatory tasks:
Some initially optional tasks:
closes: #379