From 8892a8c1d0b54965501dd03113873ac66a50f74f Mon Sep 17 00:00:00 2001 From: Thomas Dy Date: Sat, 13 Aug 2022 07:50:10 +0900 Subject: [PATCH 1/2] perf: add filesystem caching support (#166) Co-authored-by: JounQin --- .changeset/nasty-points-speak.md | 5 +++++ src/index.ts | 7 +++++-- 2 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 .changeset/nasty-points-speak.md diff --git a/.changeset/nasty-points-speak.md b/.changeset/nasty-points-speak.md new file mode 100644 index 0000000..dbd14cc --- /dev/null +++ b/.changeset/nasty-points-speak.md @@ -0,0 +1,5 @@ +--- +"eslint-import-resolver-typescript": patch +--- + +perf: add filesystem caching support diff --git a/src/index.ts b/src/index.ts index 6ca26a9..3a80169 100644 --- a/src/index.ts +++ b/src/index.ts @@ -5,6 +5,7 @@ import { fileURLToPath } from 'node:url' import debug from 'debug' import { FileSystem, + CachedInputFileSystem, ResolveOptions, Resolver, ResolverFactory, @@ -113,6 +114,7 @@ const fileSystem = fs as FileSystem const JS_EXT_PATTERN = /\.(?:[cm]js|jsx?)$/ const RELATIVE_PATH_PATTERN = /^\.{1,2}(?:\/.*)?$/ +let previousOptions: TsResolverOptions | null | undefined let cachedOptions: InternalResolverOptions | undefined let mappersCachedOptions: InternalResolverOptions @@ -135,14 +137,15 @@ export function resolve( found: boolean path?: string | null } { - if (!cachedOptions || cachedOptions !== options) { + if (!cachedOptions || previousOptions !== options) { + previousOptions = options cachedOptions = { ...options, conditionNames: options?.conditionNames ?? defaultConditionNames, extensions: options?.extensions ?? defaultExtensions, extensionAlias: options?.extensionAlias ?? defaultExtensionAlias, mainFields: options?.mainFields ?? defaultMainFields, - fileSystem, + fileSystem: new CachedInputFileSystem(fileSystem, 5 * 1000), useSyncFileSystemCalls: true, } } From 91d16536e451a96e2c261938c09b0d8af18830c4 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 13 Aug 2022 06:53:27 +0800 Subject: [PATCH 2/2] chore: release eslint-import-resolver-typescript v3.4.1 (#167) Co-authored-by: github-actions[bot] --- .changeset/nasty-points-speak.md | 5 ----- CHANGELOG.md | 6 ++++++ package.json | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) delete mode 100644 .changeset/nasty-points-speak.md diff --git a/.changeset/nasty-points-speak.md b/.changeset/nasty-points-speak.md deleted file mode 100644 index dbd14cc..0000000 --- a/.changeset/nasty-points-speak.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"eslint-import-resolver-typescript": patch ---- - -perf: add filesystem caching support diff --git a/CHANGELOG.md b/CHANGELOG.md index 93427e6..719bf47 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## 3.4.1 + +### Patch Changes + +- [#166](https://github.com/import-js/eslint-import-resolver-typescript/pull/166) [`8892a8c`](https://github.com/import-js/eslint-import-resolver-typescript/commit/8892a8c1d0b54965501dd03113873ac66a50f74f) Thanks [@thatsmydoing](https://github.com/thatsmydoing)! - perf: add filesystem caching support + ## 3.4.0 ### Minor Changes diff --git a/package.json b/package.json index 231530f..d193678 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "eslint-import-resolver-typescript", - "version": "3.4.0", + "version": "3.4.1", "type": "module", "description": "This plugin adds `TypeScript` support to `eslint-plugin-import`", "repository": "git+https://github.com/import-js/eslint-import-resolver-typescript",