Skip to content

Use lodash instead of underscore#1252

Closed
Phocea wants to merge 6 commits intomarmelab:masterfrom
Phocea:Use-Lodash-instead-of-underscore
Closed

Use lodash instead of underscore#1252
Phocea wants to merge 6 commits intomarmelab:masterfrom
Phocea:Use-Lodash-instead-of-underscore

Conversation

@Phocea
Copy link
Copy Markdown
Contributor

@Phocea Phocea commented Nov 22, 2016

As discussed with @fzaninotto, reopening this PR. I have left the original implementation with a global delcared in the vendor.js since this is the solution I tested.

On latest build I am getting the error _.includes is not a function when navigating into one of my custom pages.
Following several threads on Restangular Git (one of them being mgonto/restangular#1225). I found out that Restangular is now compatible with lodash 4.

ng-admin using underscore is causing incompatibilty since the new webpack dependency version has been merged. Making use of lodash fixes the problems

package.json Outdated
"textangular": "1.4.3",
"ui-select": "0.18.1",
"underscore": "^1.8.3"
"lodash": "4.17.2"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we just need lodash.debounce, please don't add the entire lodash lib as dep.

reduce the dependency from lodash to lodash.debounce only
require('ng-file-upload');

global._ = require('underscore');
global._ = require('lodash');
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, this won't work anymore now that we don't have lodash as dependency

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know, but adding var debounce = require('lodash.debounce'); into ListLayoutController will right ?

Copy link
Copy Markdown
Contributor Author

@Phocea Phocea Dec 1, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

..actually just tested, and if I reduce this to lodash.debounce, it is ok for the core code of ng-admin but it then make all Restangular interceptor code to fail as specified in the doc... Which was the reason for this change in the first place
So not sure how this should be handled

@fzaninotto
Copy link
Copy Markdown
Member

As seen with @Phocea, lodash is used by Restangular anyway. Adding lodash.debounce is then counterproductive, since we can't reuse the full lodash. So it's better to depend on lodash than lodash.debounce.

@Phocea
Copy link
Copy Markdown
Contributor Author

Phocea commented Dec 8, 2016

Rebased and replaced by #1268

@Phocea Phocea closed this Dec 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants