-
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
fix(karma-webpack): Regression in multi-compiler mode (#390) #391
fix(karma-webpack): Regression in multi-compiler mode (#390) #391
Conversation
|
src/karma-webpack.js
Outdated
function clone(obj) { | ||
return Object.assign({}, obj); | ||
} | ||
const clone = require('lodash.clone') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better avoid using lodash.clone
(and lodash.*
), they are deprecated and don't updated a lot of time, many of them contain security problems
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you prefer to revert to full lodash
then? (or have a better suggestion?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better use full lodash
(if you use lodash
in other places in code) or you can use https://github.com/TehShrike/deepmerge
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the only place lodash would be used.
I am not even sure why we're cloning the webpack config in the first place since it's never been a deep clone, and we're mutating its attributes either way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For info, cloning was added in #48 but as you mentioned, it's a shallow clone, so it in fact does a very poor protection for the original case. I'm thinking to use https://www.npmjs.com/package/clone-deep instead, but this is temporarily blocked until jonschlinkert/shallow-clone#3 is merged and released.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any point in cloning the webpack config?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're fine using Object.assign
, can we not just do Array.isArray(obj) ? obj.map((o) => Object.assign({}, o) : Object.assign({}, obj)
- instead of introducing all of lodash
as a dependency?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean from what #48 says, I don't think Object.assign
is enough (so we should use lodash
or deepmerge
), but we should try to avoid lodash
in it's entirety - I'd pick deepmerge
personally
If you're adding/removing dependencies, can you commit |
e24a5ad
to
c44fbb1
Compare
c44fbb1
to
22eda0c
Compare
Hello, I updated the PR (took a while, sorry for that) - can you check again? For info, the build is failing with There's some unwanted diff in |
This fixes a regression introduced in [4.0.0-rc4]
See #390 for details