From 4b79bb5e1622ee42481e4158d75273db30a8f355 Mon Sep 17 00:00:00 2001 From: Connor Clark Date: Tue, 26 Apr 2022 10:56:05 -0700 Subject: [PATCH 1/2] deps(lodash): use individual lodash modules for reduced bundle size --- 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 ++- tsconfig-base.json | 1 + 9 files changed, 12 insertions(+), 16 deletions(-) diff --git a/lighthouse-cli/test/smokehouse/frontends/lib.js b/lighthouse-cli/test/smokehouse/frontends/lib.js index fd2c085d5a9f..c5c7ec2bb3a8 100644 --- a/lighthouse-cli/test/smokehouse/frontends/lib.js +++ b/lighthouse-cli/test/smokehouse/frontends/lib.js @@ -12,13 +12,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 7e37b83910c1..21459eb2e49f 100644 --- a/lighthouse-cli/test/smokehouse/frontends/smokehouse-bin.js +++ b/lighthouse-cli/test/smokehouse/frontends/smokehouse-bin.js @@ -16,7 +16,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'; @@ -25,8 +25,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 4742e4c59bcd..7306145ec358 100644 --- a/lighthouse-cli/test/smokehouse/report-assert.js +++ b/lighthouse-cli/test/smokehouse/report-assert.js @@ -9,14 +9,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 0676ca28dd41..f616b6a64841 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, @@ -61,7 +61,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 656e5222dd9f..402f19f63c3f 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'); diff --git a/tsconfig-base.json b/tsconfig-base.json index 345313f7c05a..c5c1117a6790 100644 --- a/tsconfig-base.json +++ b/tsconfig-base.json @@ -10,6 +10,7 @@ "module": "es2020", "moduleResolution": "node", "esModuleInterop": true, + "allowSyntheticDefaultImports": true, "allowJs": true, "checkJs": true, From a27dc8a1d003917ff594c52e84662e007633326a Mon Sep 17 00:00:00 2001 From: Connor Clark Date: Tue, 26 Apr 2022 12:39:33 -0700 Subject: [PATCH 2/2] oops --- tsconfig-base.json | 1 - 1 file changed, 1 deletion(-) diff --git a/tsconfig-base.json b/tsconfig-base.json index c5c1117a6790..345313f7c05a 100644 --- a/tsconfig-base.json +++ b/tsconfig-base.json @@ -10,7 +10,6 @@ "module": "es2020", "moduleResolution": "node", "esModuleInterop": true, - "allowSyntheticDefaultImports": true, "allowJs": true, "checkJs": true,