@kubb/ast 5.0.0-beta.107 → 5.0.0-beta.109
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 +13 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -24
- package/dist/index.js +14 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -457,6 +457,17 @@ function extractStringsFromNodes(nodes) {
|
|
|
457
457
|
}
|
|
458
458
|
//#endregion
|
|
459
459
|
//#region src/utils/combineFileMembers.ts
|
|
460
|
+
const IDENTIFIER_RUN = /[\w$]+/g;
|
|
461
|
+
/**
|
|
462
|
+
* How many imports a file needs before indexing the source beats scanning it once per name.
|
|
463
|
+
*/
|
|
464
|
+
const INDEX_ABOVE_IMPORTS = 128;
|
|
465
|
+
/**
|
|
466
|
+
* Every unbroken run of identifier characters in the source.
|
|
467
|
+
*/
|
|
468
|
+
function collectIdentifiers(source) {
|
|
469
|
+
return new Set(source.match(IDENTIFIER_RUN));
|
|
470
|
+
}
|
|
460
471
|
function sourceKey(source) {
|
|
461
472
|
return `${source.name ?? extractStringsFromNodes(source.nodes)}:${source.isExportable ?? false}:${source.isTypeOnly ?? false}`;
|
|
462
473
|
}
|
|
@@ -551,7 +562,8 @@ function combineExports(exports) {
|
|
|
551
562
|
*/
|
|
552
563
|
function combineImports(imports, exports, source) {
|
|
553
564
|
const exportedNames = new Set(exports.flatMap((e) => Array.isArray(e.name) ? e.name : e.name ? [e.name] : []));
|
|
554
|
-
const
|
|
565
|
+
const identifiers = source && imports.length > INDEX_ABOVE_IMPORTS ? collectIdentifiers(source) : null;
|
|
566
|
+
const isUsed = (importName) => !source || identifiers?.has(importName) || source.includes(importName) || exportedNames.has(importName);
|
|
555
567
|
const importNameMemo = /* @__PURE__ */ new Map();
|
|
556
568
|
const canonicalizeName = (n) => {
|
|
557
569
|
if (typeof n === "string") return n;
|
|
@@ -1581,9 +1593,6 @@ var exports_exports = /* @__PURE__ */ __exportAll({
|
|
|
1581
1593
|
collectImportedRefNames: () => collectImportedRefNames,
|
|
1582
1594
|
collectSync: () => collectSync,
|
|
1583
1595
|
collectUsedSchemaNames: () => collectUsedSchemaNames,
|
|
1584
|
-
combineExports: () => combineExports,
|
|
1585
|
-
combineImports: () => combineImports,
|
|
1586
|
-
combineSources: () => combineSources,
|
|
1587
1596
|
composeMacros: () => composeMacros,
|
|
1588
1597
|
constDef: () => constDef,
|
|
1589
1598
|
contentDef: () => contentDef,
|
|
@@ -1632,9 +1641,6 @@ exports.collect = collect;
|
|
|
1632
1641
|
exports.collectImportedRefNames = collectImportedRefNames;
|
|
1633
1642
|
exports.collectSync = collectSync;
|
|
1634
1643
|
exports.collectUsedSchemaNames = collectUsedSchemaNames;
|
|
1635
|
-
exports.combineExports = combineExports;
|
|
1636
|
-
exports.combineImports = combineImports;
|
|
1637
|
-
exports.combineSources = combineSources;
|
|
1638
1644
|
exports.composeMacros = composeMacros;
|
|
1639
1645
|
exports.constDef = constDef;
|
|
1640
1646
|
exports.contentDef = contentDef;
|