Skip to content

Commit

Permalink
chore: reduce lodash usage (#35947)
Browse files Browse the repository at this point in the history
  • Loading branch information
wardpeet committed Jun 20, 2022
1 parent 384e801 commit 91fdf73
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 10 deletions.
Expand Up @@ -95,6 +95,7 @@ Array [
},
},
],
"babel-plugin-lodash",
]
`;

Expand All @@ -116,6 +117,7 @@ Array [
},
},
],
"babel-plugin-lodash",
]
`;

Expand Down Expand Up @@ -185,5 +187,6 @@ Array [
},
},
],
"babel-plugin-lodash",
]
`;
1 change: 1 addition & 0 deletions packages/babel-preset-gatsby-package/lib/index.js
Expand Up @@ -85,6 +85,7 @@ function preset(context, options = {}) {
availableFlags: availableCompilerFlags,
},
],
r(`babel-plugin-lodash`),
].filter(Boolean),
overrides: [
{
Expand Down
3 changes: 2 additions & 1 deletion packages/babel-preset-gatsby-package/package.json
Expand Up @@ -19,6 +19,7 @@
"@babel/preset-react": "^7.14.0",
"@babel/runtime": "^7.15.4",
"babel-plugin-dynamic-import-node": "^2.3.3",
"babel-plugin-lodash": "^3.3.4",
"core-js": "^3.22.3"
},
"devDependencies": {
Expand All @@ -45,4 +46,4 @@
"prepare": "cross-env NODE_ENV=production npm run build",
"watch": "babel -w src --out-dir dist/ --ignore \"**/__tests__\" --extensions \".ts,.js\""
}
}
}
1 change: 1 addition & 0 deletions packages/gatsby-cli/package.json
Expand Up @@ -65,6 +65,7 @@
"@types/hosted-git-info": "^3.0.2",
"@types/yargs": "^15.0.14",
"babel-preset-gatsby-package": "^2.18.0-next.0",
"babel-plugin-lodash": "^3.3.4",
"cross-env": "^7.0.3",
"ink": "^3.2.0",
"ink-spinner": "^4.0.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby-cli/rollup.config.js
Expand Up @@ -59,7 +59,7 @@ export default {
],
"@babel/preset-react"
],
plugins: ["@babel/plugin-transform-runtime"],
plugins: ["@babel/plugin-transform-runtime", "babel-plugin-lodash"],
overrides: [
{
"test": ["**/*.ts", "**/*.tsx"],
Expand Down
9 changes: 4 additions & 5 deletions packages/gatsby/src/bootstrap/requires-writer.ts
Expand Up @@ -67,11 +67,10 @@ const pickComponentFields = (page: IGatsbyPage): IGatsbyPageComponent =>
export const getComponents = (
pages: Array<IGatsbyPage>
): Array<IGatsbyPageComponent> =>
_(pages)
.map(pickComponentFields)
.uniqBy(c => c.componentChunkName)
.orderBy(c => c.componentChunkName)
.value()
_.orderBy(
_.uniqBy(_.map(pages, pickComponentFields), c => c.componentChunkName),
c => c.componentChunkName
)

/**
* Get all dynamic routes and sort them by most specific at the top
Expand Down
4 changes: 2 additions & 2 deletions packages/gatsby/src/utils/changed-pages.ts
@@ -1,9 +1,9 @@
import { actions } from "../redux/actions"
import { store } from "../redux"
const { deletePage } = actions

import { isEqualWith, IsEqualCustomizer } from "lodash"
import { isEqualWith } from "lodash"
import { IGatsbyPage } from "../redux/types"
import type { IsEqualCustomizer } from "lodash"

export function deleteUntouchedPages(
currentPages: Map<string, IGatsbyPage>,
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby/src/utils/sanitize-node.js
@@ -1,4 +1,4 @@
const _ = require(`lodash`)
import _ from "lodash"

/**
* Make data serializable
Expand Down

0 comments on commit 91fdf73

Please sign in to comment.