From 4e3d5c4c552f236e706b1c55dce2705123bbe0df Mon Sep 17 00:00:00 2001 From: Stefan Probst Date: Wed, 25 May 2022 11:37:16 +0200 Subject: [PATCH 1/3] fix: ignore node_modules in projects option glob --- src/index.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 55ee267..ac0fc45 100644 --- a/src/index.ts +++ b/src/index.ts @@ -287,10 +287,15 @@ function initMappers(options: TsResolverOptions) { ? options.project : [process.cwd()] + const ignore = ['./node_modules/**'] + mappers = configPaths // turn glob patterns into paths .reduce( - (paths, path) => [...paths, ...(isGlob(path) ? globSync(path) : [path])], + (paths, path) => [ + ...paths, + ...(isGlob(path) ? globSync(path, { ignore }) : [path]), + ], [], ) .map(loadConfig) From ee856013b419a25007ff77c882191ea08f4f7b3b Mon Sep 17 00:00:00 2001 From: Stefan Probst Date: Wed, 25 May 2022 18:06:53 +0200 Subject: [PATCH 2/3] refactor: use globby instead of glob --- package.json | 2 +- src/index.ts | 22 +++++++++++----------- yarn.lock | 4 ++-- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/package.json b/package.json index 382e6ce..f6b8431 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ }, "dependencies": { "debug": "^4.3.4", - "glob": "^7.2.0", + "globby": "^11.1.0", "is-glob": "^4.0.3", "resolve": "^1.22.0", "tsconfig-paths": "^4.0.0" diff --git a/src/index.ts b/src/index.ts index ac0fc45..f4ed21a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,7 +1,7 @@ import path from 'path' import debug from 'debug' -import { sync as globSync } from 'glob' +import { sync as globSync } from 'globby' import isGlob from 'is-glob' import { isCore, sync, SyncOpts } from 'resolve' import { @@ -287,17 +287,17 @@ function initMappers(options: TsResolverOptions) { ? options.project : [process.cwd()] - const ignore = ['./node_modules/**'] + const ignore = ['!**/node_modules/**'] - mappers = configPaths - // turn glob patterns into paths - .reduce( - (paths, path) => [ - ...paths, - ...(isGlob(path) ? globSync(path, { ignore }) : [path]), - ], - [], - ) + // turn glob patterns into paths + const projectPaths = [ + ...new Set([ + ...configPaths.filter(path => !isGlob(path)), + ...globSync([...configPaths.filter(path => isGlob(path)), ...ignore]), + ]), + ] + + mappers = projectPaths .map(loadConfig) .filter(isConfigLoaderSuccessResult) .map(configLoaderResult => { diff --git a/yarn.lock b/yarn.lock index c915c2c..96accd3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5317,9 +5317,9 @@ globby@10.0.1: merge2 "^1.2.3" slash "^3.0.0" -globby@^11.0.1, globby@^11.0.4: +globby@^11.0.1, globby@^11.0.4, globby@^11.1.0: version "11.1.0" - resolved "https://registry.yarnpkg.com/globby/-/globby-11.1.0.tgz#bd4be98bb042f83d796f7e3811991fbe82a0d34b" + resolved "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz#bd4be98bb042f83d796f7e3811991fbe82a0d34b" integrity sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g== dependencies: array-union "^2.1.0" From 81b29717ea8ce973f17c44ee1126b6005207bfbf Mon Sep 17 00:00:00 2001 From: Stefan Probst Date: Wed, 25 May 2022 19:15:52 +0200 Subject: [PATCH 3/3] chore: fix lock file --- yarn.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yarn.lock b/yarn.lock index 96accd3..0bd492b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5319,7 +5319,7 @@ globby@10.0.1: globby@^11.0.1, globby@^11.0.4, globby@^11.1.0: version "11.1.0" - resolved "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz#bd4be98bb042f83d796f7e3811991fbe82a0d34b" + resolved "https://registry.yarnpkg.com/globby/-/globby-11.1.0.tgz#bd4be98bb042f83d796f7e3811991fbe82a0d34b" integrity sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g== dependencies: array-union "^2.1.0"