@kubb/ast 5.0.0-beta.2 → 5.0.0-beta.4

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
@@ -1157,6 +1157,13 @@ function combineExports(exports) {
1157
1157
  function combineImports(imports, exports, source) {
1158
1158
  const exportedNames = new Set(exports.flatMap((e) => Array.isArray(e.name) ? e.name : e.name ? [e.name] : []));
1159
1159
  const isUsed = (importName) => !source || source.includes(importName) || exportedNames.has(importName);
1160
+ const importNameMemo = /* @__PURE__ */ new Map();
1161
+ const canonicalizeName = (n) => {
1162
+ if (typeof n === "string") return n;
1163
+ const key = `${n.propertyName}:${n.name ?? ""}`;
1164
+ if (!importNameMemo.has(key)) importNameMemo.set(key, n);
1165
+ return importNameMemo.get(key);
1166
+ };
1160
1167
  const result = [];
1161
1168
  const namedByPath = /* @__PURE__ */ new Map();
1162
1169
  const seen = /* @__PURE__ */ new Set();
@@ -1170,7 +1177,7 @@ function combineImports(imports, exports, source) {
1170
1177
  const { path, isTypeOnly } = curr;
1171
1178
  let { name } = curr;
1172
1179
  if (Array.isArray(name)) {
1173
- name = [...new Set(name)].filter((item) => typeof item === "string" ? isUsed(item) : isUsed(item.name ?? item.propertyName));
1180
+ name = [...new Set(name.map(canonicalizeName))].filter((item) => typeof item === "string" ? isUsed(item) : isUsed(item.name ?? item.propertyName));
1174
1181
  if (!name.length) continue;
1175
1182
  const key = pathTypeKey(path, isTypeOnly);
1176
1183
  const existing = namedByPath.get(key);