fix(js): switch from fast-glob to tinyglobby (#29141)
This commit is contained in:
parent
2d135f952b
commit
e3f8c813d6
@ -289,6 +289,7 @@
|
||||
"tar-stream": "~2.2.0",
|
||||
"tcp-port-used": "^1.0.2",
|
||||
"terser-webpack-plugin": "^5.3.3",
|
||||
"tinyglobby": "^0.2.10",
|
||||
"tmp": "~0.2.1",
|
||||
"tree-kill": "1.2.2",
|
||||
"ts-jest": "29.1.0",
|
||||
|
||||
@ -7,6 +7,10 @@
|
||||
"rules": {
|
||||
"no-restricted-imports": [
|
||||
"error",
|
||||
{
|
||||
"name": "fast-glob",
|
||||
"message": "Please use `tinyglobby` instead."
|
||||
},
|
||||
{
|
||||
"name": "fs-extra",
|
||||
"message": "Please use equivalent utilities from `node:fs` instead."
|
||||
|
||||
@ -49,7 +49,6 @@
|
||||
"columnify": "^1.6.0",
|
||||
"detect-port": "^1.5.1",
|
||||
"enquirer": "~2.3.6",
|
||||
"fast-glob": "3.2.7",
|
||||
"ignore": "^5.0.4",
|
||||
"js-tokens": "^4.0.0",
|
||||
"jsonc-parser": "3.2.0",
|
||||
@ -59,6 +58,7 @@
|
||||
"ora": "5.3.0",
|
||||
"semver": "^7.5.3",
|
||||
"source-map-support": "0.5.19",
|
||||
"tinyglobby": "^0.2.10",
|
||||
"ts-node": "10.9.1",
|
||||
"tsconfig-paths": "^4.1.2",
|
||||
"tslib": "^2.3.0"
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { ExecutorContext, output, readJsonFile } from '@nx/devkit';
|
||||
import { sync as globSync } from 'fast-glob';
|
||||
import { globSync } from 'tinyglobby';
|
||||
import { rmSync } from 'node:fs';
|
||||
import { dirname, join, normalize, relative, resolve } from 'path';
|
||||
import { copyAssets } from '../../utils/assets';
|
||||
@ -254,6 +254,7 @@ function createEntryPoints(
|
||||
if (!options.additionalEntryPoints?.length) return [];
|
||||
return globSync(options.additionalEntryPoints, {
|
||||
cwd: context.root,
|
||||
expandDirectories: false,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import * as fastGlob from 'fast-glob';
|
||||
import { globSync } from 'tinyglobby';
|
||||
import { basename, join } from 'path';
|
||||
|
||||
export type FileInputOutput = {
|
||||
@ -24,10 +24,11 @@ export function assetGlobsToFiles(
|
||||
ignore: string[] = [],
|
||||
dot: boolean = false
|
||||
) => {
|
||||
return fastGlob.sync(pattern, {
|
||||
return globSync(pattern, {
|
||||
cwd: input,
|
||||
onlyFiles: true,
|
||||
dot,
|
||||
expandDirectories: false,
|
||||
ignore,
|
||||
});
|
||||
};
|
||||
|
||||
@ -10,7 +10,7 @@ import {
|
||||
import * as pathPosix from 'node:path/posix';
|
||||
import * as path from 'node:path';
|
||||
import ignore from 'ignore';
|
||||
import * as fg from 'fast-glob';
|
||||
import { globSync } from 'tinyglobby';
|
||||
import { AssetGlob } from './assets';
|
||||
import { logger } from '@nx/devkit';
|
||||
import { ChangedFile, daemonClient } from 'nx/src/daemon/client/client';
|
||||
@ -115,10 +115,11 @@ export class CopyAssetsHandler {
|
||||
this.assetGlobs.map(async (ag) => {
|
||||
const pattern = this.normalizeAssetPattern(ag);
|
||||
|
||||
// fast-glob only supports Unix paths
|
||||
const files = await fg(pattern.replace(/\\/g, '/'), {
|
||||
// globbing only supports Unix paths
|
||||
const files = await globSync(pattern.replace(/\\/g, '/'), {
|
||||
cwd: this.rootDir,
|
||||
dot: true, // enable hidden files
|
||||
expandDirectories: false,
|
||||
});
|
||||
|
||||
this.callback(this.filesToEvent(files, ag));
|
||||
@ -130,10 +131,11 @@ export class CopyAssetsHandler {
|
||||
this.assetGlobs.forEach((ag) => {
|
||||
const pattern = this.normalizeAssetPattern(ag);
|
||||
|
||||
// fast-glob only supports Unix paths
|
||||
const files = fg.sync(pattern.replace(/\\/g, '/'), {
|
||||
// globbing only supports Unix paths
|
||||
const files = globSync(pattern.replace(/\\/g, '/'), {
|
||||
cwd: this.rootDir,
|
||||
dot: true, // enable hidden files
|
||||
expandDirectories: false,
|
||||
});
|
||||
|
||||
this.callback(this.filesToEvent(files, ag));
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { sync as globSync } from 'fast-glob';
|
||||
import { globSync } from 'tinyglobby';
|
||||
import { logger } from '@nx/devkit';
|
||||
|
||||
export function createEntryPoints(
|
||||
@ -13,7 +13,10 @@ export function createEntryPoints(
|
||||
// Performance impact should be negligible since there shouldn't be that many entry points.
|
||||
// Benchmarks show only 1-3% difference in execution time.
|
||||
for (const pattern of additionalEntryPoints) {
|
||||
const matched = globSync([pattern], { cwd: root });
|
||||
const matched = globSync([pattern], {
|
||||
cwd: root,
|
||||
expandDirectories: false,
|
||||
});
|
||||
if (!matched.length)
|
||||
logger.warn(`The pattern ${pattern} did not match any files.`);
|
||||
files.push(...matched);
|
||||
|
||||
26
pnpm-lock.yaml
generated
26
pnpm-lock.yaml
generated
@ -952,6 +952,9 @@ importers:
|
||||
terser-webpack-plugin:
|
||||
specifier: ^5.3.3
|
||||
version: 5.3.10(@swc/core@1.5.7(@swc/helpers@0.5.11))(esbuild@0.19.5)(webpack@5.88.0)
|
||||
tinyglobby:
|
||||
specifier: ^0.2.10
|
||||
version: 0.2.10
|
||||
tmp:
|
||||
specifier: ~0.2.1
|
||||
version: 0.2.3
|
||||
@ -10383,6 +10386,14 @@ packages:
|
||||
picomatch:
|
||||
optional: true
|
||||
|
||||
fdir@6.4.2:
|
||||
resolution: {integrity: sha512-KnhMXsKSPZlAhp7+IjUkRZKPb4fUyccpDrdFXbi4QL1qkmFh9kVY09Yox+n4MaOb3lHZ1Tv829C3oaaXoMYPDQ==}
|
||||
peerDependencies:
|
||||
picomatch: ^3 || ^4
|
||||
peerDependenciesMeta:
|
||||
picomatch:
|
||||
optional: true
|
||||
|
||||
fflate@0.6.10:
|
||||
resolution: {integrity: sha512-IQrh3lEPM93wVCEczc9SaAOvkmcoQn/G8Bo1e8ZPlY3X3bnAxWaBdvTdvM1hP62iZp0BXWDy4vTAy4fF0+Dlpg==}
|
||||
|
||||
@ -16225,6 +16236,10 @@ packages:
|
||||
tinybench@2.9.0:
|
||||
resolution: {integrity: sha512-0+DUvqWMValLmha6lr4kD8iAMK1HzV0/aKnCtWb9v9641TnP/MFb7Pc2bxoxQjTXAErryXVgUOfv2YqNllqGeg==}
|
||||
|
||||
tinyglobby@0.2.10:
|
||||
resolution: {integrity: sha512-Zc+8eJlFMvgatPZTl6A9L/yht8QqdmUNtURHaKZLmKBE12hNPSrqNkUp2cs3M/UKmNVVAMFQYSjYIVHDjW5zew==}
|
||||
engines: {node: '>=12.0.0'}
|
||||
|
||||
tinyglobby@0.2.6:
|
||||
resolution: {integrity: sha512-NbBoFBpqfcgd1tCiO8Lkfdk+xrA7mlLR9zgvZcZWQQwU63XAfUePyd6wZBaU93Hqw347lHnwFzttAkemHzzz4g==}
|
||||
engines: {node: '>=12.0.0'}
|
||||
@ -22038,7 +22053,7 @@ snapshots:
|
||||
semver: 7.6.3
|
||||
simple-git: 3.27.0
|
||||
sirv: 2.0.4
|
||||
tinyglobby: 0.2.6
|
||||
tinyglobby: 0.2.10
|
||||
unimport: 3.12.0(rollup@4.22.0)(webpack-sources@3.2.3)
|
||||
vite: 5.0.8(@types/node@20.16.10)(less@4.1.3)(sass@1.55.0)(stylus@0.64.0)(terser@5.36.0)
|
||||
vite-plugin-inspect: 0.8.7(@nuxt/kit@3.13.2(magicast@0.3.5)(rollup@4.22.0)(webpack-sources@3.2.3))(rollup@4.22.0)(vite@5.0.8(@types/node@20.16.10)(less@4.1.3)(sass@1.55.0)(stylus@0.64.0)(terser@5.36.0))
|
||||
@ -29374,6 +29389,10 @@ snapshots:
|
||||
optionalDependencies:
|
||||
picomatch: 4.0.2
|
||||
|
||||
fdir@6.4.2(picomatch@4.0.2):
|
||||
optionalDependencies:
|
||||
picomatch: 4.0.2
|
||||
|
||||
fflate@0.6.10: {}
|
||||
|
||||
fflate@0.8.2: {}
|
||||
@ -36655,6 +36674,11 @@ snapshots:
|
||||
|
||||
tinybench@2.9.0: {}
|
||||
|
||||
tinyglobby@0.2.10:
|
||||
dependencies:
|
||||
fdir: 6.4.2(picomatch@4.0.2)
|
||||
picomatch: 4.0.2
|
||||
|
||||
tinyglobby@0.2.6:
|
||||
dependencies:
|
||||
fdir: 6.3.0(picomatch@4.0.2)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user