diff --git a/package.json b/package.json index 9d94ab80ab..d0321e9339 100644 --- a/package.json +++ b/package.json @@ -79,7 +79,6 @@ "exsolve": "^1.0.7", "fetchdts": "^0.1.7", "fs-extra": "^11.3.1", - "globby": "^14.1.0", "gzip-size": "^7.0.0", "h3": "2.0.0-beta.4", "hookable": "^5.5.3", @@ -109,6 +108,7 @@ "source-map": "^0.7.6", "srvx": "^0.8.7", "std-env": "^3.9.0", + "tinyglobby": "^0.2.15", "ufo": "^1.6.1", "ultrahtml": "^1.6.0", "uncrypto": "^0.1.3", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 70db507dc4..ff0ecdd7ef 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -96,9 +96,6 @@ importers: fs-extra: specifier: ^11.3.1 version: 11.3.1 - globby: - specifier: ^14.1.0 - version: 14.1.0 gzip-size: specifier: ^7.0.0 version: 7.0.0 @@ -186,6 +183,9 @@ importers: std-env: specifier: ^3.9.0 version: 3.9.0 + tinyglobby: + specifier: ^0.2.15 + version: 0.2.15 ufo: specifier: ^1.6.1 version: 1.6.1 @@ -5667,6 +5667,10 @@ packages: resolution: {integrity: sha512-tX5e7OM1HnYr2+a2C/4V0htOcSQcoSTH9KgJnVvNm5zm/cyEWKJ7j7YutsH9CxMdtOkkLFy2AHrMci9IM8IPZQ==} engines: {node: '>=12.0.0'} + tinyglobby@0.2.15: + resolution: {integrity: sha512-j2Zq4NyQYG5XMST4cbs02Ak8iJUdxRM0XI5QyxXuZOzKOINmWurp3smXu3y5wDcJrptwpSjgXHzIQxR0omXljQ==} + engines: {node: '>=12.0.0'} + tinypool@1.1.1: resolution: {integrity: sha512-Zba82s87IFq9A9XmjiX5uZA/ARWDrB03OHlq+Vw1fSdt0I+4/Kutwy8BP4Y/y/aORMo61FQ0vIb5j44vSo5Pkg==} engines: {node: ^18.0.0 || >=20.0.0} @@ -8574,7 +8578,7 @@ snapshots: perfect-debounce: 1.0.0 pkg-types: 2.3.0 scule: 1.3.0 - tinyglobby: 0.2.14 + tinyglobby: 0.2.15 untyped: 2.0.0 transitivePeerDependencies: - magicast @@ -10986,7 +10990,7 @@ snapshots: postcss: 8.5.6 postcss-nested: 7.0.2(postcss@8.5.6) semver: 7.7.2 - tinyglobby: 0.2.14 + tinyglobby: 0.2.15 optionalDependencies: typescript: 5.9.2 vue: 3.5.21(typescript@5.9.2) @@ -12361,6 +12365,11 @@ snapshots: fdir: 6.5.0(picomatch@4.0.3) picomatch: 4.0.3 + tinyglobby@0.2.15: + dependencies: + fdir: 6.5.0(picomatch@4.0.3) + picomatch: 4.0.3 + tinypool@1.1.1: {} tinyrainbow@2.0.0: {} @@ -12458,7 +12467,7 @@ snapshots: rollup: 4.50.0 rollup-plugin-dts: 6.2.3(rollup@4.50.0)(typescript@5.9.2) scule: 1.3.0 - tinyglobby: 0.2.14 + tinyglobby: 0.2.15 untyped: 2.0.0 optionalDependencies: typescript: 5.9.2 @@ -12533,7 +12542,7 @@ snapshots: pkg-types: 2.3.0 scule: 1.3.0 strip-literal: 3.0.0 - tinyglobby: 0.2.14 + tinyglobby: 0.2.15 unplugin: 2.3.10 unplugin-utils: 0.2.5 @@ -12747,7 +12756,7 @@ snapshots: std-env: 3.9.0 tinybench: 2.9.0 tinyexec: 0.3.2 - tinyglobby: 0.2.14 + tinyglobby: 0.2.15 tinypool: 1.1.1 tinyrainbow: 2.0.0 vite: 7.1.4(@types/node@24.3.1)(jiti@2.5.1)(terser@5.44.0)(yaml@2.8.1) diff --git a/src/build/assets.ts b/src/build/assets.ts index e8001fb7ea..815fdb0380 100644 --- a/src/build/assets.ts +++ b/src/build/assets.ts @@ -1,5 +1,5 @@ import { existsSync, promises as fsp } from "node:fs"; -import { globby } from "globby"; +import { glob } from "tinyglobby"; import { isDirectory, prettyPath } from "../utils/fs"; import type { Nitro } from "nitro/types"; import { join, relative, resolve } from "pathe"; @@ -19,7 +19,7 @@ export async function scanUnprefixedPublicAssets(nitro: Nitro) { continue; } const includePatterns = getIncludePatterns(nitro, asset.dir); - const publicAssets = await globby(includePatterns, { + const publicAssets = await glob(includePatterns, { cwd: asset.dir, absolute: false, dot: true, @@ -40,7 +40,7 @@ export async function copyPublicAssets(nitro: Nitro) { const dstDir = join(nitro.options.output.publicDir, asset.baseURL!); if (await isDirectory(srcDir)) { const includePatterns = getIncludePatterns(nitro, srcDir); - const publicAssets = await globby(includePatterns, { + const publicAssets = await glob(includePatterns, { cwd: srcDir, absolute: false, dot: true, diff --git a/src/build/plugins/public-assets.ts b/src/build/plugins/public-assets.ts index 35adccd83e..6ca628971a 100644 --- a/src/build/plugins/public-assets.ts +++ b/src/build/plugins/public-assets.ts @@ -1,6 +1,6 @@ import { promises as fsp } from "node:fs"; import createEtag from "etag"; -import { globby } from "globby"; +import { glob } from "tinyglobby"; import mime from "mime"; import type { Nitro } from "nitro/types"; import type { PublicAsset } from "nitro/types"; @@ -26,7 +26,7 @@ export function publicAssets(nitro: Nitro): Plugin { // #nitro-internal-virtual/public-assets-data "#nitro-internal-virtual/public-assets-data": async () => { const assets: Record = {}; - const files = await globby("**", { + const files = await glob("**", { cwd: nitro.options.output.publicDir, absolute: false, dot: true, diff --git a/src/build/plugins/server-assets.ts b/src/build/plugins/server-assets.ts index aa81970c64..26b2934c62 100644 --- a/src/build/plugins/server-assets.ts +++ b/src/build/plugins/server-assets.ts @@ -1,6 +1,6 @@ import { promises as fsp } from "node:fs"; import createEtag from "etag"; -import { globby } from "globby"; +import { glob } from "tinyglobby"; import mime from "mime"; import type { Nitro } from "nitro/types"; import { resolve } from "pathe"; @@ -33,7 +33,7 @@ export function serverAssets(nitro: Nitro): Plugin { // Scan all assets const assets: Record = {}; for (const asset of nitro.options.serverAssets) { - const files = await globby(asset.pattern || "**/*", { + const files = await glob(asset.pattern || "**/*", { cwd: asset.dir, absolute: false, ignore: asset.ignore, diff --git a/src/presets/cloudflare/utils.ts b/src/presets/cloudflare/utils.ts index 9bae091c7b..2f2ff10d3b 100644 --- a/src/presets/cloudflare/utils.ts +++ b/src/presets/cloudflare/utils.ts @@ -8,8 +8,8 @@ import { writeFile } from "../_utils/fs"; import { parseTOML, parseJSONC } from "confbox"; import { readGitConfig, readPackageJSON, findNearestFile } from "pkg-types"; import { defu } from "defu"; -import { globby } from "globby"; import { provider } from "std-env"; +import { glob } from "tinyglobby"; import { join, resolve } from "pathe"; import { joinURL, @@ -70,7 +70,7 @@ export async function writeCFRoutes(nitro: Nitro) { ); // Unprefixed assets - const publicAssetFiles = await globby("**", { + const publicAssetFiles = await glob("**", { cwd: nitro.options.output.dir, absolute: false, dot: true, diff --git a/src/scan.ts b/src/scan.ts index 518c7b170e..5378f8af63 100644 --- a/src/scan.ts +++ b/src/scan.ts @@ -1,4 +1,4 @@ -import { globby } from "globby"; +import { glob } from "tinyglobby"; import type { Nitro } from "nitro/types"; import { join, relative } from "pathe"; import { withBase, withLeadingSlash, withoutTrailingSlash } from "ufo"; @@ -156,7 +156,7 @@ async function scanDir( dir: string, name: string ): Promise { - const fileNames = await globby(join(name, GLOB_SCAN_PATTERN), { + const fileNames = await glob(join(name, GLOB_SCAN_PATTERN), { cwd: dir, dot: true, ignore: nitro.options.ignore, diff --git a/src/utils/compress.ts b/src/utils/compress.ts index 422b887e84..f45e509631 100644 --- a/src/utils/compress.ts +++ b/src/utils/compress.ts @@ -1,13 +1,13 @@ import { existsSync } from "node:fs"; import fsp from "node:fs/promises"; import zlib from "node:zlib"; -import { globby } from "globby"; +import { glob } from "tinyglobby"; import mime from "mime"; import type { Nitro } from "nitro/types"; import { resolve } from "pathe"; export async function compressPublicAssets(nitro: Nitro) { - const publicFiles = await globby("**", { + const publicFiles = await glob("**", { cwd: nitro.options.output.publicDir, absolute: false, dot: true, diff --git a/src/utils/fs-tree.ts b/src/utils/fs-tree.ts index 0622e455f7..34afc15909 100644 --- a/src/utils/fs-tree.ts +++ b/src/utils/fs-tree.ts @@ -1,6 +1,6 @@ import { promises as fsp } from "node:fs"; import { colors } from "consola/utils"; -import { globby } from "globby"; +import { glob } from "tinyglobby"; import { gzipSize } from "gzip-size"; import { dirname, relative, resolve } from "pathe"; import prettyBytes from "pretty-bytes"; @@ -15,7 +15,7 @@ export async function generateFSTree( return; } - const files = await globby("**/*.*", { cwd: dir, ignore: ["*.map"] }); + const files = await glob("**/*.*", { cwd: dir, ignore: ["*.map"] }); const items: { file: string; path: string; size: number; gzip: number }[] = []; diff --git a/test/fixture/nitro.config.ts b/test/fixture/nitro.config.ts index 8bc0df9f2e..9b64e2573e 100644 --- a/test/fixture/nitro.config.ts +++ b/test/fixture/nitro.config.ts @@ -57,13 +57,7 @@ export default defineNitroConfig({ dir: "files", }, ], - ignore: [ - "api/**/_*", - "middleware/_ignored.ts", - "routes/_*.ts", - "**/_*.txt", - "!**/_unignored.txt", - ], + ignore: ["api/**/_*", "middleware/_ignored.ts", "routes/_*.ts", "**/_*.txt"], runtimeConfig: { dynamic: "initial", url: "https://{{APP_DOMAIN}}", diff --git a/test/presets/cloudflare-pages.test.ts b/test/presets/cloudflare-pages.test.ts index f9e4e969db..1a72944502 100644 --- a/test/presets/cloudflare-pages.test.ts +++ b/test/presets/cloudflare-pages.test.ts @@ -46,7 +46,6 @@ describe.skipIf(isWindows)("nitro:preset:cloudflare-pages", async () => { "/_openapi.json.gz", "/_scalar", "/_swagger", - "/_unignored.txt", "/favicon.ico", "/foo.css", "/foo.js", diff --git a/test/tests.ts b/test/tests.ts index a9ea04cc18..6ef20698c5 100644 --- a/test/tests.ts +++ b/test/tests.ts @@ -586,15 +586,6 @@ export function testNitro( expect((await callHandler({ url: "/favicon.ico" })).status).toBe(200); } ); - - it.skipIf(ctx.isWorker || ctx.isDev)( - "public files can be un-ignored with patterns", - async () => { - expect((await callHandler({ url: "/_unignored.txt" })).status).toBe( - 200 - ); - } - ); }); describe("headers", () => {