-
Notifications
You must be signed in to change notification settings - Fork 19
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
Remove lodash as a dependency #35
Conversation
package.json
Outdated
@@ -32,24 +31,24 @@ | |||
"broccoli-asset-rev": "2.6.0", | |||
"ember-ajax": "3.0.0", | |||
"ember-bootstrap": "1.2.0", | |||
"ember-cli": "~3.0.0-beta.2", | |||
"ember-cli": "^3.1.4", |
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.
Please dont use ^
in packages.
addon/services/rollbar.js
Outdated
@@ -34,7 +34,7 @@ export default Service.extend({ | |||
}).readOnly(), | |||
|
|||
rollbarClient(customConfig = {}) { | |||
let config = deepMerge({}, this.get('config'), customConfig); | |||
let config = merge({}, this.get('config'), customConfig); |
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 is a big difference between merge and deepMerge :/ We definitely need the second one.
package.json
Outdated
@@ -23,7 +23,6 @@ | |||
}, | |||
"dependencies": { | |||
"ember-cli-babel": "6.11.0", | |||
"ember-lodash": "4.18.0", |
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.
Maybe we can just use lodash.merge
package and shim it.
package.json
Outdated
"ember-cli-dependency-checker": "2.1.0", | ||
"ember-cli-eslint": "4.2.3", | ||
"ember-cli-fastboot": "1.1.3", | ||
"ember-cli-favicon": "1.0.0-beta.4", | ||
"ember-cli-favicon": "^1.0.0", |
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.
no upgrades please in this PR
@Exelord moving In regards to the deep merge, if that's needed for merging Rollbar configs, maybe some test coverage there would be good? I can add that; I just couldn't think of the use case. |
Can we move it to devDependencies? We are using it in production code, to it has to be compiled using this packages. Yes we need that. If you'll look here https://github.com/Exelord/ember-rollbar-client/blob/master/config/environment.js {
payload: {
test: true,
}
} and passing in rollbar service: {
payload: {
test2: true,
}
} will result: {
payload: {
test2: true,
}
} which will overwrite the object and remove the |
Thanks for the explanation @Exelord that was really helpful. I missed the part of the readme that specified users could create a new Rollbar instance, thus requiring the deep merge. I added a test for that and brought in just We could always add our own implementation of a deep merge, something like this is probably sufficient and passes the test. |
haha, I was gonna write a merge function tonight, as that should be doable in just a few lines of code - given that we very likely do not need very complex logic to just merge the configs. Great you already found something that works. Totally in favour of removing lodash though. I was wondering where that dependency comes from in our app a few days ago, but did not have the time to look further into it so far. Needless to say that it was significantly increasing the size of our app. |
package.json
Outdated
@@ -55,7 +54,7 @@ | |||
"ember-maybe-import-regenerator": "^0.1.6", | |||
"ember-resolver": "4.5.0", | |||
"ember-scroll-to": "0.6.4", | |||
"ember-source": "~3.0.0-beta.6", | |||
"ember-source": "~2.12.0", |
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.
Why we downgraded?
@@ -29,6 +30,27 @@ test('currentUser', function(assert) { | |||
assert.equal(service.get('notifier.options.payload.person.name'), 'User'); | |||
}); | |||
|
|||
test('new rollbar client - deep merge config', function(assert) { |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
addon/-private/deepMerge.js
Outdated
@@ -0,0 +1,52 @@ | |||
// from https://github.com/tchak/ember-fetch-adapter/blob/master/addon/-private/merge.js |
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 should be an util under addon/utils/deep-merge.js
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.
And why we dont use here a lodash one?
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.
Anyway we need full pack of tests for it
addon/-private/deepMerge.js
Outdated
@@ -0,0 +1,52 @@ | |||
// from https://github.com/tchak/ember-fetch-adapter/blob/master/addon/-private/merge.js |
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.
And why we dont use here a lodash one?
addon/-private/deepMerge.js
Outdated
@@ -0,0 +1,52 @@ | |||
// from https://github.com/tchak/ember-fetch-adapter/blob/master/addon/-private/merge.js |
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.
Anyway we need full pack of tests for it
@Exelord pr feedback addressed. Per your feedback, I reverted the If you know of a better way to shim that in, let me know. I also left the deep merge config test, since you don't have tests anywhere else for that. If you'd like me to move it or add coverage, please help me by identifying some use cases of merging rollbar configs. |
Thank you! All looks good! There is just one thing. There is a difference between ember-cli-cjs-transform and ember-auto-import. Once is for transforming cjs modules to es6 and the second one allows you import dynamically node modules. Thats why in that case I would prefer to go with auto-import as cjs-transform is not needed here as this package already export es6 module. |
@Exelord understood, i was hesitant to use |
Well it depends if we want to still support ember 2.12. What do you think? |
I think that's up to you, but I don't believe |
Ok I have a solution. Lets manually push it to vendor folder and import from there. The same as we do with rollbar. check |
I would vote for dropping 2.12 support. It's about time to do so (almost 3.4 is here). |
I think we should drop it when Ember-cli will do it, so that we can keep compatibility with everything supported by ember officially. It should be deprecated |
Agree. So few more days left and Lodash is completely gone :) ? |
Probably :) ... well Lodash will be still with us ;) ... but just one module |
package.json
Outdated
"git-repo-version": "1.0.2", | ||
"lodash.merge": "^4.6.1", |
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.
Could you change ^
to ~
?
package.json
Outdated
@@ -24,8 +24,9 @@ | |||
"dependencies": { | |||
"broccoli-funnel": "^2.0.1", | |||
"ember-cli-babel": "6.11.0", | |||
"ember-lodash": "4.18.0", | |||
"ember-cli-cjs-transform": "^1.3.0", |
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.
Could you change ^
to ~
?
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.
@Exelord are we sticking with ember-cli-cjs-transform
or going the vendor route? I pushed your recent feedback here, but if you want to go the vendor route, I'll need some more guidance there.
I'm not as familiar with broccoli trees; I follow bringing in the dependency through the vendor tree, but it's unclear how to import it in the service.
addon/services/rollbar.js
Outdated
@@ -2,7 +2,7 @@ import { getOwner } from '@ember/application'; | |||
import { computed } from '@ember/object'; | |||
import Service from '@ember/service'; | |||
import Rollbar from 'rollbar'; | |||
import deepMerge from 'lodash/merge'; | |||
import merge from 'lodash.merge'; |
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.
can we rename it to deepMerge
? it's more meaningful to what it does.
Perfect :) Lets wait then for Ember 2.12 deprecation |
I see in ember-cli 3.4 there is still support for 2.12 :/ |
can we please remove that lodash thing one way or the other? That dependency is large enough to make us switch to another rollbar client (or publish just another one |
Conflicts |
@Exelord any ideas on the CI failures? |
Try to remove this thing: |
It looks like this issue is on travis or sth. I see its everywhere without any change on multiple projects |
Any updates from travis ? I've check logs, configs, code and couldn't find any problems with it. Did you try run this again @Exelord ? Great job with this pull request btw ! |
Restarted one more time. (clean cache) |
Eh... ok merging that. Tests are not related |
is there a chance to make a release for it ? |
#40 This one should fix the tests |
Fixes #34 by removing
lodash
and replacing with Ember'smerge
polyfill. I played it safe here instead of just usingObject.assign
, but feel free to modify depending on how many browsers you need to support.