From f8889f5374f8363f9d4cccfa9c4a2872c9143efb Mon Sep 17 00:00:00 2001 From: Joshua Chen Date: Sat, 19 Feb 2022 13:26:49 +0800 Subject: [PATCH] fixes --- packages/docusaurus-utils-build/bin/index.js | 3 ++- packages/docusaurus-utils-build/src/build.ts | 7 ++++++- packages/docusaurus-utils-build/src/index.ts | 11 ----------- packages/docusaurus-utils-build/src/tsc.ts | 8 +++++--- packages/docusaurus-utils-build/src/watch.ts | 11 ++++++++--- 5 files changed, 21 insertions(+), 19 deletions(-) delete mode 100644 packages/docusaurus-utils-build/src/index.ts diff --git a/packages/docusaurus-utils-build/bin/index.js b/packages/docusaurus-utils-build/bin/index.js index 12aca2f9a0b9..4d0aadd52503 100755 --- a/packages/docusaurus-utils-build/bin/index.js +++ b/packages/docusaurus-utils-build/bin/index.js @@ -8,7 +8,8 @@ import logger from '@docusaurus/logger'; import cli from 'commander'; -import {build, watch} from '../lib/index.js'; +import build from '../lib/build.js'; +import watch from '../lib/watch.js'; cli .command('build') diff --git a/packages/docusaurus-utils-build/src/build.ts b/packages/docusaurus-utils-build/src/build.ts index 29379b5fa037..c11e535505a7 100644 --- a/packages/docusaurus-utils-build/src/build.ts +++ b/packages/docusaurus-utils-build/src/build.ts @@ -10,7 +10,12 @@ import {Globby} from '@docusaurus/utils'; import logger from '@docusaurus/logger'; import Prettier from 'prettier'; import shelljs from 'shelljs'; -import {compileOrCopy, compileServerCode, compileClientCode} from './compiler'; +import { + compileOrCopy, + compileServerCode, + compileClientCode, + // eslint-disable-next-line import/no-unresolved +} from './compiler.js'; // import {tsc} from './tsc'; function transformDir( diff --git a/packages/docusaurus-utils-build/src/index.ts b/packages/docusaurus-utils-build/src/index.ts deleted file mode 100644 index d2eb8a2401a2..000000000000 --- a/packages/docusaurus-utils-build/src/index.ts +++ /dev/null @@ -1,11 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -import build from './build'; -import watch from './watch'; - -export {build, watch}; diff --git a/packages/docusaurus-utils-build/src/tsc.ts b/packages/docusaurus-utils-build/src/tsc.ts index aefcd11d6e67..5e4a9ca72e41 100644 --- a/packages/docusaurus-utils-build/src/tsc.ts +++ b/packages/docusaurus-utils-build/src/tsc.ts @@ -8,7 +8,8 @@ import fs from 'fs'; import ts from 'typescript'; import {Globby} from '@docusaurus/utils'; -import {getTargetPath} from './compiler'; +// eslint-disable-next-line import/no-unresolved +import {getTargetPath} from './compiler.js'; const formatHost: ts.FormatDiagnosticsHost = { getCanonicalFileName: (p) => p, @@ -30,7 +31,7 @@ function reportDiagnostic(diagnostic: ts.Diagnostic) { /** * Prints a diagnostic every time the watch status changes. - * This is mainly for messages like "Starting compilation" or "Compilation completed". + * This is mainly for messages like "Starting" or "Completed". */ function reportWatchStatusChanged(diagnostic: ts.Diagnostic) { console.info(ts.formatDiagnostic(diagnostic, formatHost)); @@ -63,7 +64,8 @@ export function watch(): void { } /** - * There's no API for unrolling the `extends` field in tsconfig, so we do it ourselves. + * There's no API for unrolling the `extends` field in tsconfig, so we do it + * ourselves. */ function resolveCompilerOptions(configEntryPath: string): ts.CompilerOptions { let configPath: string | undefined = configEntryPath; diff --git a/packages/docusaurus-utils-build/src/watch.ts b/packages/docusaurus-utils-build/src/watch.ts index 6702a07c355e..49d2d5da29cb 100644 --- a/packages/docusaurus-utils-build/src/watch.ts +++ b/packages/docusaurus-utils-build/src/watch.ts @@ -7,9 +7,14 @@ import fs from 'fs'; import chokidar from 'chokidar'; -import {debounce} from 'lodash'; +import _ from 'lodash'; import logger from '@docusaurus/logger'; -import {compileOrCopy, compileClientCode, compileServerCode} from './compiler'; +import { + compileOrCopy, + compileServerCode, + compileClientCode, + // eslint-disable-next-line import/no-unresolved +} from './compiler.js'; export default async function watch( options: Partial<{ @@ -35,7 +40,7 @@ export default async function watch( pollInterval: 10, }, }); - const compile = debounce((filePath: string) => { + const compile = _.debounce((filePath: string) => { try { // TODO: is check this good enough? if (filePath.includes(themeDir)) {