chore: replace fast-glob and ora with lighter alternatives (#2173)

This commit is contained in:
Florian Metz
2026-03-04 21:26:11 +01:00
committed by GitHub
parent a14d0b4f2f
commit ae55aecb0d
20 changed files with 70 additions and 101 deletions
+1 -1
View File
@@ -25,7 +25,7 @@
"@vitest/coverage-v8": "^4.0.18",
"changelogen": "^0.6.2",
"consola": "^3.4.2",
"fast-glob": "^3.3.3",
"tinyglobby": "^0.2.13",
"feed": "^5.2.0",
"fs-extra": "^11.3.3",
"lint-staged": "^16.2.7",
+1 -1
View File
@@ -29,7 +29,7 @@
"@wxt-dev/browser": "workspace:^",
"chokidar": "^5.0.0",
"confbox": "^0.1.8 || ^0.2.2",
"fast-glob": "^3.3.3"
"tinyglobby": "^0.2.13"
},
"peerDependencies": {
"wxt": ">=0.19.7"
+2 -1
View File
@@ -18,7 +18,7 @@ import {
generateTypeText,
SUPPORTED_LOCALES,
} from './build';
import glob from 'fast-glob';
import { glob } from 'tinyglobby';
import { basename, extname, join, resolve } from 'node:path';
import { watch } from 'chokidar';
import { GeneratedPublicFile, WxtDirFileEntry } from 'wxt';
@@ -47,6 +47,7 @@ export default defineWxtModule<I18nOptions>({
const files = await glob('*.{json,json5,jsonc,yml,yaml,toml}', {
cwd: localesDir,
absolute: true,
expandDirectories: false,
});
const unsupportedLocales: string[] = [];
+1 -1
View File
@@ -48,6 +48,6 @@
},
"dependencies": {
"defu": "^6.1.4",
"fast-glob": "^3.3.3"
"tinyglobby": "^0.2.13"
}
}
+2 -1
View File
@@ -1,7 +1,7 @@
import { describe, it, expect } from 'vitest';
import { TestProject, WXT_PACKAGE_DIR } from '../utils';
import spawn from 'nano-spawn';
import glob from 'fast-glob';
import { glob } from 'tinyglobby';
import { mkdir, writeJson } from 'fs-extra';
describe('Init command', () => {
@@ -21,6 +21,7 @@ describe('Init command', () => {
cwd: project.root,
onlyFiles: true,
dot: true,
expandDirectories: false,
});
expect(files.sort()).toMatchInlineSnapshot(`
+2 -1
View File
@@ -1,4 +1,4 @@
import glob from 'fast-glob';
import { glob } from 'tinyglobby';
import fs, { mkdir } from 'fs-extra';
import merge from 'lodash.merge';
import spawn from 'nano-spawn';
@@ -160,6 +160,7 @@ export class TestProject {
const outputFiles = await glob('**/*', {
cwd: this.resolvePath(dir),
ignore: ['**/node_modules', '**/.output'],
expandDirectories: false,
});
outputFiles.sort();
const fileContents = [];
+2 -2
View File
@@ -33,7 +33,7 @@
"dotenv": "^17.2.4",
"dotenv-expand": "^12.0.3",
"esbuild": "^0.27.1",
"fast-glob": "^3.3.3",
"tinyglobby": "^0.2.13",
"filesize": "^11.0.13",
"fs-extra": "^11.3.3",
"get-port-please": "^3.2.0",
@@ -51,7 +51,7 @@
"nypm": "^0.6.5",
"ohash": "^2.0.11",
"open": "^11.0.0",
"ora": "^9.3.0",
"nanospinner": "^1.2.2",
"perfect-debounce": "^2.1.0",
"picocolors": "^1.1.1",
"prompts": "^2.4.2",
+2 -1
View File
@@ -1,5 +1,5 @@
import path from 'node:path';
import glob from 'fast-glob';
import { glob } from 'tinyglobby';
import fs from 'fs-extra';
import pc from 'picocolors';
import { InlineConfig } from '../types';
@@ -48,6 +48,7 @@ export async function clean(config?: string | InlineConfig) {
absolute: true,
onlyDirectories: true,
deep: 2,
expandDirectories: false,
});
if (directories.length === 0) {
wxt.logger.debug('No generated files found.');
+4 -4
View File
@@ -157,8 +157,8 @@ async function cloneProject({
directory: string;
template: Template;
}) {
const { default: ora } = await import('ora');
const spinner = ora('Downloading template').start();
const { createSpinner } = await import('nanospinner');
const spinner = createSpinner('Downloading template').start();
try {
// 1. Clone repo
await downloadTemplate(`gh:${REPO}/${template.path}`, {
@@ -176,9 +176,9 @@ async function cloneProject({
consola.warn('Failed to move _gitignore to .gitignore:', err),
);
spinner.succeed();
spinner.success();
} catch (err) {
spinner.fail();
spinner.error();
throw Error(`Failed to setup new project: ${JSON.stringify(err, null, 2)}`);
}
}
+2 -1
View File
@@ -22,7 +22,7 @@ import defu from 'defu';
import { NullablyRequired } from './utils/types';
import fs from 'fs-extra';
import { normalizePath } from './utils';
import glob from 'fast-glob';
import { glob } from 'tinyglobby';
import { builtinModules } from '../builtin-modules';
import { getEslintVersion } from './utils/eslint';
import { safeStringToNumber } from './utils/number';
@@ -612,6 +612,7 @@ export async function resolveWxtUserModules(
const localModulePaths = await glob(['*.[tj]s', '*/index.[tj]s'], {
cwd: modulesDir,
onlyFiles: true,
expandDirectories: false,
}).catch(() => []);
// Sort modules to ensure a consistent execution order
localModulePaths.sort();
@@ -12,12 +12,12 @@ import {
import { resolve } from 'path';
import { findEntrypoints } from '../find-entrypoints';
import fs from 'fs-extra';
import glob from 'fast-glob';
import { glob } from 'tinyglobby';
import { fakeResolvedConfig, setFakeWxt } from '../../testing/fake-objects';
import { unnormalizePath } from '../../paths';
import { wxt } from '../../../wxt';
vi.mock('fast-glob');
vi.mock('tinyglobby');
const globMock = vi.mocked(glob);
vi.mock('fs-extra');
@@ -7,26 +7,28 @@ import {
import { getPublicFiles } from '../fs';
import fs from 'fs-extra';
import { dirname, resolve } from 'path';
import type { Ora } from 'ora';
import type { Spinner } from 'nanospinner';
import pc from 'picocolors';
import { wxt } from '../../wxt';
import { toArray } from '../arrays';
export async function buildEntrypoints(
groups: EntrypointGroup[],
spinner: Ora,
spinner: Spinner,
): Promise<Omit<BuildOutput, 'manifest'>> {
const steps: BuildStepOutput[] = [];
for (let i = 0; i < groups.length; i++) {
const group = groups[i];
const groupNames = toArray(group).map((e) => e.name);
const groupNameColored = groupNames.join(pc.dim(', '));
spinner.text =
pc.dim(`[${i + 1}/${groups.length}]`) + ` ${groupNameColored}`;
spinner.update({
text: pc.dim(`[${i + 1}/${groups.length}]`) + ` ${groupNameColored}`,
});
try {
steps.push(await wxt.builder.build(group));
} catch (err) {
spinner.stop().clear();
spinner.stop();
spinner.clear();
wxt.logger.error(err);
throw Error(`Failed to build ${groupNames.join(', ')}`, { cause: err });
}
@@ -16,7 +16,7 @@ import fs from 'fs-extra';
import { minimatch } from 'minimatch';
import { parseHTML } from 'linkedom';
import JSON5 from 'json5';
import glob from 'fast-glob';
import { glob } from 'tinyglobby';
import {
getEntrypointName,
isHtmlEntrypoint,
@@ -50,6 +50,7 @@ export async function findEntrypoints(): Promise<Entrypoint[]> {
const relativePaths = await glob(Object.keys(PATH_GLOB_TO_TYPE_MAP), {
cwd: wxt.config.entrypointsDir,
expandDirectories: false,
});
// Ensure consistent output
relativePaths.sort();
@@ -5,7 +5,7 @@ import fs from 'fs-extra';
import { groupEntrypoints } from './group-entrypoints';
import { formatDuration } from '../time';
import { printBuildSummary } from '../log';
import glob from 'fast-glob';
import { glob } from 'tinyglobby';
import { unnormalizePath } from '../paths';
import { rebuild } from './rebuild';
import { relative } from 'node:path';
@@ -100,6 +100,7 @@ async function combineAnalysisStats(): Promise<void> {
const unixFiles = await glob(`${wxt.config.analysis.outputName}-*.json`, {
cwd: wxt.config.analysis.outputDir,
absolute: true,
expandDirectories: false,
});
const absolutePaths = unixFiles.map(unnormalizePath);
@@ -4,6 +4,7 @@ import { buildEntrypoints } from './build-entrypoints';
import { generateManifest, writeManifest } from '../../utils/manifest';
import { wxt } from '../../wxt';
import type { Browser } from '@wxt-dev/browser';
import { createSpinner } from 'nanospinner';
/**
* Given a configuration, list of entrypoints, and an existing, partial output,
@@ -35,8 +36,7 @@ export async function rebuild(
manifest: Browser.runtime.Manifest;
warnings: any[][];
}> {
const { default: ora } = await import('ora');
const spinner = ora(`Preparing...`).start();
const spinner = createSpinner('Preparing...').start();
// Update types directory with new files and types
await generateWxtDir(allEntrypoints).catch((err) => {
+5 -2
View File
@@ -1,5 +1,5 @@
import fs from 'fs-extra';
import glob from 'fast-glob';
import { glob } from 'tinyglobby';
import { unnormalizePath } from './paths';
import { wxt } from '../wxt';
@@ -31,6 +31,9 @@ export async function writeFileIfDifferent(
export async function getPublicFiles(): Promise<string[]> {
if (!(await fs.pathExists(wxt.config.publicDir))) return [];
const files = await glob('**/*', { cwd: wxt.config.publicDir });
const files = await glob('**/*', {
cwd: wxt.config.publicDir,
expandDirectories: false,
});
return files.map(unnormalizePath);
}
+2 -1
View File
@@ -8,7 +8,7 @@ import { printFileList } from './utils/log';
import { findEntrypoints, internalBuild } from './utils/building';
import { registerWxt, wxt } from './wxt';
import JSZip from 'jszip';
import glob from 'fast-glob';
import { glob } from 'tinyglobby';
import { normalizePath } from './utils';
import { minimatchMultiple } from './utils/minimatch-multiple';
@@ -120,6 +120,7 @@ async function zipDir(
// Ignore node_modules, otherwise this glob step takes forever
ignore: ['**/node_modules'],
onlyFiles: true,
expandDirectories: false,
})
).filter((relativePath) => {
return (
+5 -2
View File
@@ -12,7 +12,7 @@ import type {
WxtModuleSetup,
} from './types';
import type * as vite from 'vite';
import glob from 'fast-glob';
import { glob } from 'tinyglobby';
import { resolve } from 'node:path';
import type { UnimportOptions } from 'unimport';
@@ -74,7 +74,10 @@ export function addEntrypoint(wxt: Wxt, entrypoint: Entrypoint): void {
*/
export function addPublicAssets(wxt: Wxt, dir: string): void {
wxt.hooks.hook('build:publicAssets', async (wxt, files) => {
const moreFiles = await glob('**/*', { cwd: dir });
const moreFiles = await glob('**/*', {
cwd: dir,
expandDirectories: false,
});
if (moreFiles.length === 0) {
wxt.logger.warn('No files to copy in', dir);
return;
+22 -69
View File
@@ -40,9 +40,6 @@ importers:
consola:
specifier: ^3.4.2
version: 3.4.2
fast-glob:
specifier: ^3.3.3
version: 3.3.3
feed:
specifier: ^5.2.0
version: 5.2.0
@@ -76,6 +73,9 @@ importers:
simple-git-hooks:
specifier: ^2.13.1
version: 2.13.1
tinyglobby:
specifier: ^0.2.13
version: 0.2.15
tsdown:
specifier: ^0.20.3
version: 0.20.3(publint@0.3.17)(typescript@5.9.3)
@@ -208,9 +208,9 @@ importers:
confbox:
specifier: ^0.1.8 || ^0.2.2
version: 0.2.2
fast-glob:
specifier: ^3.3.3
version: 3.3.3
tinyglobby:
specifier: ^0.2.13
version: 0.2.15
devDependencies:
'@types/node':
specifier: ^20.17.6
@@ -383,9 +383,9 @@ importers:
defu:
specifier: ^6.1.4
version: 6.1.4
fast-glob:
specifier: ^3.3.3
version: 3.3.3
tinyglobby:
specifier: ^0.2.13
version: 0.2.15
devDependencies:
oxlint:
specifier: ^1.43.0
@@ -474,9 +474,6 @@ importers:
esbuild:
specifier: ^0.27.1
version: 0.27.3
fast-glob:
specifier: ^3.3.3
version: 3.3.3
filesize:
specifier: ^11.0.13
version: 11.0.13
@@ -516,6 +513,9 @@ importers:
nano-spawn:
specifier: ^2.0.0
version: 2.0.0
nanospinner:
specifier: ^1.2.2
version: 1.2.2
normalize-path:
specifier: ^3.0.0
version: 3.0.0
@@ -528,9 +528,6 @@ importers:
open:
specifier: ^11.0.0
version: 11.0.0
ora:
specifier: ^9.3.0
version: 9.3.0
perfect-debounce:
specifier: ^2.1.0
version: 2.1.0
@@ -546,6 +543,9 @@ importers:
scule:
specifier: ^1.3.0
version: 1.3.0
tinyglobby:
specifier: ^0.2.13
version: 0.2.15
unimport:
specifier: ^3.13.1 || ^4.0.0 || ^5.0.0
version: 5.6.0
@@ -2532,10 +2532,6 @@ packages:
resolution: {integrity: sha512-aCj4O5wKyszjMmDT4tZj93kxyydN/K5zPWSCe6/0AV/AA1pqe5ZBIw0a2ZfPQV7lL5/yb5HsUreJ6UFAF1tEQw==}
engines: {node: '>=18'}
cli-spinners@3.4.0:
resolution: {integrity: sha512-bXfOC4QcT1tKXGorxL3wbJm6XJPDqEnij2gQ2m7ESQuE+/z9YFIWnl/5RpTiKWbMq3EVKR4fRLJGn6DVfu0mpw==}
engines: {node: '>=18.20'}
cli-truncate@5.1.1:
resolution: {integrity: sha512-SroPvNHxUnk+vIW/dOSfNqdy1sPEFkrTk6TUtqLCnBlo3N7TNYYkzzN7uSD6+jVjrdO4+p8nH7JzH6cIvUem6A==}
engines: {node: '>=20'}
@@ -3232,10 +3228,6 @@ packages:
resolution: {integrity: sha512-K55T22lfpQ63N4KEN57jZUAaAYqYHEe8veb/TycJRk9DdSCLLcovXz/mL6mOnhQaZsQGwPhuFopdQIlqGSEjiQ==}
engines: {node: '>=18'}
is-interactive@2.0.0:
resolution: {integrity: sha512-qP1vozQRI+BMOPcjFzrjXuQvdak2pHNUMZoeG2eRbiSqyvbEf/wQtEOTOX1guk6E3t36RkaqiSt8A/6YElNxLQ==}
engines: {node: '>=12'}
is-npm@6.1.0:
resolution: {integrity: sha512-O2z4/kNgyjhQwVR1Wpkbfc19JIhggF97NZNCpWTnjH7kVcZMUrnut9XSN7txI7VdyIYk5ZatOq3zvSuWpU8hoA==}
engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
@@ -3271,10 +3263,6 @@ packages:
resolution: {integrity: sha512-wBOr+rNM4gkAZqoLRJI4myw5WzzIdQosFAAbnvfXP5z1LyzgAI3ivOKehC5KfqlQJZoihVhirgtCBj378Eg8GA==}
engines: {node: '>=0.10.0'}
is-unicode-supported@2.1.0:
resolution: {integrity: sha512-mE00Gnza5EEB3Ds0HfMyllZzbBrmLOX3vfWoj9A9PEnTfratQ/BcaJOuMhnkhjXvb2+FkY3VuHqtAGpTPmglFQ==}
engines: {node: '>=18'}
is-what@4.1.16:
resolution: {integrity: sha512-ZhMwEosbFJkA0YhFnNDgTM4ZxDRsS6HqTo7qsZM08fehyRYIYa0yHu5R6mgo1n/8MgaPBXiPimPD77baVFYg+A==}
engines: {node: '>=12.13'}
@@ -3477,10 +3465,6 @@ packages:
lodash.once@4.1.1:
resolution: {integrity: sha512-Sb487aTOCr9drQVL8pIxOzVhafOjZN9UU54hiN8PU3uAiSV7lx1yYNpbNmex2PK6dSJoNTSJUUswT651yww3Mg==}
log-symbols@7.0.1:
resolution: {integrity: sha512-ja1E3yCr9i/0hmBVaM0bfwDjnGy8I/s6PP4DFp+yP+a+mrHO4Rm7DtmnqROTUkHIkqffC84YY7AeqX6oFk0WFg==}
engines: {node: '>=18'}
log-update@6.1.0:
resolution: {integrity: sha512-9ie8ItPR6tjY5uYJh8K/Zrv/RMZ5VOlOWvtZdEHYSTFKZfIBPQa9tOAEeAWhd+AnIneLJ22w5fjOYtoutpWq5w==}
engines: {node: '>=18'}
@@ -3721,6 +3705,9 @@ packages:
engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1}
hasBin: true
nanospinner@1.2.2:
resolution: {integrity: sha512-Zt/AmG6qRU3e+WnzGGLuMCEAO/dAu45stNbHY223tUxldaDAeE+FxSPsd9Q+j+paejmm0ZbrNVs5Sraqy3dRxA==}
natural-compare@1.4.0:
resolution: {integrity: sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==}
@@ -3801,10 +3788,6 @@ packages:
resolution: {integrity: sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==}
engines: {node: '>= 0.8.0'}
ora@9.3.0:
resolution: {integrity: sha512-lBX72MWFduWEf7v7uWf5DHp9Jn5BI8bNPGuFgtXMmr2uDz2Gz2749y3am3agSDdkhHPHYmmxEGSKH85ZLGzgXw==}
engines: {node: '>=20'}
os-shim@0.1.3:
resolution: {integrity: sha512-jd0cvB8qQ5uVt0lvCIexBaROw1KyKm5sbulg2fWOHjETisuCzWyt+eTZKEMs8v6HwzoGs8xik26jg7eCM6pS+A==}
engines: {node: '>= 0.4.0'}
@@ -4294,10 +4277,6 @@ packages:
std-env@3.10.0:
resolution: {integrity: sha512-5GS12FdOZNliM5mAOxFRg7Ir0pWz8MdpYm6AY6VPkGpbA7ZzmbzNcBJQ0GPvvyWgcY7QAhCgf9Uy89I03faLkg==}
stdin-discarder@0.3.1:
resolution: {integrity: sha512-reExS1kSGoElkextOcPkel4NE99S0BWxjUHQeDFnR8S993JxpPX7KU4MNmO19NXhlJp+8dmdCbKQVNgLJh2teA==}
engines: {node: '>=18'}
string-argv@0.3.2:
resolution: {integrity: sha512-aqD2Q0144Z+/RqG52NeHEkZauTAUWJO8c6yTftGJKO3Tja5tUgIfmIl6kExvhtxSDP7fXB6DvzkfMpCd/F3G+Q==}
engines: {node: '>=0.6.19'}
@@ -4915,10 +4894,6 @@ packages:
resolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==}
engines: {node: '>=10'}
yoctocolors@2.1.2:
resolution: {integrity: sha512-CzhO+pFNo8ajLM2d2IW/R93ipy99LWjtwblvC1RsoSUMZgyLbYFr221TnSNT7GjGdYui6P459mw9JH/g/zW2ug==}
engines: {node: '>=18'}
zip-dir@2.0.0:
resolution: {integrity: sha512-uhlsJZWz26FLYXOD6WVuq+fIcZ3aBPGo/cFdiLlv3KNwpa52IF3ISV8fLhQLiqVu5No3VhlqlgthN6gehil1Dg==}
@@ -6685,8 +6660,6 @@ snapshots:
dependencies:
restore-cursor: 5.1.0
cli-spinners@3.4.0: {}
cli-truncate@5.1.1:
dependencies:
slice-ansi: 7.1.2
@@ -7361,8 +7334,6 @@ snapshots:
global-directory: 4.0.1
is-path-inside: 4.0.0
is-interactive@2.0.0: {}
is-npm@6.1.0: {}
is-number@7.0.0: {}
@@ -7383,8 +7354,6 @@ snapshots:
is-relative@0.1.3: {}
is-unicode-supported@2.1.0: {}
is-what@4.1.16: {}
is-what@5.5.0: {}
@@ -7590,11 +7559,6 @@ snapshots:
lodash.once@4.1.1: {}
log-symbols@7.0.1:
dependencies:
is-unicode-supported: 2.1.0
yoctocolors: 2.1.2
log-update@6.1.0:
dependencies:
ansi-escapes: 7.3.0
@@ -7999,6 +7963,10 @@ snapshots:
nanoid@3.3.11: {}
nanospinner@1.2.2:
dependencies:
picocolors: 1.1.1
natural-compare@1.4.0: {}
node-addon-api@7.1.1:
@@ -8099,17 +8067,6 @@ snapshots:
type-check: 0.4.0
word-wrap: 1.2.5
ora@9.3.0:
dependencies:
chalk: 5.6.2
cli-cursor: 5.0.0
cli-spinners: 3.4.0
is-interactive: 2.0.0
is-unicode-supported: 2.1.0
log-symbols: 7.0.1
stdin-discarder: 0.3.1
string-width: 8.1.1
os-shim@0.1.3: {}
oxlint@1.43.0:
@@ -8676,8 +8633,6 @@ snapshots:
std-env@3.10.0: {}
stdin-discarder@0.3.1: {}
string-argv@0.3.2: {}
string-width@4.2.3:
@@ -9354,8 +9309,6 @@ snapshots:
yocto-queue@0.1.0: {}
yoctocolors@2.1.2: {}
zip-dir@2.0.0:
dependencies:
async: 3.2.6
+2 -2
View File
@@ -1,4 +1,4 @@
import glob from 'fast-glob';
import { glob } from 'tinyglobby';
import fs from 'fs-extra';
import * as semver from 'semver';
import { dirname } from 'node:path';
@@ -97,7 +97,7 @@ async function getPackageJsonDependencies(
}> {
const packageJsonFiles = await glob(
['package.json', '*/*/package.json', '!**/node_modules'],
{ onlyFiles: true },
{ onlyFiles: true, expandDirectories: false },
);
const packageJsons: PackageJsonData[] = await Promise.all(
packageJsonFiles.map(async (path) => ({