@dudousxd/nestjs-codegen 0.27.0 → 0.27.2
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 +12 -0
- package/dist/cli/main.cjs +22 -15
- package/dist/cli/main.cjs.map +1 -1
- package/dist/cli/main.js +22 -15
- package/dist/cli/main.js.map +1 -1
- package/dist/index.cjs +22 -15
- 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 +22 -15
- package/dist/index.js.map +1 -1
- package/dist/nest/index.cjs +22 -15
- package/dist/nest/index.cjs.map +1 -1
- package/dist/nest/index.js +22 -15
- package/dist/nest/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @dudousxd/nestjs-codegen
|
|
2
2
|
|
|
3
|
+
## 0.27.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#105](https://github.com/DavideCarvalho/nestjs-codegen/pull/105) [`12be710`](https://github.com/DavideCarvalho/nestjs-codegen/commit/12be710f3c21ccc2e058d901a9921a72587ad939) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Follow relative imports inside declaration files to their declarations: `./chunk.cjs` resolves to `chunk.d.cts` (and `.cts`), `./chunk.mjs` to `chunk.d.mts`, `./chunk.js` to `chunk.d.ts` — after the source candidates, as before. A package's bundled `index.d.cts` imports its chunks by runtime name, and those types came out `unknown`.
|
|
8
|
+
|
|
9
|
+
## 0.27.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#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).
|
|
14
|
+
|
|
3
15
|
## 0.27.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
package/dist/cli/main.cjs
CHANGED
|
@@ -708,12 +708,18 @@ function findTypeInFile(name, file) {
|
|
|
708
708
|
function resolveModuleSpecifier(moduleSpecifier, sourceFile, project) {
|
|
709
709
|
if (moduleSpecifier.startsWith(".")) {
|
|
710
710
|
const dir = (0, import_node_path4.dirname)(sourceFile.getFilePath());
|
|
711
|
-
const
|
|
712
|
-
|
|
713
|
-
|
|
711
|
+
const ext = /\.(c|m)?(j|t)sx?$/.exec(moduleSpecifier)?.[0];
|
|
712
|
+
const base = ext ? moduleSpecifier.slice(0, -ext.length) : moduleSpecifier;
|
|
713
|
+
const flavour = ext?.startsWith(".c") ? "c" : ext?.startsWith(".m") ? "m" : "";
|
|
714
|
+
const candidates = [
|
|
715
|
+
(0, import_node_path4.resolve)(dir, `${base}.${flavour}ts`),
|
|
716
|
+
...flavour === "" ? [(0, import_node_path4.resolve)(dir, `${base}.tsx`)] : [],
|
|
714
717
|
(0, import_node_path4.resolve)(dir, `${moduleSpecifier}.ts`),
|
|
715
|
-
(0, import_node_path4.resolve)(dir, moduleSpecifier, "index.ts")
|
|
718
|
+
(0, import_node_path4.resolve)(dir, moduleSpecifier, "index.ts"),
|
|
719
|
+
(0, import_node_path4.resolve)(dir, `${base}.d.${flavour}ts`),
|
|
720
|
+
...ext === void 0 ? [(0, import_node_path4.resolve)(dir, moduleSpecifier, "index.d.ts")] : []
|
|
716
721
|
];
|
|
722
|
+
return [...new Set(candidates)];
|
|
717
723
|
}
|
|
718
724
|
const ctx = _ctxFor(project);
|
|
719
725
|
const baseUrl = ctx.pathsBase ?? ctx.projectRoot;
|
|
@@ -743,10 +749,11 @@ function resolveModuleSpecifier(moduleSpecifier, sourceFile, project) {
|
|
|
743
749
|
}
|
|
744
750
|
return [];
|
|
745
751
|
}
|
|
746
|
-
function resolveImportedType(name, sourceFile, project) {
|
|
752
|
+
function resolveImportedType(name, sourceFile, project, seen = /* @__PURE__ */ new Set()) {
|
|
747
753
|
for (const importDecl of sourceFile.getImportDeclarations()) {
|
|
748
|
-
const namedImport = importDecl.getNamedImports().find((n) => n.getName() === name);
|
|
754
|
+
const namedImport = importDecl.getNamedImports().find((n) => (n.getAliasNode()?.getText() ?? n.getName()) === name);
|
|
749
755
|
if (!namedImport) continue;
|
|
756
|
+
const sourceName = namedImport.getName();
|
|
750
757
|
const moduleSpecifier = importDecl.getModuleSpecifierValue();
|
|
751
758
|
const candidates = resolveModuleSpecifier(moduleSpecifier, sourceFile, project);
|
|
752
759
|
for (const candidate of candidates) {
|
|
@@ -758,17 +765,17 @@ function resolveImportedType(name, sourceFile, project) {
|
|
|
758
765
|
continue;
|
|
759
766
|
}
|
|
760
767
|
}
|
|
761
|
-
const result = findTypeInFile(
|
|
768
|
+
const result = findTypeInFile(sourceName, importedFile);
|
|
762
769
|
if (result) return result;
|
|
763
|
-
const viaReExport = resolveReExportedType(
|
|
770
|
+
const viaReExport = resolveReExportedType(sourceName, importedFile, project, /* @__PURE__ */ new Set());
|
|
764
771
|
if (viaReExport) return viaReExport;
|
|
765
772
|
}
|
|
766
773
|
if (candidates.length === 0) {
|
|
767
|
-
const viaCompiler = resolveBareSpecifierType(
|
|
774
|
+
const viaCompiler = resolveBareSpecifierType(sourceName, importDecl, project);
|
|
768
775
|
if (viaCompiler) return viaCompiler;
|
|
769
776
|
}
|
|
770
777
|
}
|
|
771
|
-
return resolveReExportedType(name, sourceFile, project,
|
|
778
|
+
return resolveReExportedType(name, sourceFile, project, seen);
|
|
772
779
|
}
|
|
773
780
|
function resolveBareSpecifierType(name, importDecl, project) {
|
|
774
781
|
let target;
|
|
@@ -783,9 +790,9 @@ function resolveBareSpecifierType(name, importDecl, project) {
|
|
|
783
790
|
return resolveReExportedType(name, target, project, /* @__PURE__ */ new Set());
|
|
784
791
|
}
|
|
785
792
|
function resolveReExportedType(name, file, project, seen) {
|
|
786
|
-
const
|
|
787
|
-
if (seen.has(
|
|
788
|
-
seen.add(
|
|
793
|
+
const visit = `${file.getFilePath()}#${name}`;
|
|
794
|
+
if (seen.has(visit)) return null;
|
|
795
|
+
seen.add(visit);
|
|
789
796
|
for (const exportDecl of file.getExportDeclarations()) {
|
|
790
797
|
const moduleSpecifier = exportDecl.getModuleSpecifierValue();
|
|
791
798
|
const namedExports = exportDecl.getNamedExports();
|
|
@@ -807,7 +814,7 @@ function resolveReExportedType(name, file, project, seen) {
|
|
|
807
814
|
const sourceName = namedExports.find((n) => (n.getAliasNode()?.getText() ?? n.getName()) === name)?.getName() ?? name;
|
|
808
815
|
const local = findTypeInFile(sourceName, file);
|
|
809
816
|
if (local) return local;
|
|
810
|
-
const imported = resolveImportedType(sourceName, file, project);
|
|
817
|
+
const imported = resolveImportedType(sourceName, file, project, seen);
|
|
811
818
|
if (imported) return imported;
|
|
812
819
|
}
|
|
813
820
|
return null;
|
|
@@ -6020,7 +6027,7 @@ async function watch(config, onChange, options = {}) {
|
|
|
6020
6027
|
}
|
|
6021
6028
|
|
|
6022
6029
|
// src/index.ts
|
|
6023
|
-
var VERSION = "0.27.
|
|
6030
|
+
var VERSION = "0.27.2";
|
|
6024
6031
|
|
|
6025
6032
|
// src/cli/codegen.ts
|
|
6026
6033
|
async function runCodegen(opts = {}) {
|