@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/dist/nest/index.cjs
CHANGED
|
@@ -279,12 +279,18 @@ function findTypeInFile(name, file) {
|
|
|
279
279
|
function resolveModuleSpecifier(moduleSpecifier, sourceFile, project) {
|
|
280
280
|
if (moduleSpecifier.startsWith(".")) {
|
|
281
281
|
const dir = (0, import_node_path2.dirname)(sourceFile.getFilePath());
|
|
282
|
-
const
|
|
283
|
-
|
|
284
|
-
|
|
282
|
+
const ext = /\.(c|m)?(j|t)sx?$/.exec(moduleSpecifier)?.[0];
|
|
283
|
+
const base = ext ? moduleSpecifier.slice(0, -ext.length) : moduleSpecifier;
|
|
284
|
+
const flavour = ext?.startsWith(".c") ? "c" : ext?.startsWith(".m") ? "m" : "";
|
|
285
|
+
const candidates = [
|
|
286
|
+
(0, import_node_path2.resolve)(dir, `${base}.${flavour}ts`),
|
|
287
|
+
...flavour === "" ? [(0, import_node_path2.resolve)(dir, `${base}.tsx`)] : [],
|
|
285
288
|
(0, import_node_path2.resolve)(dir, `${moduleSpecifier}.ts`),
|
|
286
|
-
(0, import_node_path2.resolve)(dir, moduleSpecifier, "index.ts")
|
|
289
|
+
(0, import_node_path2.resolve)(dir, moduleSpecifier, "index.ts"),
|
|
290
|
+
(0, import_node_path2.resolve)(dir, `${base}.d.${flavour}ts`),
|
|
291
|
+
...ext === void 0 ? [(0, import_node_path2.resolve)(dir, moduleSpecifier, "index.d.ts")] : []
|
|
287
292
|
];
|
|
293
|
+
return [...new Set(candidates)];
|
|
288
294
|
}
|
|
289
295
|
const ctx = _ctxFor(project);
|
|
290
296
|
const baseUrl = ctx.pathsBase ?? ctx.projectRoot;
|
|
@@ -314,10 +320,11 @@ function resolveModuleSpecifier(moduleSpecifier, sourceFile, project) {
|
|
|
314
320
|
}
|
|
315
321
|
return [];
|
|
316
322
|
}
|
|
317
|
-
function resolveImportedType(name, sourceFile, project) {
|
|
323
|
+
function resolveImportedType(name, sourceFile, project, seen = /* @__PURE__ */ new Set()) {
|
|
318
324
|
for (const importDecl of sourceFile.getImportDeclarations()) {
|
|
319
|
-
const namedImport = importDecl.getNamedImports().find((n) => n.getName() === name);
|
|
325
|
+
const namedImport = importDecl.getNamedImports().find((n) => (n.getAliasNode()?.getText() ?? n.getName()) === name);
|
|
320
326
|
if (!namedImport) continue;
|
|
327
|
+
const sourceName = namedImport.getName();
|
|
321
328
|
const moduleSpecifier = importDecl.getModuleSpecifierValue();
|
|
322
329
|
const candidates = resolveModuleSpecifier(moduleSpecifier, sourceFile, project);
|
|
323
330
|
for (const candidate of candidates) {
|
|
@@ -329,17 +336,17 @@ function resolveImportedType(name, sourceFile, project) {
|
|
|
329
336
|
continue;
|
|
330
337
|
}
|
|
331
338
|
}
|
|
332
|
-
const result = findTypeInFile(
|
|
339
|
+
const result = findTypeInFile(sourceName, importedFile);
|
|
333
340
|
if (result) return result;
|
|
334
|
-
const viaReExport = resolveReExportedType(
|
|
341
|
+
const viaReExport = resolveReExportedType(sourceName, importedFile, project, /* @__PURE__ */ new Set());
|
|
335
342
|
if (viaReExport) return viaReExport;
|
|
336
343
|
}
|
|
337
344
|
if (candidates.length === 0) {
|
|
338
|
-
const viaCompiler = resolveBareSpecifierType(
|
|
345
|
+
const viaCompiler = resolveBareSpecifierType(sourceName, importDecl, project);
|
|
339
346
|
if (viaCompiler) return viaCompiler;
|
|
340
347
|
}
|
|
341
348
|
}
|
|
342
|
-
return resolveReExportedType(name, sourceFile, project,
|
|
349
|
+
return resolveReExportedType(name, sourceFile, project, seen);
|
|
343
350
|
}
|
|
344
351
|
function resolveBareSpecifierType(name, importDecl, project) {
|
|
345
352
|
let target;
|
|
@@ -354,9 +361,9 @@ function resolveBareSpecifierType(name, importDecl, project) {
|
|
|
354
361
|
return resolveReExportedType(name, target, project, /* @__PURE__ */ new Set());
|
|
355
362
|
}
|
|
356
363
|
function resolveReExportedType(name, file, project, seen) {
|
|
357
|
-
const
|
|
358
|
-
if (seen.has(
|
|
359
|
-
seen.add(
|
|
364
|
+
const visit = `${file.getFilePath()}#${name}`;
|
|
365
|
+
if (seen.has(visit)) return null;
|
|
366
|
+
seen.add(visit);
|
|
360
367
|
for (const exportDecl of file.getExportDeclarations()) {
|
|
361
368
|
const moduleSpecifier = exportDecl.getModuleSpecifierValue();
|
|
362
369
|
const namedExports = exportDecl.getNamedExports();
|
|
@@ -378,7 +385,7 @@ function resolveReExportedType(name, file, project, seen) {
|
|
|
378
385
|
const sourceName = namedExports.find((n) => (n.getAliasNode()?.getText() ?? n.getName()) === name)?.getName() ?? name;
|
|
379
386
|
const local = findTypeInFile(sourceName, file);
|
|
380
387
|
if (local) return local;
|
|
381
|
-
const imported = resolveImportedType(sourceName, file, project);
|
|
388
|
+
const imported = resolveImportedType(sourceName, file, project, seen);
|
|
382
389
|
if (imported) return imported;
|
|
383
390
|
}
|
|
384
391
|
return null;
|
|
@@ -5805,7 +5812,7 @@ async function watch(config, onChange, options = {}) {
|
|
|
5805
5812
|
}
|
|
5806
5813
|
|
|
5807
5814
|
// src/index.ts
|
|
5808
|
-
var VERSION = "0.27.
|
|
5815
|
+
var VERSION = "0.27.2";
|
|
5809
5816
|
|
|
5810
5817
|
// src/generate-manifest.ts
|
|
5811
5818
|
var MANIFEST_FILE = ".codegen-manifest.json";
|