Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deps(lodash): use individual lodash modules to reduce bundle size #13914

Merged
merged 3 commits into from
Apr 27, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -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
*/
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 @@ -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';
Expand All @@ -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');

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 @@ -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
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 @@ -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);
}

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
1 change: 1 addition & 0 deletions tsconfig-base.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"module": "es2020",
"moduleResolution": "node",
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
connorjclark marked this conversation as resolved.
Show resolved Hide resolved

"allowJs": true,
"checkJs": true,
Expand Down