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
|
* Add it to the results array
|
||||||
*/
|
*/
|
||||||
const id = `${exportEntry.specifier}::${exportEntry.file}::${exportsAnalyzerResult.analyzerMeta.targetProject.name}`;
|
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) {
|
if (resultForCurrentExport) {
|
||||||
resultForCurrentExport.importProjectFiles.push(importEntry.file);
|
resultForCurrentExport.importProjectFiles.push(importEntry.file);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -92,57 +92,41 @@
|
||||||
{
|
{
|
||||||
"name": "getterSetter",
|
"name": "getterSetter",
|
||||||
"accessType": "public",
|
"accessType": "public",
|
||||||
"kind": [
|
"kind": ["get", "set"]
|
||||||
"get",
|
|
||||||
"set"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "staticGetterSetter",
|
"name": "staticGetterSetter",
|
||||||
"accessType": "public",
|
"accessType": "public",
|
||||||
"static": true,
|
"static": true,
|
||||||
"kind": [
|
"kind": ["get", "set"]
|
||||||
"get",
|
|
||||||
"set"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "attributes",
|
"name": "attributes",
|
||||||
"accessType": "public",
|
"accessType": "public",
|
||||||
"static": true,
|
"static": true,
|
||||||
"kind": [
|
"kind": ["get"]
|
||||||
"get"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "styles",
|
"name": "styles",
|
||||||
"accessType": "public",
|
"accessType": "public",
|
||||||
"static": true,
|
"static": true,
|
||||||
"kind": [
|
"kind": ["get"]
|
||||||
"get"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "updateComplete",
|
"name": "updateComplete",
|
||||||
"accessType": "public",
|
"accessType": "public",
|
||||||
"kind": [
|
"kind": ["get"]
|
||||||
"get"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "localizeNamespaces",
|
"name": "localizeNamespaces",
|
||||||
"accessType": "public",
|
"accessType": "public",
|
||||||
"static": true,
|
"static": true,
|
||||||
"kind": [
|
"kind": ["get"]
|
||||||
"get"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "slots",
|
"name": "slots",
|
||||||
"accessType": "public",
|
"accessType": "public",
|
||||||
"kind": [
|
"kind": ["get"]
|
||||||
"get"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"methods": [
|
"methods": [
|
||||||
|
|
@ -180,7 +164,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "requestUpdate",
|
"name": "requestUpdate",
|
||||||
"accessType": "protected"
|
"accessType": "public"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "createRenderRoot",
|
"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', () => {
|
describe('Inside small example project', () => {
|
||||||
it(`produces a list of all matches, sorted by project`, async () => {
|
it(`produces a list of all matches, sorted by project`, async () => {
|
||||||
mockTargetAndReferenceProject(searchTargetProject, referenceProject);
|
mockTargetAndReferenceProject(searchTargetProject, referenceProject);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue