Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): replace fast-glob with tinyglobby #4132

Merged
merged 6 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
33 changes: 30 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions scripts/copyClient.js
Original file line number Diff line number Diff line change
@@ -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))
})
4 changes: 2 additions & 2 deletions scripts/copyShared.js
Original file line number Diff line number Diff line change
@@ -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/'))
Expand Down
7 changes: 4 additions & 3 deletions src/node/contentLoader.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -54,11 +54,11 @@ export interface ContentOptions<T = ContentData[]> {
transform?: (data: ContentData[]) => T | Promise<T>

/**
* 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 {
Expand Down Expand Up @@ -118,6 +118,7 @@ export function createContentLoader<T = ContentData[]>(
files = (
await glob(pattern, {
ignore: ['**/node_modules/**', '**/dist/**'],
expandDirectories: false,
...globOptions
})
).sort()
Expand Down
7 changes: 4 additions & 3 deletions src/node/plugins/dynamicRoutesPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand All @@ -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!
Expand All @@ -32,7 +32,8 @@ export async function resolvePages(
'**/node_modules/**',
'**/dist/**',
...(userConfig.srcExclude || [])
]
],
expandDirectories: false
})
).sort()

Expand Down
6 changes: 4 additions & 2 deletions src/node/plugins/staticDataPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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($|\?)/

Expand Down Expand Up @@ -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()
}
Expand Down