question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

If you already have lodash in your package:

{
  "name": "algolia-test",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "lodash": "^4.11.1"
  }
}

then when you npm install instantsearch.js it will download lodash 3 times again:

$ ls node_modules/**/node_modules/
node_modules/algoliasearch-helper/node_modules/:
lodash

node_modules/algoliasearch/node_modules/:
lodash

node_modules/instantsearch.js/node_modules/:
lodash

Ok… this is how npm does things when there are version conflicts, but… then when you’re building with webpack it imports all lodash again for every package (almost 2mb redundant stuff in total):

...
 [891] ./~/algoliasearch-helper/~/lodash/math/sum.js 1.35 kB {0} [built]
  [892] ./~/algoliasearch-helper/~/lodash/internal/arraySum.js 491 bytes {0} [built]
  [893] ./~/algoliasearch-helper/~/lodash/internal/baseSum.js 569 bytes {0} [built]
  [894] ./~/algoliasearch-helper/~/lodash/internal/toIterable.js 527 bytes {0} [built]
  [895] ./~/algoliasearch-helper/~/lodash/object/values.js 691 bytes {0} [built]
  [896] ./~/algoliasearch-helper/~/lodash/internal/baseValues.js 593 bytes {0} [built]
  [897] ./~/algoliasearch-helper/~/lodash/collection/includes.js 2.05 kB {0} [built]
  [898] ./~/algoliasearch-helper/~/lodash/collection/sortByOrder.js 2.06 kB {0} [built]
  [899] ./~/algoliasearch-helper/~/lodash/internal/baseSortByOrder.js 1.1 kB {0} [built]
  [900] ./~/algoliasearch-helper/~/lodash/internal/baseSortBy.js 543 bytes {0} [built]
  [901] ./~/algoliasearch-helper/~/lodash/internal/compareMultiple.js 1.62 kB {0} [built]
  [902] ./~/algoliasearch-helper/~/lodash/internal/baseCompareAscending.js 1.06 kB {0} [built]
  [903] ./~/algoliasearch-helper/~/lodash/function/partial.js 1.29 kB {0} [built]
  [904] ./~/algoliasearch-helper/~/lodash/internal/createPartial.js 619 bytes {0} [built]
  [905] ./~/algoliasearch-helper/~/lodash/function/partialRight.js 1.26 kB {0} [built]
  [906] ./~/algoliasearch-helper/src/functions/formatSort.js 587 bytes {0} [built]
  [907] ./~/algoliasearch-helper/src/SearchResults/generate-hierarchical-tree.js 5.09 kB {0} [built]
  [908] ./~/algoliasearch-helper/~/lodash/string/trim.js 1.35 kB {0} [built]
  [909] ./~/algoliasearch-helper/~/lodash/internal/charsLeftIndex.js 543 bytes {0} [built]
  [910] ./~/algoliasearch-helper/~/lodash/internal/charsRightIndex.js 516 bytes {0} [built]
  [911] ./~/algoliasearch-helper/~/lodash/internal/trimmedLeftIndex.js 501 bytes {0} [built]
  [912] ./~/algoliasearch-helper/~/lodash/internal/isSpace.js 639 bytes {0} [built]
  [913] ./~/algoliasearch-helper/~/lodash/internal/trimmedRightIndex.js 474 bytes {0} [built]
  [914] ./~/algoliasearch-helper/~/lodash/object/pick.js 1.51 kB {0} [built]
  [915] ./~/algoliasearch-helper/src/requestBuilder.js 9.41 kB {0} [built]
  [916] ./~/util/util.js 15.6 kB {0} [built]
  [917] ./~/util/support/isBufferBrowser.js 203 bytes {0} [built]
  [918] ./~/algoliasearch-helper/src/url.js 5.83 kB {0} [built]
  [919] ./~/algoliasearch-helper/src/SearchParameters/shortener.js 2.09 kB {0} [built]
  [920] ./~/algoliasearch-helper/~/lodash/object/invert.js 1.58 kB {0} [built]
  [921] ./~/qs/lib/index.js 200 bytes {0} [built]
  [922] ./~/qs/lib/stringify.js 3.91 kB {0} [built]
  [923] ./~/qs/lib/utils.js 4.32 kB {0} [built]
  [924] ./~/qs/lib/parse.js 5.36 kB {0} [built]
  [925] ./~/algoliasearch-helper/~/lodash/object/mapKeys.js 781 bytes {0} [built]
  [926] ./~/algoliasearch-helper/~/lodash/internal/createObjectMapper.js 736 bytes {0} [built]
  [927] ./~/algoliasearch-helper/~/lodash/object/mapValues.js 1.61 kB {0} [built]
  [928] ./~/algoliasearch-helper/src/version.js 41 bytes {0} [built]
  [929] ./~/instantsearch.js/~/lodash/collection/forEach.js 1.38 kB {0} [built]
  [930] ./~/instantsearch.js/~/lodash/internal/arrayEach.js 534 bytes {0} [built]
  [931] ./~/instantsearch.js/~/lodash/internal/baseEach.js 489 bytes {0} [built]
  [932] ./~/instantsearch.js/~/lodash/internal/baseForOwn.js 475 bytes {0} [built]
  [933] ./~/instantsearch.js/~/lodash/internal/baseFor.js 608 bytes {0} [built]
  [934] ./~/instantsearch.js/~/lodash/internal/createBaseFor.js 709 bytes {0} [built]
  [935] ./~/instantsearch.js/~/lodash/internal/toObject.js 308 bytes {0} [built]
  [936] ./~/instantsearch.js/~/lodash/lang/isObject.js 732 bytes {0} [built]
...

Here’s a repo with a POC: https://github.com/xarg/instantsearch.js-984

npm install
webpack --progress --display-modules

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:14 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
samousscommented, Oct 8, 2018

@Haroenv @tkrugg We should avoid to pin dependencies for the production ones.

1reaction
corentin-gautiercommented, Oct 8, 2018
  "dependencies": {
    "@agm/core": "^1.0.0-beta.3",
    "@angular/animations": "^6.1.4",
    "@angular/common": "^6.1.4",
    "@angular/compiler": "^6.1.4",
    "@angular/core": "^6.1.4",
    "@angular/forms": "^6.1.4",
    "@angular/http": "^6.1.4",
    "@angular/platform-browser": "^6.1.4",
    "@angular/platform-browser-dynamic": "^6.1.4",
    "@angular/platform-server": "^6.1.7",
    "@angular/router": "^6.1.4",
    "@ngu/carousel": "1.4.8",
    "@nguniversal/common": "^6.1.0",
    "@nguniversal/express-engine": "^6.1.0",
    "@nguniversal/module-map-ngfactory-loader": "^6.1.0",
    "@ngx-translate/core": "^10.0.2",
    "@ngx-translate/http-loader": "^3.0.1",
    "@ngx-universal/translate-loader": "^5.0.0",
    "angular-instantsearch": "^2.0.4",
    "classlist.js": "^1.1.20150312",
    "core-js": "^2.5.4",
    "hammerjs": "^2.0.8",
    "preboot": "^6.0.0-beta.6",
    "rxjs": "^6.0.0",
    "rxjs-compat": "^6.2.2",
    "zone.js": "~0.8.26"
  },

I don’t use yarn on my project, I use webpack (it’s a angular universal project)

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to get multiple key values from array with lodash?
I want to get a new object from above object but remove active key like below: var users = [{ 'user': 'barney', ...
Read more >
“Arrays” Methods - Lodash
Gets the last element or last n elements of an array. If a callback is provided elements at the end of the array...
Read more >
Lodash _.get() Method - GeeksforGeeks
object: This parameter holds the object to query. path: This parameter holds the path of the property to get. The path will be...
Read more >
Pick multiple properties · Issue #1247 · lodash/lodash - GitHub
import _ from 'lodash'; /* eslint no-underscore-dangle:0 */ export const ... it(`be able to pick multiple items from an array of objects`, ...
Read more >
Lodash sortby multiple fields - CodePen
Lodash sortby multiple fields · Raja Jaganathan Follow. Love Run. Pen Editor Menu. Settings. Change View. Use Left Layout Use Top Layout Use...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found