@dudousxd/nestjs-codegen 0.27.0 → 0.27.1
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/CHANGELOG.md +6 -0
- package/dist/cli/main.cjs +12 -11
- package/dist/cli/main.cjs.map +1 -1
- package/dist/cli/main.js +12 -11
- package/dist/cli/main.js.map +1 -1
- package/dist/index.cjs +12 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +12 -11
- package/dist/index.js.map +1 -1
- package/dist/nest/index.cjs +12 -11
- package/dist/nest/index.cjs.map +1 -1
- package/dist/nest/index.js +12 -11
- package/dist/nest/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @dudousxd/nestjs-codegen
|
|
2
2
|
|
|
3
|
+
## 0.27.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#103](https://github.com/DavideCarvalho/nestjs-codegen/pull/103) [`9489714`](https://github.com/DavideCarvalho/nestjs-codegen/commit/94897149bb7133c61de43d66ab6c1bdc5de98cd9) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Type discovery no longer overflows the stack on bundled declaration files. A `.d.ts` chunk that imports a type under an alias and re-publishes it bare (`import { p as ToolKind } from './chunk'; export { ToolKind }` — what tsup/rollup emit) used to be matched by the import's source name, miss, and re-enter the same file with a fresh cycle guard until `Maximum call stack size exceeded` aborted the whole `codegen` run (seen with `@dudousxd/nestjs-agent-core` 0.29 through `@dudousxd/nestjs-agent-codegen`). Imports are now matched by their local name and followed under their source name, and the cycle guard is carried through the walk (keyed by file and name).
|
|
8
|
+
|
|
3
9
|
## 0.27.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
package/dist/cli/main.cjs
CHANGED
|
@@ -743,10 +743,11 @@ function resolveModuleSpecifier(moduleSpecifier, sourceFile, project) {
|
|
|
743
743
|
}
|
|
744
744
|
return [];
|
|
745
745
|
}
|
|
746
|
-
function resolveImportedType(name, sourceFile, project) {
|
|
746
|
+
function resolveImportedType(name, sourceFile, project, seen = /* @__PURE__ */ new Set()) {
|
|
747
747
|
for (const importDecl of sourceFile.getImportDeclarations()) {
|
|
748
|
-
const namedImport = importDecl.getNamedImports().find((n) => n.getName() === name);
|
|
748
|
+
const namedImport = importDecl.getNamedImports().find((n) => (n.getAliasNode()?.getText() ?? n.getName()) === name);
|
|
749
749
|
if (!namedImport) continue;
|
|
750
|
+
const sourceName = namedImport.getName();
|
|
750
751
|
const moduleSpecifier = importDecl.getModuleSpecifierValue();
|
|
751
752
|
const candidates = resolveModuleSpecifier(moduleSpecifier, sourceFile, project);
|
|
752
753
|
for (const candidate of candidates) {
|
|
@@ -758,17 +759,17 @@ function resolveImportedType(name, sourceFile, project) {
|
|
|
758
759
|
continue;
|
|
759
760
|
}
|
|
760
761
|
}
|
|
761
|
-
const result = findTypeInFile(
|
|
762
|
+
const result = findTypeInFile(sourceName, importedFile);
|
|
762
763
|
if (result) return result;
|
|
763
|
-
const viaReExport = resolveReExportedType(
|
|
764
|
+
const viaReExport = resolveReExportedType(sourceName, importedFile, project, /* @__PURE__ */ new Set());
|
|
764
765
|
if (viaReExport) return viaReExport;
|
|
765
766
|
}
|
|
766
767
|
if (candidates.length === 0) {
|
|
767
|
-
const viaCompiler = resolveBareSpecifierType(
|
|
768
|
+
const viaCompiler = resolveBareSpecifierType(sourceName, importDecl, project);
|
|
768
769
|
if (viaCompiler) return viaCompiler;
|
|
769
770
|
}
|
|
770
771
|
}
|
|
771
|
-
return resolveReExportedType(name, sourceFile, project,
|
|
772
|
+
return resolveReExportedType(name, sourceFile, project, seen);
|
|
772
773
|
}
|
|
773
774
|
function resolveBareSpecifierType(name, importDecl, project) {
|
|
774
775
|
let target;
|
|
@@ -783,9 +784,9 @@ function resolveBareSpecifierType(name, importDecl, project) {
|
|
|
783
784
|
return resolveReExportedType(name, target, project, /* @__PURE__ */ new Set());
|
|
784
785
|
}
|
|
785
786
|
function resolveReExportedType(name, file, project, seen) {
|
|
786
|
-
const
|
|
787
|
-
if (seen.has(
|
|
788
|
-
seen.add(
|
|
787
|
+
const visit = `${file.getFilePath()}#${name}`;
|
|
788
|
+
if (seen.has(visit)) return null;
|
|
789
|
+
seen.add(visit);
|
|
789
790
|
for (const exportDecl of file.getExportDeclarations()) {
|
|
790
791
|
const moduleSpecifier = exportDecl.getModuleSpecifierValue();
|
|
791
792
|
const namedExports = exportDecl.getNamedExports();
|
|
@@ -807,7 +808,7 @@ function resolveReExportedType(name, file, project, seen) {
|
|
|
807
808
|
const sourceName = namedExports.find((n) => (n.getAliasNode()?.getText() ?? n.getName()) === name)?.getName() ?? name;
|
|
808
809
|
const local = findTypeInFile(sourceName, file);
|
|
809
810
|
if (local) return local;
|
|
810
|
-
const imported = resolveImportedType(sourceName, file, project);
|
|
811
|
+
const imported = resolveImportedType(sourceName, file, project, seen);
|
|
811
812
|
if (imported) return imported;
|
|
812
813
|
}
|
|
813
814
|
return null;
|
|
@@ -6020,7 +6021,7 @@ async function watch(config, onChange, options = {}) {
|
|
|
6020
6021
|
}
|
|
6021
6022
|
|
|
6022
6023
|
// src/index.ts
|
|
6023
|
-
var VERSION = "0.27.
|
|
6024
|
+
var VERSION = "0.27.1";
|
|
6024
6025
|
|
|
6025
6026
|
// src/cli/codegen.ts
|
|
6026
6027
|
async function runCodegen(opts = {}) {
|