diff --git a/package.json b/package.json index 69a4d488912a..d9162ae34cff 100644 --- a/package.json +++ b/package.json @@ -149,7 +149,6 @@ "debug": "^4.3.6", "esbuild": "^0.23.1", "execa": "^9.3.1", - "fast-glob": "^3.3.2", "fs-extra": "^11.2.0", "get-port": "^7.1.0", "gray-matter": "^4.0.3", @@ -185,6 +184,7 @@ "sirv": "^2.0.4", "sitemap": "^8.0.0", "supports-color": "^9.4.0", + "tinyglobby": "^0.2.5", "typescript": "^5.5.4", "vitest": "^2.0.5", "vue-tsc": "^2.1.4", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 519a914c4d75..4ee5588e2f5f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -164,9 +164,6 @@ importers: execa: specifier: ^9.3.1 version: 9.3.1 - fast-glob: - specifier: ^3.3.2 - version: 3.3.2 fs-extra: specifier: ^11.2.0 version: 11.2.0 @@ -272,6 +269,9 @@ importers: supports-color: specifier: ^9.4.0 version: 9.4.0 + tinyglobby: + specifier: ^0.2.5 + version: 0.2.5 typescript: specifier: ^5.5.4 version: 5.5.4 @@ -1607,6 +1607,14 @@ packages: fastq@1.17.1: resolution: {integrity: sha512-sRVD3lWVIXWg6By68ZN7vho9a1pQcN/WBFaAAsDDFzlJjvoGx0P8z7V1t72grFJfJhu3YPZBuu25f7Kaw2jN1w==} + fdir@6.3.0: + resolution: {integrity: sha512-QOnuT+BOtivR77wYvCWHfGt9s4Pz1VIMbD463vegT5MLqNXy8rYFT/lPVEqf/bhYeT6qmqrNHhsX+rWwe3rOCQ==} + peerDependencies: + picomatch: ^3 || ^4 + peerDependenciesMeta: + picomatch: + optional: true + figures@6.1.0: resolution: {integrity: sha512-d+l3qxjSesT4V7v2fh+QnmFnUWv9lSpjarhShNTgBOfA0ttejbQUAlHLitbjkoRiDulW0OPoQPYIGhIC8ohejg==} engines: {node: '>=18'} @@ -2179,6 +2187,10 @@ packages: resolution: {integrity: sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==} engines: {node: '>=8.6'} + picomatch@4.0.2: + resolution: {integrity: sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==} + engines: {node: '>=12'} + pidtree@0.6.0: resolution: {integrity: sha512-eG2dWTVw5bzqGRztnHExczNxt5VGsE6OwTeCG3fdUf9KBsZzO3R5OIIIzWR+iZA0NtZ+RDVdaoE2dK1cn6jH4g==} engines: {node: '>=0.10'} @@ -2502,6 +2514,10 @@ packages: tinybench@2.9.0: resolution: {integrity: sha512-0+DUvqWMValLmha6lr4kD8iAMK1HzV0/aKnCtWb9v9641TnP/MFb7Pc2bxoxQjTXAErryXVgUOfv2YqNllqGeg==} + tinyglobby@0.2.5: + resolution: {integrity: sha512-Dlqgt6h0QkoHttG53/WGADNh9QhcjCAIZMTERAVhdpmIBEejSuLI9ZmGKWzB7tweBjlk30+s/ofi4SLmBeTYhw==} + engines: {node: '>=12.0.0'} + tinypool@1.0.1: resolution: {integrity: sha512-URZYihUbRPcGv95En+sz6MfghfIc2OJ1sv/RmhWZLouPY0/8Vo80viwPvg3dlaS9fuq7fQMEfgRRK7BBZThBEA==} engines: {node: ^18.0.0 || >=20.0.0} @@ -4037,6 +4053,10 @@ snapshots: dependencies: reusify: 1.0.4 + fdir@6.3.0(picomatch@4.0.2): + optionalDependencies: + picomatch: 4.0.2 + figures@6.1.0: dependencies: is-unicode-supported: 2.0.0 @@ -4581,6 +4601,8 @@ snapshots: picomatch@2.3.1: {} + picomatch@4.0.2: {} + pidtree@0.6.0: {} pkg-dir@8.0.0: @@ -4903,6 +4925,11 @@ snapshots: tinybench@2.9.0: {} + tinyglobby@0.2.5: + dependencies: + fdir: 6.3.0(picomatch@4.0.2) + picomatch: 4.0.2 + tinypool@1.0.1: {} tinyrainbow@1.2.0: {} diff --git a/scripts/copyClient.js b/scripts/copyClient.js index 44360e28e647..465be10caf4e 100644 --- a/scripts/copyClient.js +++ b/scripts/copyClient.js @@ -1,11 +1,11 @@ import { copy } from 'fs-extra' -import fg from 'fast-glob' +import { globSync } from 'tinyglobby' function toDest(file) { return file.replace(/^src\//, 'dist/') } -fg.sync('src/client/**').forEach((file) => { +globSync(['src/client/**']).forEach((file) => { if (/(\.ts|tsconfig\.json)$/.test(file)) return copy(file, toDest(file)) }) diff --git a/scripts/copyShared.js b/scripts/copyShared.js index 465f2853d810..af73c48e65c2 100644 --- a/scripts/copyShared.js +++ b/scripts/copyShared.js @@ -1,7 +1,7 @@ import { copy } from 'fs-extra' -import fg from 'fast-glob' +import { globSync } from 'tinyglobby' -fg.sync('src/shared/**/*.ts').forEach(async (file) => { +globSync(['src/shared/**/*.ts']).forEach(async (file) => { await Promise.all([ copy(file, file.replace(/^src\/shared\//, 'src/node/')), copy(file, file.replace(/^src\/shared\//, 'src/client/')) diff --git a/src/node/contentLoader.ts b/src/node/contentLoader.ts index dc8651ac84e0..3cce19d0b96f 100644 --- a/src/node/contentLoader.ts +++ b/src/node/contentLoader.ts @@ -1,6 +1,6 @@ import fs from 'fs-extra' import path from 'path' -import glob from 'fast-glob' +import { glob, type GlobOptions } from 'tinyglobby' import type { SiteConfig } from './config' import matter from 'gray-matter' import { normalizePath } from 'vite' @@ -54,11 +54,11 @@ export interface ContentOptions { transform?: (data: ContentData[]) => T | Promise /** - * Options to pass to `fast-glob`. + * Options to pass to `tinyglobby`. * You'll need to manually specify `node_modules` and `dist` in * `globOptions.ignore` if you've overridden it. */ - globOptions?: glob.Options + globOptions?: GlobOptions } export interface ContentData { @@ -118,6 +118,7 @@ export function createContentLoader( files = ( await glob(pattern, { ignore: ['**/node_modules/**', '**/dist/**'], + expandDirectories: false, ...globOptions }) ).sort() diff --git a/src/node/plugins/dynamicRoutesPlugin.ts b/src/node/plugins/dynamicRoutesPlugin.ts index 49dd19635b9f..6fffe4205612 100644 --- a/src/node/plugins/dynamicRoutesPlugin.ts +++ b/src/node/plugins/dynamicRoutesPlugin.ts @@ -8,7 +8,7 @@ import { import fs from 'fs-extra' import c from 'picocolors' import path from 'path' -import glob from 'fast-glob' +import { glob } from 'tinyglobby' import { type SiteConfig, type UserConfig } from '../siteConfig' import { resolveRewrites } from './rewritesPlugin' @@ -19,7 +19,7 @@ export async function resolvePages( userConfig: UserConfig, logger: Logger ) { - // Important: fast-glob doesn't guarantee order of the returned files. + // Important: tinyglobby doesn't guarantee order of the returned files. // We must sort the pages so the input list to rollup is stable across // builds - otherwise different input order could result in different exports // order in shared chunks which in turns invalidates the hash of every chunk! @@ -32,7 +32,8 @@ export async function resolvePages( '**/node_modules/**', '**/dist/**', ...(userConfig.srcExclude || []) - ] + ], + expandDirectories: false }) ).sort() diff --git a/src/node/plugins/staticDataPlugin.ts b/src/node/plugins/staticDataPlugin.ts index 1d8d231fd729..672738d94f13 100644 --- a/src/node/plugins/staticDataPlugin.ts +++ b/src/node/plugins/staticDataPlugin.ts @@ -6,7 +6,7 @@ import { } from 'vite' import path, { dirname, resolve } from 'path' import { isMatch } from 'micromatch' -import glob from 'fast-glob' +import { glob } from 'tinyglobby' const loaderMatch = /\.data\.m?(j|t)s($|\?)/ @@ -98,9 +98,11 @@ export const staticDataPlugin: Plugin = { // load the data let watchedFiles if (watch) { + if (typeof watch === 'string') watch = [watch] watchedFiles = ( await glob(watch, { - ignore: ['**/node_modules/**', '**/dist/**'] + ignore: ['**/node_modules/**', '**/dist/**'], + expandDirectories: false }) ).sort() }