@kubb/ast 5.0.0-alpha.42 → 5.0.0-alpha.44
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 +22 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +22 -14
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/utils.ts +16 -12
package/package.json
CHANGED
package/src/utils.ts
CHANGED
|
@@ -524,11 +524,11 @@ export function combineExports(exports: Array<ExportNode>): Array<ExportNode> {
|
|
|
524
524
|
// Deduplicates non-array exports by their exact identity
|
|
525
525
|
const seen = new Set<string>()
|
|
526
526
|
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
})
|
|
527
|
+
// Precompute sort keys once — avoids recomputing per comparison.
|
|
528
|
+
const keyed = exports.map((node) => ({ node, key: sortKey(node) }))
|
|
529
|
+
keyed.sort((a, b) => (a.key < b.key ? -1 : a.key > b.key ? 1 : 0))
|
|
530
|
+
|
|
531
|
+
for (const { node: curr } of keyed) {
|
|
532
532
|
const { name, path, isTypeOnly, asAlias } = curr
|
|
533
533
|
|
|
534
534
|
if (Array.isArray(name)) {
|
|
@@ -538,7 +538,9 @@ export function combineExports(exports: Array<ExportNode>): Array<ExportNode> {
|
|
|
538
538
|
const existing = namedByPath.get(key)
|
|
539
539
|
|
|
540
540
|
if (existing && Array.isArray(existing.name)) {
|
|
541
|
-
|
|
541
|
+
const merged = new Set(existing.name)
|
|
542
|
+
for (const n of name) merged.add(n)
|
|
543
|
+
existing.name = [...merged]
|
|
542
544
|
} else {
|
|
543
545
|
const newItem: ExportNode = { ...curr, name: [...new Set(name)] }
|
|
544
546
|
result.push(newItem)
|
|
@@ -572,11 +574,11 @@ export function combineImports(imports: Array<ImportNode>, exports: Array<Export
|
|
|
572
574
|
// Deduplicates non-array imports by their exact identity
|
|
573
575
|
const seen = new Set<string>()
|
|
574
576
|
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
})
|
|
577
|
+
// Precompute sort keys once — avoids recomputing per comparison.
|
|
578
|
+
const keyed = imports.map((node) => ({ node, key: sortKey(node) }))
|
|
579
|
+
keyed.sort((a, b) => (a.key < b.key ? -1 : a.key > b.key ? 1 : 0))
|
|
580
|
+
|
|
581
|
+
for (const { node: curr } of keyed) {
|
|
580
582
|
if (curr.path === curr.root) continue
|
|
581
583
|
|
|
582
584
|
const { path, isTypeOnly } = curr
|
|
@@ -590,7 +592,9 @@ export function combineImports(imports: Array<ImportNode>, exports: Array<Export
|
|
|
590
592
|
const existing = namedByPath.get(key)
|
|
591
593
|
|
|
592
594
|
if (existing && Array.isArray(existing.name)) {
|
|
593
|
-
|
|
595
|
+
const merged = new Set(existing.name)
|
|
596
|
+
for (const n of name) merged.add(n)
|
|
597
|
+
existing.name = [...merged]
|
|
594
598
|
} else {
|
|
595
599
|
const newItem: ImportNode = { ...curr, name }
|
|
596
600
|
result.push(newItem)
|