@kubb/ast 5.0.0-beta.27 → 5.0.0-beta.28
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 +6 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/utils.ts +12 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/ast",
|
|
3
|
-
"version": "5.0.0-beta.
|
|
3
|
+
"version": "5.0.0-beta.28",
|
|
4
4
|
"description": "Spec-agnostic AST layer for Kubb. Defines the node tree, visitor pattern, factory functions, and type guards used across all code generation plugins.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ast",
|
package/src/utils.ts
CHANGED
|
@@ -664,6 +664,17 @@ export function combineImports(imports: Array<ImportNode>, exports: Array<Export
|
|
|
664
664
|
return importNameMemo.get(key)!
|
|
665
665
|
}
|
|
666
666
|
|
|
667
|
+
// Paths that keep at least one used named import. A default import from such a path is retained
|
|
668
|
+
// even when its binding can't be found in `source` — e.g. a generated `client` default import
|
|
669
|
+
// alongside `import type { Client } from <same path>`, where merged grouped output omits the body.
|
|
670
|
+
const pathsWithUsedNamedImport = new Set<string>()
|
|
671
|
+
for (const node of imports) {
|
|
672
|
+
if (!Array.isArray(node.name)) continue
|
|
673
|
+
if (node.name.some((item) => (typeof item === 'string' ? isUsed(item) : isUsed(item.name ?? item.propertyName)))) {
|
|
674
|
+
pathsWithUsedNamedImport.add(node.path)
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
|
|
667
678
|
const result: Array<ImportNode> = []
|
|
668
679
|
// Accumulates array-named imports keyed by `path:isTypeOnly` for name-merging
|
|
669
680
|
const namedByPath = new Map<string, ImportNode>()
|
|
@@ -697,7 +708,7 @@ export function combineImports(imports: Array<ImportNode>, exports: Array<Export
|
|
|
697
708
|
namedByPath.set(key, newItem)
|
|
698
709
|
}
|
|
699
710
|
} else {
|
|
700
|
-
if (name && !isUsed(name)) continue
|
|
711
|
+
if (name && !isUsed(name) && !pathsWithUsedNamedImport.has(path)) continue
|
|
701
712
|
|
|
702
713
|
const key = importKey(path, name, isTypeOnly)
|
|
703
714
|
if (!seen.has(key)) {
|