@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.js
CHANGED
|
@@ -251,12 +251,18 @@ function findTypeInFile(name, file) {
|
|
|
251
251
|
function resolveModuleSpecifier(moduleSpecifier, sourceFile, project) {
|
|
252
252
|
if (moduleSpecifier.startsWith(".")) {
|
|
253
253
|
const dir = dirname(sourceFile.getFilePath());
|
|
254
|
-
const
|
|
255
|
-
|
|
256
|
-
|
|
254
|
+
const ext = /\.(c|m)?(j|t)sx?$/.exec(moduleSpecifier)?.[0];
|
|
255
|
+
const base = ext ? moduleSpecifier.slice(0, -ext.length) : moduleSpecifier;
|
|
256
|
+
const flavour = ext?.startsWith(".c") ? "c" : ext?.startsWith(".m") ? "m" : "";
|
|
257
|
+
const candidates = [
|
|
258
|
+
resolve2(dir, `${base}.${flavour}ts`),
|
|
259
|
+
...flavour === "" ? [resolve2(dir, `${base}.tsx`)] : [],
|
|
257
260
|
resolve2(dir, `${moduleSpecifier}.ts`),
|
|
258
|
-
resolve2(dir, moduleSpecifier, "index.ts")
|
|
261
|
+
resolve2(dir, moduleSpecifier, "index.ts"),
|
|
262
|
+
resolve2(dir, `${base}.d.${flavour}ts`),
|
|
263
|
+
...ext === void 0 ? [resolve2(dir, moduleSpecifier, "index.d.ts")] : []
|
|
259
264
|
];
|
|
265
|
+
return [...new Set(candidates)];
|
|
260
266
|
}
|
|
261
267
|
const ctx = _ctxFor(project);
|
|
262
268
|
const baseUrl = ctx.pathsBase ?? ctx.projectRoot;
|
|
@@ -286,10 +292,11 @@ function resolveModuleSpecifier(moduleSpecifier, sourceFile, project) {
|
|
|
286
292
|
}
|
|
287
293
|
return [];
|
|
288
294
|
}
|
|
289
|
-
function resolveImportedType(name, sourceFile, project) {
|
|
295
|
+
function resolveImportedType(name, sourceFile, project, seen = /* @__PURE__ */ new Set()) {
|
|
290
296
|
for (const importDecl of sourceFile.getImportDeclarations()) {
|
|
291
|
-
const namedImport = importDecl.getNamedImports().find((n) => n.getName() === name);
|
|
297
|
+
const namedImport = importDecl.getNamedImports().find((n) => (n.getAliasNode()?.getText() ?? n.getName()) === name);
|
|
292
298
|
if (!namedImport) continue;
|
|
299
|
+
const sourceName = namedImport.getName();
|
|
293
300
|
const moduleSpecifier = importDecl.getModuleSpecifierValue();
|
|
294
301
|
const candidates = resolveModuleSpecifier(moduleSpecifier, sourceFile, project);
|
|
295
302
|
for (const candidate of candidates) {
|
|
@@ -301,17 +308,17 @@ function resolveImportedType(name, sourceFile, project) {
|
|
|
301
308
|
continue;
|
|
302
309
|
}
|
|
303
310
|
}
|
|
304
|
-
const result = findTypeInFile(
|
|
311
|
+
const result = findTypeInFile(sourceName, importedFile);
|
|
305
312
|
if (result) return result;
|
|
306
|
-
const viaReExport = resolveReExportedType(
|
|
313
|
+
const viaReExport = resolveReExportedType(sourceName, importedFile, project, /* @__PURE__ */ new Set());
|
|
307
314
|
if (viaReExport) return viaReExport;
|
|
308
315
|
}
|
|
309
316
|
if (candidates.length === 0) {
|
|
310
|
-
const viaCompiler = resolveBareSpecifierType(
|
|
317
|
+
const viaCompiler = resolveBareSpecifierType(sourceName, importDecl, project);
|
|
311
318
|
if (viaCompiler) return viaCompiler;
|
|
312
319
|
}
|
|
313
320
|
}
|
|
314
|
-
return resolveReExportedType(name, sourceFile, project,
|
|
321
|
+
return resolveReExportedType(name, sourceFile, project, seen);
|
|
315
322
|
}
|
|
316
323
|
function resolveBareSpecifierType(name, importDecl, project) {
|
|
317
324
|
let target;
|
|
@@ -326,9 +333,9 @@ function resolveBareSpecifierType(name, importDecl, project) {
|
|
|
326
333
|
return resolveReExportedType(name, target, project, /* @__PURE__ */ new Set());
|
|
327
334
|
}
|
|
328
335
|
function resolveReExportedType(name, file, project, seen) {
|
|
329
|
-
const
|
|
330
|
-
if (seen.has(
|
|
331
|
-
seen.add(
|
|
336
|
+
const visit = `${file.getFilePath()}#${name}`;
|
|
337
|
+
if (seen.has(visit)) return null;
|
|
338
|
+
seen.add(visit);
|
|
332
339
|
for (const exportDecl of file.getExportDeclarations()) {
|
|
333
340
|
const moduleSpecifier = exportDecl.getModuleSpecifierValue();
|
|
334
341
|
const namedExports = exportDecl.getNamedExports();
|
|
@@ -350,7 +357,7 @@ function resolveReExportedType(name, file, project, seen) {
|
|
|
350
357
|
const sourceName = namedExports.find((n) => (n.getAliasNode()?.getText() ?? n.getName()) === name)?.getName() ?? name;
|
|
351
358
|
const local = findTypeInFile(sourceName, file);
|
|
352
359
|
if (local) return local;
|
|
353
|
-
const imported = resolveImportedType(sourceName, file, project);
|
|
360
|
+
const imported = resolveImportedType(sourceName, file, project, seen);
|
|
354
361
|
if (imported) return imported;
|
|
355
362
|
}
|
|
356
363
|
return null;
|
|
@@ -5784,7 +5791,7 @@ async function watch(config, onChange, options = {}) {
|
|
|
5784
5791
|
}
|
|
5785
5792
|
|
|
5786
5793
|
// src/index.ts
|
|
5787
|
-
var VERSION = "0.27.
|
|
5794
|
+
var VERSION = "0.27.2";
|
|
5788
5795
|
|
|
5789
5796
|
// src/generate-manifest.ts
|
|
5790
5797
|
var MANIFEST_FILE = ".codegen-manifest.json";
|