refactor(v2): replace Lodash with single methods packages in core (#2535)

This commit is contained in:
Bartosz Kaszubowski 2020-04-05 11:50:30 +02:00 committed by GitHub
parent 5e664a1f26
commit 3dfc41bd36
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 13 deletions

View file

@ -60,7 +60,9 @@
"html-tags": "^3.1.0",
"html-webpack-plugin": "^4.0.4",
"import-fresh": "^3.2.1",
"lodash": "^4.17.15",
"lodash.has": "^4.5.2",
"lodash.isplainobject": "^4.0.6",
"lodash.isstring": "^4.0.1",
"mini-css-extract-plugin": "^0.8.0",
"nprogress": "^0.2.0",
"null-loader": "^3.0.0",

View file

@ -7,7 +7,7 @@
import fs from 'fs-extra';
import importFresh from 'import-fresh';
import _ from 'lodash';
import has from 'lodash.has';
import path from 'path';
import {CONFIG_FILE_NAME} from '../constants';
import {DocusaurusConfig, PluginConfig} from '@docusaurus/types';
@ -57,7 +57,7 @@ export function loadConfig(siteDir: string): DocusaurusConfig {
const loadedConfig = importFresh(configPath) as Partial<DocusaurusConfig>;
const missingFields = REQUIRED_FIELDS.filter(
field => !_.has(loadedConfig, field),
field => !has(loadedConfig, field),
);
if (missingFields.length > 0) {

View file

@ -5,13 +5,13 @@
* LICENSE file in the root directory of this source tree.
*/
import _ from 'lodash';
import isPlainObject from 'lodash.isplainobject';
import {HtmlTagObject} from '@docusaurus/types';
import htmlTags from 'html-tags';
import voidHtmlTags from 'html-tags/void';
function assertIsHtmlTagObject(val: any): asserts val is HtmlTagObject {
if (!_.isPlainObject(val)) {
if (!isPlainObject(val)) {
throw new Error(`"${val}" is not a valid HTML tag object`);
}
if (typeof val.tagName !== 'string') {

View file

@ -6,7 +6,9 @@
*/
import {genChunkName, normalizeUrl} from '@docusaurus/utils';
import _ from 'lodash';
import has from 'lodash.has';
import isPlainObject from 'lodash.isplainobject';
import isString from 'lodash.isstring';
import {stringify} from 'querystring';
import {
ChunkRegistry,
@ -17,14 +19,10 @@ import {
} from '@docusaurus/types';
function isModule(value: any): value is Module {
if (_.isString(value)) {
if (isString(value)) {
return true;
}
if (
_.isPlainObject(value) &&
_.has(value, '__import') &&
_.has(value, 'path')
) {
if (isPlainObject(value) && has(value, '__import') && has(value, 'path')) {
return true;
}
return false;
@ -64,7 +62,7 @@ export async function loadRoutes(
exact,
} = routeConfig;
if (!_.isString(routePath) || !component) {
if (!isString(routePath) || !component) {
throw new Error(
`Invalid routeConfig (Path must be a string and component is required) \n${JSON.stringify(
routeConfig,