Skip to content

Commit

Permalink
deps(lodash): use individual lodash modules to reduce bundle size (#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
connorjclark committed May 9, 2022
1 parent cf91bdd commit b92ea8d
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 16 deletions.
4 changes: 1 addition & 3 deletions lighthouse-cli/test/smokehouse/frontends/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,11 @@

/* eslint-disable no-console */

import _ from 'lodash';
import cloneDeep from 'lodash/cloneDeep.js';

import smokeTests from '../core-tests.js';
import {runSmokehouse, getShardedDefinitions} from '../smokehouse.js';

const {cloneDeep} = _;

/**
* @param {Smokehouse.SmokehouseLibOptions} options
*/
Expand Down
4 changes: 1 addition & 3 deletions lighthouse-cli/test/smokehouse/frontends/smokehouse-bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import path from 'path';
import fs from 'fs';
import url from 'url';

import _ from 'lodash';
import cloneDeep from 'lodash/cloneDeep.js';
import yargs from 'yargs';
import * as yargsHelpers from 'yargs/helpers';
import log from 'lighthouse-logger';
Expand All @@ -26,8 +26,6 @@ import {runSmokehouse, getShardedDefinitions} from '../smokehouse.js';
import {updateTestDefnFormat} from './back-compat-util.js';
import {LH_ROOT} from '../../../../root.js';

const {cloneDeep} = _;

const coreTestDefnsPath =
path.join(LH_ROOT, 'lighthouse-cli/test/smokehouse/core-tests.js');

Expand Down
4 changes: 1 addition & 3 deletions lighthouse-cli/test/smokehouse/report-assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@
* against the results actually collected from Lighthouse.
*/

import _ from 'lodash';
import cloneDeep from 'lodash/cloneDeep.js';
import log from 'lighthouse-logger';

import {LocalConsole} from './lib/local-console.js';
import {chromiumVersionCheck} from './version-check.js';

const {cloneDeep} = _;

/**
* @typedef Difference
* @property {string} path
Expand Down
2 changes: 1 addition & 1 deletion lighthouse-core/config/config-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
'use strict';

const path = require('path');
const {isEqual: isDeepEqual} = require('lodash');
const isDeepEqual = require('lodash/isEqual.js');
const constants = require('./constants.js');
const Budget = require('./budget.js');
const ConfigPlugin = require('./config-plugin.js');
Expand Down
4 changes: 2 additions & 2 deletions lighthouse-core/fraggle-rock/gather/base-artifacts.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
'use strict';

const log = require('lighthouse-logger');
const {isEqual} = require('lodash');
const isDeepEqual = require('lodash/isEqual.js');
const {
getBrowserVersion,
getBenchmarkIndex,
Expand Down Expand Up @@ -58,7 +58,7 @@ function deduplicateWarnings(warnings) {
const unique = [];

for (const warning of warnings) {
if (unique.some(existing => isEqual(warning, existing))) continue;
if (unique.some(existing => isDeepEqual(warning, existing))) continue;
unique.push(warning);
}

Expand Down
4 changes: 2 additions & 2 deletions lighthouse-core/lib/arbitrary-equality-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
'use strict';

const {isEqual} = require('lodash');
const isDeepEqual = require('lodash/isEqual.js');

/**
* @fileoverview This class is designed to allow maps with arbitrary equality functions.
Expand Down Expand Up @@ -74,7 +74,7 @@ class ArbitraryEqualityMap {
* @return {boolean}
*/
static deepEquals(objA, objB) {
return isEqual(objA, objB);
return isDeepEqual(objA, objB);
}
}

Expand Down
2 changes: 1 addition & 1 deletion lighthouse-core/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
'use strict';

const {isEqual: isDeepEqual} = require('lodash');
const isDeepEqual = require('lodash/isEqual.js');
const Driver = require('./gather/driver.js');
const GatherRunner = require('./gather/gather-runner.js');
const ReportScoring = require('./scoring.js');
Expand Down
3 changes: 2 additions & 1 deletion shared/localization/swap-locale.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
*/
'use strict';

const {set: _set, get: _get} = require('lodash');
const _set = require('lodash/set.js');
const _get = require('lodash/get.js');

const format = require('./format.js');

Expand Down

0 comments on commit b92ea8d

Please sign in to comment.