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

chore: reduce lodash usage #35947

Merged
merged 2 commits into from Jun 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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