diff --git a/package.json b/package.json index 7f3035a8f..e2300b807 100644 --- a/package.json +++ b/package.json @@ -57,10 +57,9 @@ "debug": "^4.3.5", "esbuild": "^0.23.0", "execa": "^5.1.1", - "fdir": "^6.1.1", + "globby": "^11.1.0", "joycon": "^3.1.1", "picocolors": "^1.0.1", - "picomatch": "^4.0.2", "postcss-load-config": "^6.0.1", "resolve-from": "^5.0.0", "rollup": "^4.19.0", @@ -75,7 +74,6 @@ "@types/debug": "4.1.12", "@types/fs-extra": "11.0.4", "@types/node": "20.14.11", - "@types/picomatch": "^3.0.0", "@types/resolve": "1.20.6", "flat": "6.0.1", "fs-extra": "11.2.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b12f804ea..704505847 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -29,18 +29,15 @@ importers: execa: specifier: ^5.1.1 version: 5.1.1 - fdir: - specifier: ^6.1.1 - version: 6.1.1(picomatch@4.0.2) + globby: + specifier: ^11.1.0 + version: 11.1.0 joycon: specifier: ^3.1.1 version: 3.1.1 picocolors: specifier: ^1.0.1 version: 1.0.1 - picomatch: - specifier: ^4.0.2 - version: 4.0.2 postcss-load-config: specifier: ^6.0.1 version: 6.0.1(jiti@1.21.6)(postcss@8.4.39)(yaml@2.4.5) @@ -78,9 +75,6 @@ importers: '@types/node': specifier: 20.14.11 version: 20.14.11 - '@types/picomatch': - specifier: ^3.0.0 - version: 3.0.0 '@types/resolve': specifier: 1.20.6 version: 1.20.6 @@ -474,6 +468,18 @@ packages: '@microsoft/tsdoc@0.15.0': resolution: {integrity: sha512-HZpPoABogPvjeJOdzCOSJsXeL/SMCBgBZMVC3X3d7YYp2gf31MfxhUoYUNwf1ERPJOnQc0wkFn9trqI6ZEdZuA==} + '@nodelib/fs.scandir@2.1.5': + resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==} + engines: {node: '>= 8'} + + '@nodelib/fs.stat@2.0.5': + resolution: {integrity: sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==} + engines: {node: '>= 8'} + + '@nodelib/fs.walk@1.2.8': + resolution: {integrity: sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==} + engines: {node: '>= 8'} + '@pkgjs/parseargs@0.11.0': resolution: {integrity: sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==} engines: {node: '>=14'} @@ -694,9 +700,6 @@ packages: '@types/node@20.14.11': resolution: {integrity: sha512-kprQpL8MMeszbz6ojB5/tU8PLN4kesnN8Gjzw349rDlNgsSzg90lAVj3llK99Dh7JON+t9AuscPPFW6mPbTnSA==} - '@types/picomatch@3.0.0': - resolution: {integrity: sha512-iX/Qwk9vU17N/5Q7QrV46wzciloTdCqTRt6z8A7uFFADM2+Sy5oQh9ldZhAiTXH+l0sM/EkXatEhJIs8FUyOBQ==} - '@types/pug@2.0.10': resolution: {integrity: sha512-Sk/uYFOBAB7mb74XcpizmH0KOR2Pv3D2Hmrh1Dmy5BmK3MpdSa5kqZcg6EKBdklU0bFXX9gCfzvpnyUehrPIuA==} @@ -778,6 +781,10 @@ packages: argparse@1.0.10: resolution: {integrity: sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==} + array-union@2.1.0: + resolution: {integrity: sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==} + engines: {node: '>=8'} + assertion-error@2.0.1: resolution: {integrity: sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==} engines: {node: '>=12'} @@ -880,6 +887,10 @@ packages: resolution: {integrity: sha512-reYkTUJAZb9gUuZ2RvVCNhVHdg62RHnJ7WJl8ftMi4diZ6NWlciOzQN88pUhSELEwflJht4oQDv0F0BMlwaYtA==} engines: {node: '>=8'} + dir-glob@3.0.1: + resolution: {integrity: sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==} + engines: {node: '>=8'} + eastasianwidth@0.2.0: resolution: {integrity: sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==} @@ -923,6 +934,13 @@ packages: fast-deep-equal@3.1.3: resolution: {integrity: sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==} + fast-glob@3.3.2: + resolution: {integrity: sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow==} + engines: {node: '>=8.6.0'} + + fastq@1.17.1: + resolution: {integrity: sha512-sRVD3lWVIXWg6By68ZN7vho9a1pQcN/WBFaAAsDDFzlJjvoGx0P8z7V1t72grFJfJhu3YPZBuu25f7Kaw2jN1w==} + fdir@6.1.1: resolution: {integrity: sha512-QfKBVg453Dyn3mr0Q0O+Tkr1r79lOTAKSi9f/Ot4+qVEwxWhav2Z+SudrG9vQjM2aYRMQQZ2/Q1zdA8ACM1pDg==} peerDependencies: @@ -986,6 +1004,10 @@ packages: resolution: {integrity: sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==} deprecated: Glob versions prior to v9 are no longer supported + globby@11.1.0: + resolution: {integrity: sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==} + engines: {node: '>=10'} + graceful-fs@4.2.11: resolution: {integrity: sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==} @@ -1009,6 +1031,10 @@ packages: resolution: {integrity: sha512-AXcZb6vzzrFAUE61HnN4mpLqd/cSIwNQjtNWR0euPm6y0iqx3G4gOXaIDdtdDwZmhwe82LA6+zinmW4UBWVePQ==} engines: {node: '>=16.17.0'} + ignore@5.3.1: + resolution: {integrity: sha512-5Fytz/IraMjqpwfd34ke28PTVMjZjJG2MPn5t7OE4eUCUNf8BAa7b5WUS9/Qvr6mwOQS7Mk6vdsMno5he+T8Xw==} + engines: {node: '>= 4'} + immutable@4.3.6: resolution: {integrity: sha512-Ju0+lEMyzMVZarkTn/gqRpdqd5dOPaz1mCZ0SH3JV6iFw81PldE/PEB1hWVEA288HPt4WXW8O7AWxB10M+03QQ==} @@ -1121,6 +1147,14 @@ packages: merge-stream@2.0.0: resolution: {integrity: sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==} + merge2@1.4.1: + resolution: {integrity: sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==} + engines: {node: '>= 8'} + + micromatch@4.0.7: + resolution: {integrity: sha512-LPP/3KorzCwBxfeUuZmaR6bG2kdeHSbe0P2tY3FLRU4vYrjYz5hI4QZwV0njUx3jeuKe67YukQ1LSPZBKDqO/Q==} + engines: {node: '>=8.6'} + mimic-fn@2.1.0: resolution: {integrity: sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==} engines: {node: '>=6'} @@ -1214,6 +1248,10 @@ packages: resolution: {integrity: sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA==} engines: {node: '>=16 || 14 >=14.18'} + path-type@4.0.0: + resolution: {integrity: sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==} + engines: {node: '>=8'} + pathe@1.1.2: resolution: {integrity: sha512-whLdWMYL2TwI08hn8/ZqAbrVemu0LNaNNJZX73O6qaIdCTfXutsLhMkjdENX0qhsQ9uIimo4/aQOmXkoon2nDQ==} @@ -1273,6 +1311,9 @@ packages: resolution: {integrity: sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==} engines: {node: '>=6'} + queue-microtask@1.2.3: + resolution: {integrity: sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==} + readdirp@3.6.0: resolution: {integrity: sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==} engines: {node: '>=8.10.0'} @@ -1289,6 +1330,10 @@ packages: resolution: {integrity: sha512-oKWePCxqpd6FlLvGV1VU0x7bkPmmCNolxzjMf4NczoDnQcIWrAF+cPtZn5i6n+RfD2d9i0tzpKnG6Yk168yIyw==} hasBin: true + reusify@1.0.4: + resolution: {integrity: sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==} + engines: {iojs: '>=1.0.0', node: '>=0.10.0'} + rimraf@2.7.1: resolution: {integrity: sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==} deprecated: Rimraf versions prior to v4 are no longer supported @@ -1306,6 +1351,9 @@ packages: engines: {node: '>=18.0.0', npm: '>=8.0.0'} hasBin: true + run-parallel@1.2.0: + resolution: {integrity: sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==} + sander@0.5.1: resolution: {integrity: sha512-3lVqBir7WuKDHGrKRDn/1Ye3kwpXaDOMsiRP1wd6wpZW56gJhsbp5RqQpA6JG/P+pkXizygnr1dKR8vzWaVsfA==} @@ -1337,6 +1385,10 @@ packages: resolution: {integrity: sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==} engines: {node: '>=14'} + slash@3.0.0: + resolution: {integrity: sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==} + engines: {node: '>=8'} + sorcery@0.11.1: resolution: {integrity: sha512-o7npfeJE6wi6J9l0/5LKshFzZ2rMatRiCDwYeDQaOzqdzRJwALhX7mk/A/ecg6wjMu7wdZbmXfD2S/vpOg0bdQ==} hasBin: true @@ -1882,6 +1934,18 @@ snapshots: '@microsoft/tsdoc@0.15.0': {} + '@nodelib/fs.scandir@2.1.5': + dependencies: + '@nodelib/fs.stat': 2.0.5 + run-parallel: 1.2.0 + + '@nodelib/fs.stat@2.0.5': {} + + '@nodelib/fs.walk@1.2.8': + dependencies: + '@nodelib/fs.scandir': 2.1.5 + fastq: 1.17.1 + '@pkgjs/parseargs@0.11.0': optional: true @@ -2056,8 +2120,6 @@ snapshots: dependencies: undici-types: 5.26.5 - '@types/picomatch@3.0.0': {} - '@types/pug@2.0.10': {} '@types/resolve@1.20.6': {} @@ -2145,6 +2207,8 @@ snapshots: dependencies: sprintf-js: 1.0.3 + array-union@2.1.0: {} + assertion-error@2.0.1: {} balanced-match@1.0.2: {} @@ -2240,6 +2304,10 @@ snapshots: detect-indent@6.1.0: {} + dir-glob@3.0.1: + dependencies: + path-type: 4.0.0 + eastasianwidth@0.2.0: {} emoji-regex@8.0.0: {} @@ -2336,6 +2404,18 @@ snapshots: fast-deep-equal@3.1.3: {} + fast-glob@3.3.2: + dependencies: + '@nodelib/fs.stat': 2.0.5 + '@nodelib/fs.walk': 1.2.8 + glob-parent: 5.1.2 + merge2: 1.4.1 + micromatch: 4.0.7 + + fastq@1.17.1: + dependencies: + reusify: 1.0.4 + fdir@6.1.1(picomatch@4.0.2): optionalDependencies: picomatch: 4.0.2 @@ -2398,6 +2478,15 @@ snapshots: once: 1.4.0 path-is-absolute: 1.0.1 + globby@11.1.0: + dependencies: + array-union: 2.1.0 + dir-glob: 3.0.1 + fast-glob: 3.3.2 + ignore: 5.3.1 + merge2: 1.4.1 + slash: 3.0.0 + graceful-fs@4.2.11: {} has-flag@3.0.0: @@ -2413,6 +2502,8 @@ snapshots: human-signals@5.0.0: {} + ignore@5.3.1: {} + immutable@4.3.6: {} import-lazy@4.0.0: {} @@ -2506,6 +2597,13 @@ snapshots: merge-stream@2.0.0: {} + merge2@1.4.1: {} + + micromatch@4.0.7: + dependencies: + braces: 3.0.3 + picomatch: 2.3.1 + mimic-fn@2.1.0: {} mimic-fn@4.0.0: {} @@ -2581,6 +2679,8 @@ snapshots: lru-cache: 10.4.3 minipass: 7.1.2 + path-type@4.0.0: {} + pathe@1.1.2: {} pathval@2.0.0: {} @@ -2615,6 +2715,8 @@ snapshots: punycode@2.3.1: {} + queue-microtask@1.2.3: {} + readdirp@3.6.0: dependencies: picomatch: 2.3.1 @@ -2629,6 +2731,8 @@ snapshots: path-parse: 1.0.7 supports-preserve-symlinks-flag: 1.0.0 + reusify@1.0.4: {} + rimraf@2.7.1: dependencies: glob: 7.2.3 @@ -2663,6 +2767,10 @@ snapshots: '@rollup/rollup-win32-x64-msvc': 4.19.0 fsevents: 2.3.3 + run-parallel@1.2.0: + dependencies: + queue-microtask: 1.2.3 + sander@0.5.1: dependencies: es6-promise: 3.3.1 @@ -2692,6 +2800,8 @@ snapshots: signal-exit@4.1.0: {} + slash@3.0.0: {} + sorcery@0.11.1: dependencies: '@jridgewell/sourcemap-codec': 1.5.0 diff --git a/src/index.ts b/src/index.ts index a00102d32..1c26fd2c3 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,10 +1,9 @@ import path from 'node:path' import fs from 'node:fs' import { Worker } from 'node:worker_threads' +import glob from 'globby' import { loadTsConfig } from 'bundle-require' import execa from 'execa' -import { fdir } from 'fdir' -import picomatch from 'picomatch' import kill from 'tree-kill' import { version } from '../package.json' import { PrettyError, handleError } from './errors' @@ -119,12 +118,7 @@ const normalizeOptions = async ( } if (Array.isArray(entry)) { - const matcher = picomatch(entry, { windows: process.platform === 'win32' }) - options.entry = await new fdir() - .withRelativePaths() - .filter((file) => matcher(file)) - .crawl(process.cwd()) - .withPromise() + options.entry = await glob(entry) // Ensure entry exists if (!options.entry || options.entry.length === 0) { throw new PrettyError(`Cannot find ${entry}`) diff --git a/src/utils.ts b/src/utils.ts index 04c08a4ec..08314658c 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,7 +1,6 @@ import fs from 'node:fs' import path from 'node:path' -import { fdir } from 'fdir' -import picomatch from 'picomatch' +import glob from 'globby' import resolveFrom from 'resolve-from' import strip from 'strip-json-comments' import type { Entry, Format } from './options' @@ -66,27 +65,10 @@ export function pathExists(p: string) { } export async function removeFiles(patterns: string[], dir: string) { - const matchPatterns: string[] = [] - const ignorePatterns: string[] = [] - for (const pattern of patterns) { - if (pattern.startsWith('!') && pattern[1] !== '(') { - ignorePatterns.push(pattern.slice(1)) - } else { - matchPatterns.push(pattern) - } - } - - const matcher = picomatch(matchPatterns, { - dot: true, - ignore: ignorePatterns, - windows: process.platform === 'win32', + const files = await glob(patterns, { + cwd: dir, + absolute: true, }) - - const files = await new fdir() - .withFullPaths() - .filter((file) => matcher(file)) - .crawl(dir) - .withPromise() files.forEach((file) => fs.existsSync(file) && fs.unlinkSync(file)) } diff --git a/test/utils.ts b/test/utils.ts index 2b60ffb1a..d928d9874 100644 --- a/test/utils.ts +++ b/test/utils.ts @@ -2,8 +2,8 @@ import path from 'node:path' import { fileURLToPath } from 'node:url' import { expect } from 'vitest' import execa from 'execa' -import { fdir } from 'fdir' import fs from 'fs-extra' +import glob from 'globby' const __dirname = path.dirname(fileURLToPath(import.meta.url)) const cacheDir = path.resolve(__dirname, '.cache') @@ -57,11 +57,9 @@ export async function run( } // Get output - const outFiles = await new fdir() - .withRelativePaths() - .crawl(path.resolve(testDir, 'dist')) - .withPromise() - .then((res) => res.map((f) => f.replaceAll('\\', '/')).sort()) + const outFiles = await glob('**/*', { + cwd: path.resolve(testDir, 'dist'), + }).then((res) => res.sort()) return { get output() {