Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
### Fixed
- [`no-duplicates`]: remove duplicate identifiers in duplicate imports ([#2577], thanks [@joe-matsec])
- [`consistent-type-specifier-style`]: fix accidental removal of comma in certain cases ([#2754], thanks [@bradzacher])
- [Perf] `ExportMap`: Improve `ExportMap.for` performance on larger codebases ([#2756], thanks [@leipert])

### Changed
- [Docs] [`no-duplicates`]: fix example schema ([#2684], thanks [@simmo])
Expand Down Expand Up @@ -1066,6 +1067,7 @@ for info on changes for earlier releases.

[`memo-parser`]: ./memo-parser/README.md

[#2756]: https://github.com/import-js/eslint-plugin-import/pull/2756
[#2754]: https://github.com/import-js/eslint-plugin-import/pull/2754
[#2748]: https://github.com/import-js/eslint-plugin-import/pull/2748
[#2699]: https://github.com/import-js/eslint-plugin-import/pull/2699
Expand Down Expand Up @@ -1737,6 +1739,7 @@ for info on changes for earlier releases.
[@kylemh]: https://github.com/kylemh
[@laysent]: https://github.com/laysent
[@le0nik]: https://github.com/le0nik
[@leipert]: https://github.com/leipert
[@lemonmade]: https://github.com/lemonmade
[@lencioni]: https://github.com/lencioni
[@leonardodino]: https://github.com/leonardodino
Expand Down
21 changes: 19 additions & 2 deletions src/ExportMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ ExportMap.get = function (source, context) {
ExportMap.for = function (context) {
const { path } = context;

const cacheKey = hashObject(context).digest('hex');
const cacheKey = context.cacheKey || hashObject(context).digest('hex');
let exportMap = exportCache.get(cacheKey);

// return cached ignore
Expand Down Expand Up @@ -559,7 +559,7 @@ ExportMap.parse = function (path, content, context) {
if (tsConfigInfo.tsConfigPath !== undefined) {
// Projects not using TypeScript won't have `typescript` installed.
if (!ts) { ts = require('typescript'); } // eslint-disable-line import/no-extraneous-dependencies

const configFile = ts.readConfigFile(tsConfigInfo.tsConfigPath, ts.sys.readFile);
return ts.parseJsonConfigFileContent(
configFile.config,
Expand Down Expand Up @@ -781,12 +781,29 @@ export function recursivePatternCapture(pattern, callback) {
}
}

let parserOptionsHash = '';
let prevParserOptions = '';
let settingsHash = '';
let prevSettings = '';
/**
* don't hold full context object in memory, just grab what we need.
* also calculate a cacheKey, where parts of the cacheKey hash are memoized
*/
function childContext(path, context) {
const { settings, parserOptions, parserPath } = context;

if (JSON.stringify(settings) !== prevSettings) {
settingsHash = hashObject({ settings }).digest('hex');
prevSettings = JSON.stringify(settings);
}

if (JSON.stringify(parserOptions) !== prevParserOptions) {
parserOptionsHash = hashObject({ parserOptions }).digest('hex');
prevParserOptions = JSON.stringify(parserOptions);
}

return {
cacheKey: String(parserPath) + parserOptionsHash + settingsHash + String(path),
settings,
parserOptions,
parserPath,
Expand Down