fix(providence): correctly dedupe match-imports exportSpecifiers
This commit is contained in:
parent
30122f0e31
commit
306d57f57d
4 changed files with 42 additions and 25 deletions
5
.changeset/kind-zoos-bathe.md
Normal file
5
.changeset/kind-zoos-bathe.md
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'providence-analytics': patch
|
||||
---
|
||||
|
||||
correctly dedupe match-imports exportSpecifiers
|
||||
|
|
@ -237,7 +237,9 @@ async function matchImportsPostprocess(exportsAnalyzerResult, importsAnalyzerRes
|
|||
* Add it to the results array
|
||||
*/
|
||||
const id = `${exportEntry.specifier}::${exportEntry.file}::${exportsAnalyzerResult.analyzerMeta.targetProject.name}`;
|
||||
const resultForCurrentExport = conciseResultsArray.find(entry => entry.id === id);
|
||||
const resultForCurrentExport = conciseResultsArray.find(
|
||||
entry => entry.exportSpecifier && entry.exportSpecifier.id === id,
|
||||
);
|
||||
if (resultForCurrentExport) {
|
||||
resultForCurrentExport.importProjectFiles.push(importEntry.file);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -92,57 +92,41 @@
|
|||
{
|
||||
"name": "getterSetter",
|
||||
"accessType": "public",
|
||||
"kind": [
|
||||
"get",
|
||||
"set"
|
||||
]
|
||||
"kind": ["get", "set"]
|
||||
},
|
||||
{
|
||||
"name": "staticGetterSetter",
|
||||
"accessType": "public",
|
||||
"static": true,
|
||||
"kind": [
|
||||
"get",
|
||||
"set"
|
||||
]
|
||||
"kind": ["get", "set"]
|
||||
},
|
||||
{
|
||||
"name": "attributes",
|
||||
"accessType": "public",
|
||||
"static": true,
|
||||
"kind": [
|
||||
"get"
|
||||
]
|
||||
"kind": ["get"]
|
||||
},
|
||||
{
|
||||
"name": "styles",
|
||||
"accessType": "public",
|
||||
"static": true,
|
||||
"kind": [
|
||||
"get"
|
||||
]
|
||||
"kind": ["get"]
|
||||
},
|
||||
{
|
||||
"name": "updateComplete",
|
||||
"accessType": "public",
|
||||
"kind": [
|
||||
"get"
|
||||
]
|
||||
"kind": ["get"]
|
||||
},
|
||||
{
|
||||
"name": "localizeNamespaces",
|
||||
"accessType": "public",
|
||||
"static": true,
|
||||
"kind": [
|
||||
"get"
|
||||
]
|
||||
"kind": ["get"]
|
||||
},
|
||||
{
|
||||
"name": "slots",
|
||||
"accessType": "public",
|
||||
"kind": [
|
||||
"get"
|
||||
]
|
||||
"kind": ["get"]
|
||||
}
|
||||
],
|
||||
"methods": [
|
||||
|
|
@ -180,7 +164,7 @@
|
|||
},
|
||||
{
|
||||
"name": "requestUpdate",
|
||||
"accessType": "protected"
|
||||
"accessType": "public"
|
||||
},
|
||||
{
|
||||
"name": "createRenderRoot",
|
||||
|
|
|
|||
|
|
@ -441,6 +441,32 @@ describe('Analyzer "match-imports"', () => {
|
|||
]);
|
||||
});
|
||||
|
||||
it(`correctly merges/dedupes double found exports`, async () => {
|
||||
const refProject = {
|
||||
path: '/target/node_modules/ref',
|
||||
name: 'ref',
|
||||
files: [{ file: './index.js', code: `export default function x() {};` }],
|
||||
};
|
||||
const targetProject = {
|
||||
path: '/target',
|
||||
name: 'target',
|
||||
files: [
|
||||
{ file: './importDefault1.js', code: `import myFn1 from 'ref/index.js';` },
|
||||
{ file: './importDefault2.js', code: `import myFn2 from 'ref/index.js';` },
|
||||
],
|
||||
};
|
||||
mockTargetAndReferenceProject(targetProject, refProject);
|
||||
await providence(matchImportsQueryConfig, {
|
||||
targetProjectPaths: [targetProject.path],
|
||||
referenceProjectPaths: [refProject.path],
|
||||
});
|
||||
const queryResult = queryResults[0];
|
||||
expect(queryResult.queryOutput[0].exportSpecifier.name).to.equal('[default]');
|
||||
expect(queryResult.queryOutput[0].matchesPerProject).to.eql([
|
||||
{ files: ['./importDefault1.js', './importDefault2.js'], project: 'target' },
|
||||
]);
|
||||
});
|
||||
|
||||
describe('Inside small example project', () => {
|
||||
it(`produces a list of all matches, sorted by project`, async () => {
|
||||
mockTargetAndReferenceProject(searchTargetProject, referenceProject);
|
||||
|
|
|
|||
Loading…
Reference in a new issue