diff --git a/core/docz-core/src/config/babel.ts b/core/docz-core/src/config/babel.ts index 2bbbc6c3f..b0675e191 100644 --- a/core/docz-core/src/config/babel.ts +++ b/core/docz-core/src/config/babel.ts @@ -1,5 +1,5 @@ import { load } from 'load-cfg' -import { merge } from 'lodash' +import { merge } from 'lodash/fp' import getCacheIdentifier from 'react-dev-utils/getCacheIdentifier' import { Config, Env } from '../config/argv' diff --git a/core/docz-core/src/config/docz.ts b/core/docz-core/src/config/docz.ts index 970d47a40..aa437e32c 100644 --- a/core/docz-core/src/config/docz.ts +++ b/core/docz-core/src/config/docz.ts @@ -2,8 +2,8 @@ import * as path from 'path' import { Arguments } from 'yargs' import { omit } from 'lodash/fp' import { load, loadFrom } from 'load-cfg' +import { merge } from 'lodash/fp' import detectPort from 'detect-port' -import merge from 'lodash/merge' import * as paths from '../config/paths' import { BabelRC } from '../config/babel' diff --git a/core/docz-core/src/states/config.ts b/core/docz-core/src/states/config.ts index fd6ded6e7..403b1f802 100644 --- a/core/docz-core/src/states/config.ts +++ b/core/docz-core/src/states/config.ts @@ -37,13 +37,13 @@ const getInitialConfig = (config: Config): Payload => { } } -const updateConfig = (config: Config) => async (p: Params) => { - const initial = getInitialConfig(config) +const update = async (params: Params, initial: Payload) => { const next = load('docz', initial, true, true) - p.setState('config', next) + params.setState('config', next) } export const state = (config: Config): State => { + const initial = getInitialConfig(config) const watcher = chokidar.watch(finds('docz'), { cwd: paths.root, ignored: /(((^|[\/\\])\..+)|(node_modules))/, @@ -55,10 +55,8 @@ export const state = (config: Config): State => { return { id: 'config', start: async params => { - const update = updateConfig(config) - const fn = async () => update(params) + const fn = async () => update(params, initial) - await update(params) watcher.on('add', fn) watcher.on('change', fn) watcher.on('unlink', fn) diff --git a/other-packages/load-cfg/src/index.ts b/other-packages/load-cfg/src/index.ts index 658c7dcc0..31c698dce 100644 --- a/other-packages/load-cfg/src/index.ts +++ b/other-packages/load-cfg/src/index.ts @@ -1,7 +1,7 @@ import * as fs from 'fs-extra' import * as path from 'path' import * as findup from 'find-up' -import { merge } from 'lodash' +import { merge } from 'lodash/fp' export const loadFile = (filepath: string, noCache?: boolean) => { require('@babel/register')({ @@ -54,7 +54,6 @@ export function load( ? merge(defaultConfig, file) : { ...defaultConfig, ...file } : file - // tslint:disable return next }