@kubb/ast 5.0.0-beta.45 → 5.0.0-beta.47

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1464,7 +1464,18 @@ function createFile(input) {
1464
1464
  if (!extname) throw new Error(`No extname found for ${input.baseName}`);
1465
1465
  const source = (input.sources ?? []).flatMap((item) => item.nodes ?? []).map((node) => extractStringsFromNodes([node])).filter(Boolean).join("\n\n");
1466
1466
  const resolvedExports = input.exports?.length ? combineExports(input.exports) : [];
1467
- const resolvedImports = input.imports?.length ? combineImports(input.imports, resolvedExports, source || void 0) : [];
1467
+ const combinedImports = input.imports?.length ? combineImports(input.imports, resolvedExports, source || void 0) : [];
1468
+ const localNames = new Set((input.sources ?? []).map((item) => item.name).filter((name) => Boolean(name)));
1469
+ const nameOf = (item) => typeof item === "string" ? item : item.name ?? item.propertyName;
1470
+ const resolvedImports = combinedImports.filter((imp) => imp.path !== input.path).flatMap((imp) => {
1471
+ if (!Array.isArray(imp.name)) return typeof imp.name === "string" && localNames.has(imp.name) ? [] : [imp];
1472
+ const kept = imp.name.filter((item) => !localNames.has(nameOf(item)));
1473
+ if (!kept.length) return [];
1474
+ return [kept.length === imp.name.length ? imp : {
1475
+ ...imp,
1476
+ name: kept
1477
+ }];
1478
+ });
1468
1479
  const resolvedSources = input.sources?.length ? combineSources(input.sources) : [];
1469
1480
  return {
1470
1481
  kind: "File",