Skip to content

Commit

Permalink
More robust definition cache for ImportDeclaration (#2279)
Browse files Browse the repository at this point in the history
* bypass the cache for exportnameddeclarations

* dont set the cache either

* use alternate cache key

* CL
  • Loading branch information
thompsongl authored Sep 5, 2019
1 parent c3729dc commit e3b9bb9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
**Bug fixes**

- Removed extra right side margin in `EuiSuperDatePicker` ([#2236](https://github.com/elastic/eui/pull/2236))
- Fix incorrect `onClick` type for `EuiButtonEmpty` ([#2282](https://github.com/elastic/eui/pull/2282))
- Fixed incorrect `onClick` type for `EuiButtonEmpty` ([#2282](https://github.com/elastic/eui/pull/2282))
- Fixed compilation script to remove all TypeScript definition exports from built JS assets ([#2279](https://github.com/elastic/eui/pull/2279))

## [`13.7.0`](https://github.com/elastic/eui/tree/v13.7.0)

Expand Down
7 changes: 4 additions & 3 deletions scripts/babel/proptypes-from-ts-props/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -811,15 +811,16 @@ const typeDefinitionExtractors = {
return [];
}

if (importedDefinitionsCache.has(resolvedPath)) {
return importedDefinitionsCache.get(resolvedPath);
const cacheKey = `${sourceFilename}_${resolvedPath}`
if (importedDefinitionsCache.has(cacheKey)) {
return importedDefinitionsCache.get(cacheKey);
}

// to support circular dependencies, create & pre-cache the array of imported dependencies
// this array is directly mutated after parsing the subsequent files, supporting
// the circular nature as values settle into the correct locations
const importedDefinitions = [];
importedDefinitionsCache.set(resolvedPath, importedDefinitions);
importedDefinitionsCache.set(cacheKey, importedDefinitions);

// load & parse the imported file
const ast = parse(fs.readFileSync(resolvedPath).toString());
Expand Down

0 comments on commit e3b9bb9

Please sign in to comment.