From 8a0cf53dc98384a4454ee8d349a35d37d56e2a0e Mon Sep 17 00:00:00 2001 From: Greg Thompson Date: Tue, 3 Sep 2019 13:34:40 -0500 Subject: [PATCH 1/4] bypass the cache for exportnameddeclarations --- scripts/babel/proptypes-from-ts-props/index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/babel/proptypes-from-ts-props/index.js b/scripts/babel/proptypes-from-ts-props/index.js index 99c0c9dfd32..dd52225a569 100644 --- a/scripts/babel/proptypes-from-ts-props/index.js +++ b/scripts/babel/proptypes-from-ts-props/index.js @@ -772,6 +772,7 @@ const typeDefinitionExtractors = { const { fs, sourceFilename, parse, state } = extractionOptions; const importPath = node.source.value; const isPathRelative = /^\.{1,2}\//.test(importPath); + let isExportNamedDeclaration = false; // only process relative imports for typescript definitions (avoid node_modules) if (isPathRelative) { @@ -782,6 +783,7 @@ const typeDefinitionExtractors = { case 'ImportSpecifier': return specifier.imported.name; case 'ExportSpecifier': + isExportNamedDeclaration = true; return specifier.local.name; // default: @@ -811,7 +813,7 @@ const typeDefinitionExtractors = { return []; } - if (importedDefinitionsCache.has(resolvedPath)) { + if (!isExportNamedDeclaration && importedDefinitionsCache.has(resolvedPath)) { return importedDefinitionsCache.get(resolvedPath); } From 24c5c4eb8b00eda19741d4b99a9ac2822d333e48 Mon Sep 17 00:00:00 2001 From: Greg Thompson Date: Tue, 3 Sep 2019 14:04:14 -0500 Subject: [PATCH 2/4] dont set the cache either --- scripts/babel/proptypes-from-ts-props/index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/babel/proptypes-from-ts-props/index.js b/scripts/babel/proptypes-from-ts-props/index.js index dd52225a569..9170ecf587c 100644 --- a/scripts/babel/proptypes-from-ts-props/index.js +++ b/scripts/babel/proptypes-from-ts-props/index.js @@ -813,6 +813,7 @@ const typeDefinitionExtractors = { return []; } + // Use the cached resolution if available, for imports only if (!isExportNamedDeclaration && importedDefinitionsCache.has(resolvedPath)) { return importedDefinitionsCache.get(resolvedPath); } @@ -821,7 +822,9 @@ const typeDefinitionExtractors = { // 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); + if (!isExportNamedDeclaration) { + importedDefinitionsCache.set(resolvedPath, importedDefinitions); + } // load & parse the imported file const ast = parse(fs.readFileSync(resolvedPath).toString()); From 6fe00350540f6b886a1cdee56b613c5f1227b4a6 Mon Sep 17 00:00:00 2001 From: Greg Thompson Date: Thu, 5 Sep 2019 09:00:29 -0500 Subject: [PATCH 3/4] use alternate cache key --- scripts/babel/proptypes-from-ts-props/index.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/scripts/babel/proptypes-from-ts-props/index.js b/scripts/babel/proptypes-from-ts-props/index.js index 9170ecf587c..bf6481ca25b 100644 --- a/scripts/babel/proptypes-from-ts-props/index.js +++ b/scripts/babel/proptypes-from-ts-props/index.js @@ -772,7 +772,6 @@ const typeDefinitionExtractors = { const { fs, sourceFilename, parse, state } = extractionOptions; const importPath = node.source.value; const isPathRelative = /^\.{1,2}\//.test(importPath); - let isExportNamedDeclaration = false; // only process relative imports for typescript definitions (avoid node_modules) if (isPathRelative) { @@ -783,7 +782,6 @@ const typeDefinitionExtractors = { case 'ImportSpecifier': return specifier.imported.name; case 'ExportSpecifier': - isExportNamedDeclaration = true; return specifier.local.name; // default: @@ -813,18 +811,16 @@ const typeDefinitionExtractors = { return []; } - // Use the cached resolution if available, for imports only - if (!isExportNamedDeclaration && 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 = []; - if (!isExportNamedDeclaration) { - importedDefinitionsCache.set(resolvedPath, importedDefinitions); - } + importedDefinitionsCache.set(cacheKey, importedDefinitions); // load & parse the imported file const ast = parse(fs.readFileSync(resolvedPath).toString()); From 274e051492436355563412e159dddecf9e911738 Mon Sep 17 00:00:00 2001 From: Greg Thompson Date: Thu, 5 Sep 2019 13:41:57 -0500 Subject: [PATCH 4/4] CL --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 26f62666793..850eaa3fa5d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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)