From b92ea8dc81d112d7e38cf9bbf049d52cd8c6a87e Mon Sep 17 00:00:00 2001 From: Connor Clark Date: Wed, 27 Apr 2022 12:39:16 -0700 Subject: [PATCH] deps(lodash): use individual lodash modules to reduce bundle size (#13914) --- lighthouse-cli/test/smokehouse/frontends/lib.js | 4 +--- lighthouse-cli/test/smokehouse/frontends/smokehouse-bin.js | 4 +--- lighthouse-cli/test/smokehouse/report-assert.js | 4 +--- lighthouse-core/config/config-helpers.js | 2 +- lighthouse-core/fraggle-rock/gather/base-artifacts.js | 4 ++-- lighthouse-core/lib/arbitrary-equality-map.js | 4 ++-- lighthouse-core/runner.js | 2 +- shared/localization/swap-locale.js | 3 ++- 8 files changed, 11 insertions(+), 16 deletions(-) diff --git a/lighthouse-cli/test/smokehouse/frontends/lib.js b/lighthouse-cli/test/smokehouse/frontends/lib.js index 67a523732e2c..a344aeb502d8 100644 --- a/lighthouse-cli/test/smokehouse/frontends/lib.js +++ b/lighthouse-cli/test/smokehouse/frontends/lib.js @@ -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 */ diff --git a/lighthouse-cli/test/smokehouse/frontends/smokehouse-bin.js b/lighthouse-cli/test/smokehouse/frontends/smokehouse-bin.js index 7c99745f1065..959b390a9630 100644 --- a/lighthouse-cli/test/smokehouse/frontends/smokehouse-bin.js +++ b/lighthouse-cli/test/smokehouse/frontends/smokehouse-bin.js @@ -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'; @@ -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'); diff --git a/lighthouse-cli/test/smokehouse/report-assert.js b/lighthouse-cli/test/smokehouse/report-assert.js index e429529a25e1..7f2c5233ede4 100644 --- a/lighthouse-cli/test/smokehouse/report-assert.js +++ b/lighthouse-cli/test/smokehouse/report-assert.js @@ -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 diff --git a/lighthouse-core/config/config-helpers.js b/lighthouse-core/config/config-helpers.js index 2e49f663ad74..090ddb2b5253 100644 --- a/lighthouse-core/config/config-helpers.js +++ b/lighthouse-core/config/config-helpers.js @@ -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'); diff --git a/lighthouse-core/fraggle-rock/gather/base-artifacts.js b/lighthouse-core/fraggle-rock/gather/base-artifacts.js index 1f6dbd448320..9478e7f394b4 100644 --- a/lighthouse-core/fraggle-rock/gather/base-artifacts.js +++ b/lighthouse-core/fraggle-rock/gather/base-artifacts.js @@ -6,7 +6,7 @@ 'use strict'; const log = require('lighthouse-logger'); -const {isEqual} = require('lodash'); +const isDeepEqual = require('lodash/isEqual.js'); const { getBrowserVersion, getBenchmarkIndex, @@ -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); } diff --git a/lighthouse-core/lib/arbitrary-equality-map.js b/lighthouse-core/lib/arbitrary-equality-map.js index 8b0c0514adc5..3386153ca2d5 100644 --- a/lighthouse-core/lib/arbitrary-equality-map.js +++ b/lighthouse-core/lib/arbitrary-equality-map.js @@ -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. @@ -74,7 +74,7 @@ class ArbitraryEqualityMap { * @return {boolean} */ static deepEquals(objA, objB) { - return isEqual(objA, objB); + return isDeepEqual(objA, objB); } } diff --git a/lighthouse-core/runner.js b/lighthouse-core/runner.js index b062cda53932..c073a0029507 100644 --- a/lighthouse-core/runner.js +++ b/lighthouse-core/runner.js @@ -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'); diff --git a/shared/localization/swap-locale.js b/shared/localization/swap-locale.js index e390075fcbd2..1a369d6c0f14 100644 --- a/shared/localization/swap-locale.js +++ b/shared/localization/swap-locale.js @@ -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');