@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.cjs CHANGED
@@ -1180,6 +1180,13 @@ function combineExports(exports) {
1180
1180
  function combineImports(imports, exports, source) {
1181
1181
  const exportedNames = new Set(exports.flatMap((e) => Array.isArray(e.name) ? e.name : e.name ? [e.name] : []));
1182
1182
  const isUsed = (importName) => !source || source.includes(importName) || exportedNames.has(importName);
1183
+ const importNameMemo = /* @__PURE__ */ new Map();
1184
+ const canonicalizeName = (n) => {
1185
+ if (typeof n === "string") return n;
1186
+ const key = `${n.propertyName}:${n.name ?? ""}`;
1187
+ if (!importNameMemo.has(key)) importNameMemo.set(key, n);
1188
+ return importNameMemo.get(key);
1189
+ };
1183
1190
  const result = [];
1184
1191
  const namedByPath = /* @__PURE__ */ new Map();
1185
1192
  const seen = /* @__PURE__ */ new Set();
@@ -1193,7 +1200,7 @@ function combineImports(imports, exports, source) {
1193
1200
  const { path, isTypeOnly } = curr;
1194
1201
  let { name } = curr;
1195
1202
  if (Array.isArray(name)) {
1196
- name = [...new Set(name)].filter((item) => typeof item === "string" ? isUsed(item) : isUsed(item.name ?? item.propertyName));
1203
+ name = [...new Set(name.map(canonicalizeName))].filter((item) => typeof item === "string" ? isUsed(item) : isUsed(item.name ?? item.propertyName));
1197
1204
  if (!name.length) continue;
1198
1205
  const key = pathTypeKey(path, isTypeOnly);
1199
1206
  const existing = namedByPath.get(key);