From 2eb5714e96950080ca709c1cddcf9b81b297817b Mon Sep 17 00:00:00 2001 From: Ivan Tanev Date: Tue, 8 Oct 2024 00:41:41 +0300 Subject: [PATCH 1/2] Replace fast-glob with tinyglobby --- build/yarn.lock | 27 ++++++++++++++++++++++++--- packages/cli/package.json | 3 ++- packages/cli/src/package.ts | 8 +++++--- packages/cli/src/project.ts | 5 +++-- yarn.lock | 15 ++++++++++++++- 5 files changed, 48 insertions(+), 10 deletions(-) diff --git a/build/yarn.lock b/build/yarn.lock index 4d7ff4f0..d2f5f569 100644 --- a/build/yarn.lock +++ b/build/yarn.lock @@ -131,11 +131,21 @@ resolved "https://registry.yarnpkg.com/@babel/helper-string-parser/-/helper-string-parser-7.24.7.tgz#4d2d0f14820ede3b9807ea5fc36dfc8cd7da07f2" integrity sha512-7MbVt6xrwFQbunH2DNQsAP5sTGxfqQtErvBIvIMi6EQnbgUOuVYanvREcmFrOPhoXBrTtjhhP+lW+o5UfK+tDg== +"@babel/helper-string-parser@^7.25.7": + version "7.25.7" + resolved "https://registry.yarnpkg.com/@babel/helper-string-parser/-/helper-string-parser-7.25.7.tgz#d50e8d37b1176207b4fe9acedec386c565a44a54" + integrity sha512-CbkjYdsJNHFk8uqpEkpCvRs3YRp9tY6FmFY7wLMSYuGYkrdUi7r2lc4/wqsvlHoMznX3WJ9IP8giGPq68T/Y6g== + "@babel/helper-validator-identifier@^7.24.7": version "7.24.7" resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.24.7.tgz#75b889cfaf9e35c2aaf42cf0d72c8e91719251db" integrity sha512-rR+PBcQ1SMQDDyF6X0wxtG8QyLCgUB0eRAGguqRLfkCA87l7yAP7ehq8SNj96OOGTO8OBV70KhuFYcIkHXOg0w== +"@babel/helper-validator-identifier@^7.25.7": + version "7.25.7" + resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.25.7.tgz#77b7f60c40b15c97df735b38a66ba1d7c3e93da5" + integrity sha512-AM6TzwYqGChO45oiuPqwL2t20/HdMC1rTPAesnBCgPCSF1x3oN9MVUwQV2iyz4xqWrctwK5RNC8LV22kaQCNYg== + "@babel/helper-validator-option@^7.24.7": version "7.24.7" resolved "https://registry.yarnpkg.com/@babel/helper-validator-option/-/helper-validator-option-7.24.7.tgz#24c3bb77c7a425d1742eec8fb433b5a1b38e62f6" @@ -160,9 +170,11 @@ picocolors "^1.0.0" "@babel/parser@^7.21.2", "@babel/parser@^7.24.7": - version "7.24.7" - resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.24.7.tgz#9a5226f92f0c5c8ead550b750f5608e766c8ce85" - integrity sha512-9uUYRm6OqQrCqQdG1iCBwBPZgN8ciDBro2nIOFaiRz1/BCxaI7CNvQbDHvsArAC7Tw9Hda/B3U+6ui9u4HWXPw== + version "7.25.8" + resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.25.8.tgz#f6aaf38e80c36129460c1657c0762db584c9d5e2" + integrity sha512-HcttkxzdPucv3nNFmfOOMfFf64KgdJVqm1KaCm25dPGMLElo9nsLvXeJECQg8UzPuBGLyTSA0ZzqCtDSzKTEoQ== + dependencies: + "@babel/types" "^7.25.8" "@babel/plugin-transform-modules-commonjs@^7.7.5": version "7.24.7" @@ -214,6 +226,15 @@ "@babel/helper-validator-identifier" "^7.24.7" to-fast-properties "^2.0.0" +"@babel/types@^7.25.8": + version "7.25.8" + resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.25.8.tgz#5cf6037258e8a9bcad533f4979025140cb9993e1" + integrity sha512-JWtuCu8VQsMladxVz/P4HzHUGCAwpuqacmowgXFs5XjxIgKuNjnLokQzuVjlTvIzODaDmpjT3oxcC48vyk9EWg== + dependencies: + "@babel/helper-string-parser" "^7.25.7" + "@babel/helper-validator-identifier" "^7.25.7" + to-fast-properties "^2.0.0" + "@jridgewell/gen-mapping@^0.3.5": version "0.3.5" resolved "https://registry.yarnpkg.com/@jridgewell/gen-mapping/-/gen-mapping-0.3.5.tgz#dcce6aff74bdf6dad1a95802b69b04a2fcb1fb36" diff --git a/packages/cli/package.json b/packages/cli/package.json index 395b2ca6..afe4ba73 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -54,7 +54,6 @@ "enquirer": "^2.3.6", "estree-walker": "^2.0.1", "fast-deep-equal": "^2.0.1", - "fast-glob": "^3.2.4", "fs-extra": "^9.0.1", "is-reference": "^1.2.1", "jest-worker": "^26.3.0", @@ -70,6 +69,7 @@ "rollup": "^2.79.1", "semver": "^7.3.4", "terser": "^5.16.8", + "tinyglobby": "^0.2.9", "v8-compile-cache": "^2.1.1", "zod": "^3.21.4" }, @@ -82,6 +82,7 @@ "devDependencies": { "@types/estree": "*", "escape-string-regexp": "^4.0.0", + "fast-glob": "^3.2.4", "spawndamnit": "^2.0.0", "strip-ansi": "^6.0.0" } diff --git a/packages/cli/src/package.ts b/packages/cli/src/package.ts index e40511e3..41f29ce5 100644 --- a/packages/cli/src/package.ts +++ b/packages/cli/src/package.ts @@ -1,5 +1,5 @@ // based on https://github.com/jamiebuilds/std-pkg but reading fewer things, adding setters and reading the file -import fastGlob from "fast-glob"; +import { glob } from "tinyglobby"; import * as fs from "fs-extra"; import fsPromises from "fs/promises"; import nodePath from "path"; @@ -191,8 +191,9 @@ export class Package extends Item<{ let contents = await fs.readFile(filePath, "utf-8"); let pkg = new Package(filePath, contents, project._jsonDataByPath); pkg.project = project; - let entrypoints = await fastGlob(pkg.configEntrypoints, { + let entrypoints = await glob(pkg.configEntrypoints, { cwd: nodePath.join(pkg.directory, "src"), + expandDirectories: false, onlyFiles: true, absolute: true, }); @@ -211,8 +212,9 @@ export class Package extends Item<{ }), ]; if (!entrypoints.length) { - let oldEntrypoints = await fastGlob(pkg.configEntrypoints, { + let oldEntrypoints = await glob(pkg.configEntrypoints, { cwd: pkg.directory, + expandDirectories: false, onlyDirectories: true, absolute: true, }); diff --git a/packages/cli/src/project.ts b/packages/cli/src/project.ts index b4ed5526..e546fdfe 100644 --- a/packages/cli/src/project.ts +++ b/packages/cli/src/project.ts @@ -1,6 +1,6 @@ import nodePath from "path"; import { promptInput } from "./prompt"; -import fastGlob from "fast-glob"; +import { glob } from "tinyglobby"; import * as fs from "fs-extra"; import { Item } from "./item"; import { Package } from "./package"; @@ -123,9 +123,10 @@ export class Project extends Item<{ await this.save(); } - let filenames = await fastGlob(this.configPackages, { + let filenames = await glob(this.configPackages, { cwd: this.directory, onlyDirectories: true, + expandDirectories: false, absolute: true, }); diff --git a/yarn.lock b/yarn.lock index 7aec5ee7..4648d708 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6919,6 +6919,11 @@ fbjs@^3.0.0, fbjs@^3.0.1: setimmediate "^1.0.5" ua-parser-js "^0.7.30" +fdir@^6.4.0: + version "6.4.0" + resolved "https://registry.yarnpkg.com/fdir/-/fdir-6.4.0.tgz#8e80ab4b18a2ac24beebf9d20d71e1bc2627dbae" + integrity sha512-3oB133prH1o4j/L5lLW7uOCF1PlD+/It2L0eL/iAqWMB91RBbqTewABqxhj0ibBd90EEmWZq7ntIWzVaWcXTGQ== + feed@^4.2.2: version "4.2.2" resolved "https://registry.yarnpkg.com/feed/-/feed-4.2.2.tgz#865783ef6ed12579e2c44bbef3c9113bc4956a7e" @@ -10437,7 +10442,7 @@ picomatch@^2.2.3, picomatch@^2.3.1: resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42" integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA== -picomatch@^4.0.1: +picomatch@^4.0.1, picomatch@^4.0.2: version "4.0.2" resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-4.0.2.tgz#77c742931e8f3b8820946c76cd0c1f13730d1dab" integrity sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg== @@ -12628,6 +12633,14 @@ tiny-warning@^1.0.0, tiny-warning@^1.0.3: resolved "https://registry.yarnpkg.com/tiny-warning/-/tiny-warning-1.0.3.tgz#94a30db453df4c643d0fd566060d60a875d84754" integrity sha512-lBN9zLN/oAf68o3zNXYrdCt1kP8WsiGW8Oo2ka41b2IM5JL/S1CTyX1rW0mb/zSuJun0ZUrDxx4sqvYS2FWzPA== +tinyglobby@^0.2.9: + version "0.2.9" + resolved "https://registry.yarnpkg.com/tinyglobby/-/tinyglobby-0.2.9.tgz#6baddd1b0fe416403efb0dd40442c7d7c03c1c66" + integrity sha512-8or1+BGEdk1Zkkw2ii16qSS7uVrQJPre5A9o/XkWPATkk23FZh/15BKFxPnlTy6vkljZxLqYCzzBMj30ZrSvjw== + dependencies: + fdir "^6.4.0" + picomatch "^4.0.2" + tmp@^0.0.33: version "0.0.33" resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9" From ddfc5d090e7b5041c5d052672fe4c8ac5db053ee Mon Sep 17 00:00:00 2001 From: Ivan Tanev Date: Wed, 16 Oct 2024 12:22:02 +0300 Subject: [PATCH 2/2] changeset --- .changeset/plenty-cycles-applaud.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/plenty-cycles-applaud.md diff --git a/.changeset/plenty-cycles-applaud.md b/.changeset/plenty-cycles-applaud.md new file mode 100644 index 00000000..3fcb0de0 --- /dev/null +++ b/.changeset/plenty-cycles-applaud.md @@ -0,0 +1,5 @@ +--- +"@preconstruct/cli": minor +--- + +Replce `fast-glob` with `tinyglobby`