From 843baa00c3f705f662548391c7b49fa642692410 Mon Sep 17 00:00:00 2001 From: Ben McCann <322311+benmccann@users.noreply.github.com> Date: Mon, 30 Sep 2024 08:17:35 -0700 Subject: [PATCH] chore(dynamic-import-vars): switch to tinyglobby for fewer dependencies --- packages/dynamic-import-vars/package.json | 4 +-- .../src/dynamic-import-to-glob.js | 4 +-- packages/dynamic-import-vars/src/index.js | 4 +-- pnpm-lock.yaml | 35 ++++++++++++++++--- 4 files changed, 37 insertions(+), 10 deletions(-) diff --git a/packages/dynamic-import-vars/package.json b/packages/dynamic-import-vars/package.json index d25ea21b9..bad284257 100644 --- a/packages/dynamic-import-vars/package.json +++ b/packages/dynamic-import-vars/package.json @@ -66,8 +66,8 @@ "@rollup/pluginutils": "^5.0.1", "astring": "^1.8.5", "estree-walker": "^2.0.2", - "fast-glob": "^3.2.12", - "magic-string": "^0.30.3" + "magic-string": "^0.30.3", + "tinyglobby": "^0.2.7" }, "devDependencies": { "acorn": "^8.8.0", diff --git a/packages/dynamic-import-vars/src/dynamic-import-to-glob.js b/packages/dynamic-import-vars/src/dynamic-import-to-glob.js index ed1ae978e..de63b90b1 100644 --- a/packages/dynamic-import-vars/src/dynamic-import-to-glob.js +++ b/packages/dynamic-import-vars/src/dynamic-import-to-glob.js @@ -1,6 +1,6 @@ import path from 'path'; -import fastGlob from 'fast-glob'; +import { escapePath } from 'tinyglobby'; export class VariableDynamicImportError extends Error {} @@ -12,7 +12,7 @@ function sanitizeString(str) { if (str.includes('*')) { throw new VariableDynamicImportError('A dynamic import cannot contain * characters.'); } - return fastGlob.escapePath(str); + return escapePath(str); } function templateLiteralToGlob(node) { diff --git a/packages/dynamic-import-vars/src/index.js b/packages/dynamic-import-vars/src/index.js index b44770c45..3351a1582 100644 --- a/packages/dynamic-import-vars/src/index.js +++ b/packages/dynamic-import-vars/src/index.js @@ -2,7 +2,7 @@ import path from 'path'; import { walk } from 'estree-walker'; import MagicString from 'magic-string'; -import fastGlob from 'fast-glob'; +import { globSync } from 'tinyglobby'; import { generate } from 'astring'; import { createFilter } from '@rollup/pluginutils'; @@ -50,7 +50,7 @@ function dynamicImportVariables({ include, exclude, warnOnError, errorWhenNoFile } // execute the glob - const result = fastGlob.sync(glob, { cwd: path.dirname(id) }); + const result = globSync(glob, { cwd: path.dirname(id), expandDirectories: false }); const paths = result.map((r) => r.startsWith('./') || r.startsWith('../') ? r : `./${r}` ); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 66a7d6c92..7ff6bf991 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -295,12 +295,12 @@ importers: estree-walker: specifier: ^2.0.2 version: 2.0.2 - fast-glob: - specifier: ^3.2.12 - version: 3.2.12 magic-string: specifier: ^0.30.3 version: 0.30.3 + tinyglobby: + specifier: ^0.2.7 + version: 0.2.7 devDependencies: acorn: specifier: ^8.8.0 @@ -2286,7 +2286,7 @@ packages: resolution: {integrity: sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg==} concat-map@0.0.1: - resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==} + resolution: {integrity: sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=} concat-with-sourcemaps@1.1.0: resolution: {integrity: sha512-4gEjHJFT9e+2W/77h/DS5SGUgwDaOwprX8L/gl5+3ixnzkVJJsZWDSelmN3Oilw3LNDZjZV0yqH1hLG3k6nghg==} @@ -2731,6 +2731,14 @@ packages: picomatch: optional: true + fdir@6.4.0: + resolution: {integrity: sha512-3oB133prH1o4j/L5lLW7uOCF1PlD+/It2L0eL/iAqWMB91RBbqTewABqxhj0ibBd90EEmWZq7ntIWzVaWcXTGQ==} + peerDependencies: + picomatch: ^3 || ^4 + peerDependenciesMeta: + picomatch: + optional: true + figures@4.0.1: resolution: {integrity: sha512-rElJwkA/xS04Vfg+CaZodpso7VqBknOYbzi6I76hI4X80RUjkSxO2oAyPmGbuXUppywjqndOrQDl817hDnI++w==} engines: {node: '>=12'} @@ -3669,6 +3677,10 @@ packages: resolution: {integrity: sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==} engines: {node: '>=8.6'} + picomatch@4.0.2: + resolution: {integrity: sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==} + engines: {node: '>=12'} + pify@4.0.1: resolution: {integrity: sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==} engines: {node: '>=6'} @@ -4403,6 +4415,10 @@ packages: resolution: {integrity: sha512-TIsDdtKo6+XrPtiTm1ssmMngN1sAhyKnTO2kunQWqNPWIVvCm15Wmw4SWInwTVgJ5u/Tr04+8Ei9TNcw4x4ONA==} engines: {node: '>=4'} + tinyglobby@0.2.7: + resolution: {integrity: sha512-qFWYeNxBQxrOTRHvGjlRdBamy8JFqu6c0bwRru9leE+q8J72tLtlT0L3v+2T7fbLXN7FGzDNBhXkWiJqHUHD9g==} + engines: {node: '>=12.0.0'} + to-fast-properties@2.0.0: resolution: {integrity: sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog==} engines: {node: '>=4'} @@ -6963,6 +6979,10 @@ snapshots: optionalDependencies: picomatch: 2.3.1 + fdir@6.4.0(picomatch@4.0.2): + optionalDependencies: + picomatch: 4.0.2 + figures@4.0.1: dependencies: escape-string-regexp: 5.0.0 @@ -7880,6 +7900,8 @@ snapshots: picomatch@2.3.1: {} + picomatch@4.0.2: {} + pify@4.0.1: {} pify@5.0.0: {} @@ -8620,6 +8642,11 @@ snapshots: time-zone@1.0.0: {} + tinyglobby@0.2.7: + dependencies: + fdir: 6.4.0(picomatch@4.0.2) + picomatch: 4.0.2 + to-fast-properties@2.0.0: {} to-regex-range@5.0.1: