diff --git a/packages/docusaurus-utils/package.json b/packages/docusaurus-utils/package.json index efcdce2b34..ea8ed7d4c4 100644 --- a/packages/docusaurus-utils/package.json +++ b/packages/docusaurus-utils/package.json @@ -26,7 +26,6 @@ "file-loader": "^6.2.0", "fs-extra": "^11.1.1", "github-slugger": "^1.5.0", - "globby": "^11.1.0", "gray-matter": "^4.0.3", "jiti": "^1.20.0", "js-yaml": "^4.1.0", @@ -35,6 +34,7 @@ "p-queue": "^6.6.2", "prompts": "^2.4.2", "resolve-pathname": "^3.0.0", + "tinyglobby": "^0.2.14", "tslib": "^2.6.0", "url-loader": "^4.1.1", "utility-types": "^3.10.0", diff --git a/packages/docusaurus-utils/src/globUtils.ts b/packages/docusaurus-utils/src/globUtils.ts index ba6b558975..305b3ff383 100644 --- a/packages/docusaurus-utils/src/globUtils.ts +++ b/packages/docusaurus-utils/src/globUtils.ts @@ -10,11 +10,15 @@ import path from 'path'; import Micromatch from 'micromatch'; // Note: Micromatch is used by Globby import {addSuffix} from '@docusaurus/utils-common'; -import Globby from 'globby'; +import * as Tinyglobby from 'tinyglobby'; import {posixPath} from './pathUtils'; +type GlobOptions = Tinyglobby.GlobOptions; + +// TODO Docusaurus v4 refactor, hide lib behind home-made abstraction +// See https://github.com/facebook/docusaurus/pull/11042 /** A re-export of the globby instance. */ -export {Globby}; +export const Globby = Tinyglobby.glob; /** * The default glob patterns we ignore when sourcing content. @@ -93,7 +97,7 @@ export function createAbsoluteFilePathMatcher( // See https://github.com/facebook/docusaurus/pull/4222#issuecomment-795517329 export async function safeGlobby( patterns: string[], - options?: Globby.GlobbyOptions, + options?: GlobOptions, ): Promise { // Required for Windows support, as paths using \ should not be used by globby // (also using the windows hard drive prefix like c: is not a good idea) diff --git a/packages/docusaurus/src/commands/writeHeadingIds.ts b/packages/docusaurus/src/commands/writeHeadingIds.ts index 3963270dc5..7cbda95206 100644 --- a/packages/docusaurus/src/commands/writeHeadingIds.ts +++ b/packages/docusaurus/src/commands/writeHeadingIds.ts @@ -47,12 +47,11 @@ export async function writeHeadingIds( ): Promise { const siteDir = await fs.realpath(siteDirParam); - const markdownFiles = await safeGlobby( - files ?? (await getPathsToWatch(siteDir)), - { - expandDirectories: ['**/*.{md,mdx}'], - }, - ); + const markdownFiles = ( + await safeGlobby(files ?? (await getPathsToWatch(siteDir)), { + expandDirectories: true, + }) + ).filter((file) => file.endsWith('.md') || file.endsWith('.mdx')); const result = await Promise.all( markdownFiles.map((p) => transformMarkdownFile(p, options)), diff --git a/yarn.lock b/yarn.lock index b1d51b9392..411d44c022 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8869,10 +8869,10 @@ fb-watchman@^2.0.0: dependencies: bser "2.1.1" -fdir@^6.4.3: - version "6.4.3" - resolved "https://registry.yarnpkg.com/fdir/-/fdir-6.4.3.tgz#011cdacf837eca9b811c89dbb902df714273db72" - integrity sha512-PMXmW2y1hDDfTSRc9gaXIuCCRpuoz3Kaz8cUelp3smouvfT632ozg2vrT6lJsHKKOF59YLbOGfAWGUcKEfRMQw== +fdir@^6.4.4: + version "6.4.4" + resolved "https://registry.yarnpkg.com/fdir/-/fdir-6.4.4.tgz#1cfcf86f875a883e19a8fab53622cfe992e8d2f9" + integrity sha512-1NZP+GK4GfuAv3PqKvxQRDMjdSRZjnkq7KfhlNrCNNlZ0ygQFpebfrnfnq/W7fpUnAv9aGWmY1zKx7FYL3gwhg== feed@^4.2.2: version "4.2.2" @@ -17534,12 +17534,12 @@ tinyexec@^0.3.2: resolved "https://registry.yarnpkg.com/tinyexec/-/tinyexec-0.3.2.tgz#941794e657a85e496577995c6eef66f53f42b3d2" integrity sha512-KQQR9yN7R5+OSwaK0XQoj22pwHoTlgYqmUscPYoknOoWCWfj/5/ABTMRi69FrKU5ffPVh5QcFikpWJI/P1ocHA== -tinyglobby@^0.2.12: - version "0.2.12" - resolved "https://registry.yarnpkg.com/tinyglobby/-/tinyglobby-0.2.12.tgz#ac941a42e0c5773bd0b5d08f32de82e74a1a61b5" - integrity sha512-qkf4trmKSIiMTs/E63cxH+ojC2unam7rJ0WrauAzpT3ECNTxGRMlaXxVbfxMUC/w0LaYk6jQ4y/nGR9uBO3tww== +tinyglobby@^0.2.12, tinyglobby@^0.2.14: + version "0.2.14" + resolved "https://registry.yarnpkg.com/tinyglobby/-/tinyglobby-0.2.14.tgz#5280b0cf3f972b050e74ae88406c0a6a58f4079d" + integrity sha512-tX5e7OM1HnYr2+a2C/4V0htOcSQcoSTH9KgJnVvNm5zm/cyEWKJ7j7YutsH9CxMdtOkkLFy2AHrMci9IM8IPZQ== dependencies: - fdir "^6.4.3" + fdir "^6.4.4" picomatch "^4.0.2" tinypool@^1.0.2: