Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion packages/gatsby/cache-dir/dev-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import getSocket from "./socketIo"
import normalizePagePath from "./normalize-page-path"

// TODO move away from lodash
import isEqual from "lodash/isEqual"
import { isEqual } from "es-toolkit/compat"

function mergePageEntry(cachedPage, newPageData) {
return {
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby/cache-dir/develop-static-entry.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* global BROWSER_ESM_ONLY */
import React from "react"
import { renderToStaticMarkup } from "react-dom/server"
import { merge } from "lodash"
import { merge } from "es-toolkit/compat"
import { apiRunner } from "./api-runner-ssr"
import asyncRequires from "$virtual/async-requires"

Expand Down
9 changes: 8 additions & 1 deletion packages/gatsby/cache-dir/ssr-develop-static-entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@
import React from "react"
import fs from "fs-extra"
import { renderToStaticMarkup, renderToPipeableStream } from "react-dom/server"
import { get, merge, isObject, flatten, uniqBy, concat } from "lodash"
import {
get,
merge,
isObject,
flatten,
uniqBy,
concat,
} from "es-toolkit/compat"
import nodePath from "path"
import { apiRunner, apiRunnerAsync } from "./api-runner-ssr"
import { grabMatchParams } from "./find-path"
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
"latest-version": "^7.0.0",
"linkfs": "^2.1.0",
"lmdb": "2.5.3",
"lodash": "^4.17.21",
"es-toolkit": "^1.30.0",
"meant": "^1.0.3",
"memoizee": "^0.4.15",
"micromatch": "^4.0.5",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { slash } from "gatsby-core-utils"
import { uniqWith, isEqual } from "lodash"
import { uniqWith, isEqual } from "es-toolkit/compat"
import path from "path"
import { store } from "../../redux"
import {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { IPluginInfo, PluginRef } from "./types"
import { createPluginId } from "./utils/create-id"
import { resolvePlugin } from "./resolve-plugin"
import { isString, isEmpty, set, merge } from "lodash"
import { isString, isEmpty, set, merge } from "es-toolkit/compat"

export function processPlugin(plugin: PluginRef, rootDir: string): IPluginInfo {
// Respect the directory that the plugin was sourced from initially
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { IPluginInfo, PluginRef } from "./types"
import { createPluginId } from "./utils/create-id"
import { createFileContentHash } from "./utils/create-hash"
import reporter from "gatsby-cli/lib/reporter"
import { isString } from "lodash"
import { isString } from "es-toolkit/compat"
import { checkLocalPlugin } from "./utils/check-local-plugin"
import { getResolvedFieldsForPlugin } from "../../utils/parcel/compile-gatsby-files"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ExportType, ICurrentAPIs } from "../validate"
import { keys } from "lodash"
import { keys } from "es-toolkit/compat"

export const getAPI = (api: {
[exportType in ExportType]: { [api: string]: boolean }
Expand Down
14 changes: 7 additions & 7 deletions packages/gatsby/src/bootstrap/load-plugins/validate.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import _ from "lodash"
import { difference, intersection, toPairs, get } from "es-toolkit/compat"
import path from "path"
import * as semver from "semver"
import * as stringSimilarity from "string-similarity"
Expand Down Expand Up @@ -63,7 +63,7 @@ function getBadExports(
let badExports: Array<IEntry> = []
// Discover any exports from plugins which are not "known"
badExports = badExports.concat(
_.difference(pluginAPIKeys, apis).map(e => {
difference(pluginAPIKeys, apis).map(e => {
return {
exportName: e,
pluginName: plugin.name,
Expand Down Expand Up @@ -162,7 +162,7 @@ export async function handleBadExports({
if (hasBadExports) {
const latestAPIs = await getLatestAPIs()
// Output error messages for all bad exports
_.toPairs(badExports).forEach(badItem => {
toPairs(badExports).forEach(badItem => {
const [exportType, entries] = badItem
if (entries.length > 0) {
const context = getErrorContext(
Expand Down Expand Up @@ -473,14 +473,14 @@ export async function collatePluginAPIs({
)

if (pluginNodeExports.length > 0) {
plugin.nodeAPIs = _.intersection(pluginNodeExports, currentAPIs.node)
plugin.nodeAPIs = intersection(pluginNodeExports, currentAPIs.node)
badExports.node = badExports.node.concat(
getBadExports(plugin, pluginNodeExports, currentAPIs.node)
) // Collate any bad exports
}

if (pluginBrowserExports.length > 0) {
plugin.browserAPIs = _.intersection(
plugin.browserAPIs = intersection(
pluginBrowserExports,
currentAPIs.browser
)
Expand All @@ -490,7 +490,7 @@ export async function collatePluginAPIs({
}

if (pluginSSRExports.length > 0) {
plugin.ssrAPIs = _.intersection(pluginSSRExports, currentAPIs.ssr)
plugin.ssrAPIs = intersection(pluginSSRExports, currentAPIs.ssr)
badExports.ssr = badExports.ssr.concat(
getBadExports(plugin, pluginSSRExports, currentAPIs.ssr)
) // Collate any bad exports
Expand Down Expand Up @@ -561,7 +561,7 @@ export function warnOnIncompatiblePeerDependency(
packageJSON: PackageJson
): void {
// Note: In the future the peer dependency should be enforced for all plugins.
const gatsbyPeerDependency = _.get(packageJSON, `peerDependencies.gatsby`)
const gatsbyPeerDependency = get(packageJSON, `peerDependencies.gatsby`)
if (
!isWorker &&
gatsbyPeerDependency &&
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby/src/bootstrap/load-themes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
IPluginEntryWithParentDir,
} from "../../utils/merge-gatsby-config"
import { mapSeries } from "bluebird"
import { flattenDeep, isEqual, isFunction, uniqWith } from "lodash"
import { flattenDeep, isEqual, isFunction, uniqWith } from "es-toolkit/compat"
import DebugCtor from "debug"
import { preferDefault } from "../prefer-default"
import { getConfigFile } from "../get-config-file"
Expand Down
4 changes: 2 additions & 2 deletions packages/gatsby/src/bootstrap/redirects-writer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import _ from "lodash"
import { debounce } from "es-toolkit/compat"
import fs from "fs-extra"
import { joinPath, md5 } from "gatsby-core-utils"
import reporter from "gatsby-cli/lib/reporter"
Expand Down Expand Up @@ -66,7 +66,7 @@ export const writeRedirects = async (): Promise<void> => {
)
}

const debouncedWriteRedirects = _.debounce(() => {
const debouncedWriteRedirects = debounce(() => {
// Don't write redirects again until bootstrap has finished.
if (bootstrapFinished) {
writeRedirects()
Expand Down
10 changes: 5 additions & 5 deletions packages/gatsby/src/bootstrap/requires-writer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import _ from "lodash"
import { orderBy, uniqBy, map, debounce } from "es-toolkit/compat"
import path from "path"
import fs from "fs-extra"
import reporter from "gatsby-cli/lib/reporter"
Expand Down Expand Up @@ -56,9 +56,9 @@ export const getComponents = (
}
}

return _.orderBy(
_.uniqBy(
_.map([...pages, ...slices.values()], pickComponentFields),
return orderBy(
uniqBy(
map([...pages, ...slices.values()], pickComponentFields),
c => c.componentChunkName
),
c => c.componentChunkName
Expand Down Expand Up @@ -319,7 +319,7 @@ exports.head = {\n${components
return true
}

const debouncedWriteAll = _.debounce(
const debouncedWriteAll = debounce(
async (): Promise<void> => {
const activity = reporter.activityTimer(`write out requires`, {
id: `requires-writer`,
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby/src/bootstrap/schema-hot-reloader.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { debounce, cloneDeep } from "lodash"
import { debounce, cloneDeep } from "es-toolkit/compat"
import { emitter, store } from "../redux"
import { rebuild } from "../schema"
import { haveEqualFields } from "../schema/infer/inference-metadata"
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby/src/commands/build-html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Bluebird from "bluebird"
import fs from "fs-extra"
import reporter from "gatsby-cli/lib/reporter"
import { createErrorFromString } from "gatsby-cli/lib/reporter/errors"
import { chunk } from "lodash"
import { chunk } from "es-toolkit/compat"
import { build, watch } from "../utils/webpack/bundle"
import * as path from "path"
import fastq from "fastq"
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby/src/datastore/common/query.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as _ from "lodash"
import * as _ from "es-toolkit/compat"
import { prepareRegex } from "../../utils/prepare-regex"
import { makeRe } from "micromatch"

Expand Down
4 changes: 2 additions & 2 deletions packages/gatsby/src/datastore/in-memory/indexing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
objectToDottedField,
} from "../common/query"
import { getDataStore, getNode } from "../"
import _ from "lodash"
import { every } from "es-toolkit/compat"
import { getValueAt } from "../../utils/get-value-at"
import { getResolvedFields } from "../../schema/utils"

Expand Down Expand Up @@ -63,7 +63,7 @@ export const getGatsbyNodePartial = (
// now check if we have it in memory and it has all the fields we need
if (
derefPartial &&
_.every(
every(
indexFields.map(field =>
derefPartial!.gatsbyNodePartialInternalData.indexFields.has(field)
)
Expand Down
4 changes: 2 additions & 2 deletions packages/gatsby/src/datastore/in-memory/run-fast-filters.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import _ from "lodash"
import { orderBy } from "es-toolkit/compat"
import {
DbQuery,
IDbQueryQuery,
Expand Down Expand Up @@ -457,5 +457,5 @@ function sortNodes(
})
}

return _.orderBy(nodes, sortFns, sortOrder)
return orderBy(nodes, sortFns, sortOrder)
}
8 changes: 4 additions & 4 deletions packages/gatsby/src/internal-plugins/functions/gatsby-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import fs from "fs-extra"
import glob from "glob"
import path from "path"
import webpack from "webpack"
import _ from "lodash"
import { union, kebabCase, unionBy } from "es-toolkit/compat"
import { getMatchPath, urlResolve } from "gatsby-core-utils"
import { CreateDevServerArgs, ParentSpanPluginArgs } from "gatsby"
import formatWebpackMessages from "react-dev-utils/formatWebpackMessages"
Expand Down Expand Up @@ -121,7 +121,7 @@ const createGlobArray = (siteDirectoryPath, plugins): Array<IGlobPattern> => {
})

// Only return unique paths
return _.union(globs)
return union(globs)
}

async function globAsync(
Expand Down Expand Up @@ -178,7 +178,7 @@ const createWebpackConfig = async ({
const finalName = urlResolve(dir, name === `index` ? `` : name)

// functionId should have only alphanumeric characters and dashes
const functionIdBase = _.kebabCase(compiledFunctionName).replace(
const functionIdBase = kebabCase(compiledFunctionName).replace(
/[^a-zA-Z0-9-]/g,
`-`
)
Expand Down Expand Up @@ -212,7 +212,7 @@ const createWebpackConfig = async ({
// Combine functions by the route name so that functions in the default
// functions directory can override the plugin's implementations.
// @ts-ignore - Seems like a TS bug: https://github.com/microsoft/TypeScript/issues/28010#issuecomment-713484584
const knownFunctions = _.unionBy(...allFunctions, func => func.functionRoute)
const knownFunctions = unionBy(...allFunctions, func => func.functionRoute)

store.dispatch(internalActions.setFunctions(knownFunctions))

Expand Down
6 changes: 2 additions & 4 deletions packages/gatsby/src/query/graphql-errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const fs = require(`fs-extra`)
import { print, visit, getLocation } from "graphql"
import { codeFrameColumns } from "@babel/code-frame"
const { distance: levenshtein } = require(`fastest-levenshtein`)
import _ from "lodash"
import { camelCase, upperFirst } from "es-toolkit/compat"
import report from "gatsby-cli/lib/reporter"
const { locInGraphQlToLocInFile } = require(`./error-parser`)
import { getCodeFrame } from "./graphql-errors-codeframe"
Expand Down Expand Up @@ -118,9 +118,7 @@ export function multipleRootQueriesError(
const otherName = otherDef.name.value
const field = def.selectionSet.selections[0].name.value
const otherField = otherDef.selectionSet.selections[0].name.value
const unifiedName = `${_.camelCase(name)}And${_.upperFirst(
_.camelCase(otherName)
)}`
const unifiedName = `${camelCase(name)}And${upperFirst(camelCase(otherName))}`

// colors are problematic for tests as we can different
// results depending on platform, so we don't
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby/src/query/graphql-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
NoDeprecatedCustomRule,
print,
} from "graphql"
import { debounce } from "lodash"
import { debounce } from "es-toolkit/compat"
import reporter from "gatsby-cli/lib/reporter"
import { sha1 } from "gatsby-core-utils/hash"

Expand Down
4 changes: 2 additions & 2 deletions packages/gatsby/src/query/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import _ from "lodash"
import { groupBy } from "es-toolkit/compat"
import fastq from "fastq"
import { IProgressReporter } from "gatsby-cli/lib/reporter/reporter-progress"
import { store } from "../redux"
Expand Down Expand Up @@ -58,7 +58,7 @@ export { calcDirtyQueryIds as calcInitialDirtyQueryIds }
* Groups queryIds by whether they are static or page queries.
*/
export function groupQueryIds(queryIds: Array<string>): IGroupedQueryIds {
const grouped = _.groupBy(queryIds, p => {
const grouped = groupBy(queryIds, p => {
if (p.startsWith(`sq--`)) {
return `static`
} else if (p.startsWith(`slice--`)) {
Expand Down
1 change: 0 additions & 1 deletion packages/gatsby/src/query/query-runner.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Span } from "opentracing"
import _ from "lodash"
import fs from "fs-extra"
import report from "gatsby-cli/lib/reporter"
import { ExecutionResult, GraphQLError } from "graphql"
Expand Down
3 changes: 1 addition & 2 deletions packages/gatsby/src/redux/actions/restricted.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import camelCase from "lodash/camelCase"
import isEqual from "lodash/isEqual"
import { camelCase, isEqual } from "es-toolkit/compat"

import { GraphQLSchema, GraphQLOutputType } from "graphql"
import { ActionCreator } from "redux"
Expand Down
6 changes: 3 additions & 3 deletions packages/gatsby/src/redux/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
ReducersMapObject,
Store,
} from "redux"
import _ from "lodash"
import { pick } from "es-toolkit/compat"

import { mett } from "../utils/mett"
import thunk, { ThunkMiddleware, ThunkAction, ThunkDispatch } from "redux-thunk"
Expand Down Expand Up @@ -140,7 +140,7 @@ export const saveState = (): void => {

const state = store.getState()

const sliceOfStateToPersist = _.pick(state, persistedReduxKeys)
const sliceOfStateToPersist = pick(state, persistedReduxKeys)

return writeToCache(sliceOfStateToPersist)
}
Expand All @@ -151,7 +151,7 @@ export const savePartialStateToDisk = (
transformState?: <T extends DeepPartial<IGatsbyState>>(state: T) => T
): void => {
const state = store.getState()
const contents = _.pick(state, slices)
const contents = pick(state, slices)
const savedContents = transformState ? transformState(contents) : contents

return writeToCache(savedContents, slices, optionalPrefix)
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby/src/redux/reducers/__tests__/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
IQueryStartAction,
} from "../../types"

import { cloneDeep } from "lodash"
import { cloneDeep } from "es-toolkit/compat"

type QueriesState = IGatsbyState["queries"]

Expand Down
Loading