Skip to content

Commit

Permalink
refactor: replace fast-glob with tinyglobby (#426)
Browse files Browse the repository at this point in the history
Co-authored-by: Pooya Parsa <[email protected]>
  • Loading branch information
SuperchupuDev and pi0 authored Sep 25, 2024
1 parent 2f815ef commit 40674c9
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 4 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"rollup": "^4.22.4",
"rollup-plugin-dts": "^6.1.1",
"scule": "^1.3.0",
"tinyglobby": "^0.2.2",
"ufo": "^1.5.4",
"untyped": "^1.4.2"
},
Expand Down
22 changes: 22 additions & 0 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 src/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { consola } from "consola";
import { defu } from "defu";
import { createHooks } from "hookable";
import prettyBytes from "pretty-bytes";
import fg from "fast-glob";
import { glob } from "tinyglobby";
import type { RollupOptions } from "rollup";
import { dumpObject, rmdir, resolvePreset, removeExtension } from "./utils";
import type { BuildContext, BuildConfig, BuildOptions } from "./types";
Expand Down Expand Up @@ -289,7 +289,7 @@ async function _build(
consola.success(colors.green("Build succeeded for " + options.name));

// Find all dist files and add missing entries as chunks
const outFiles = await fg("**", { cwd: options.outDir });
const outFiles = await glob(["**"], { cwd: options.outDir });
for (const file of outFiles) {
let entry = ctx.buildEntries.find((e) => e.path === file);
if (!entry) {
Expand Down
7 changes: 5 additions & 2 deletions src/builders/copy/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { promises as fsp } from "node:fs";
import { relative, resolve } from "pathe";
import fg from "fast-glob";
import { glob } from "tinyglobby";
import { symlink, rmdir, warn } from "../../utils";
import type { CopyBuildEntry, BuildContext } from "../../types";
import consola from "consola";
Expand All @@ -18,7 +18,10 @@ export async function copyBuild(ctx: BuildContext): Promise<void> {
await rmdir(distDir);
await symlink(entry.input, distDir);
} else {
const paths = await fg(entry.pattern || ["**"], {
const patterns = Array.isArray(entry.pattern)
? entry.pattern
: [entry.pattern || "**"];
const paths = await glob(patterns, {
cwd: resolve(ctx.options.rootDir, entry.input),
absolute: false,
});
Expand Down

0 comments on commit 40674c9

Please sign in to comment.