@dudousxd/nestjs-codegen 0.5.2 → 0.6.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/dist/index.cjs CHANGED
@@ -2304,7 +2304,6 @@ function resolveImportedType(name, sourceFile, project) {
2304
2304
  if (!namedImport) continue;
2305
2305
  const moduleSpecifier = importDecl.getModuleSpecifierValue();
2306
2306
  const candidates = resolveModuleSpecifier(moduleSpecifier, sourceFile, project);
2307
- if (candidates.length === 0) continue;
2308
2307
  for (const candidate of candidates) {
2309
2308
  let importedFile = project.getSourceFile(candidate);
2310
2309
  if (!importedFile) {
@@ -2319,9 +2318,25 @@ function resolveImportedType(name, sourceFile, project) {
2319
2318
  const viaReExport = resolveReExportedType(name, importedFile, project, /* @__PURE__ */ new Set());
2320
2319
  if (viaReExport) return viaReExport;
2321
2320
  }
2321
+ if (candidates.length === 0) {
2322
+ const viaCompiler = resolveBareSpecifierType(name, importDecl, project);
2323
+ if (viaCompiler) return viaCompiler;
2324
+ }
2322
2325
  }
2323
2326
  return resolveReExportedType(name, sourceFile, project, /* @__PURE__ */ new Set());
2324
2327
  }
2328
+ function resolveBareSpecifierType(name, importDecl, project) {
2329
+ let target;
2330
+ try {
2331
+ target = importDecl.getModuleSpecifierSourceFile();
2332
+ } catch {
2333
+ return null;
2334
+ }
2335
+ if (!target) return null;
2336
+ const direct = findTypeInFile(name, target);
2337
+ if (direct) return direct;
2338
+ return resolveReExportedType(name, target, project, /* @__PURE__ */ new Set());
2339
+ }
2325
2340
  function resolveReExportedType(name, file, project, seen) {
2326
2341
  const filePath = file.getFilePath();
2327
2342
  if (seen.has(filePath)) return null;
@@ -4374,6 +4389,7 @@ async function watch(config, onChange) {
4374
4389
  return NO_OP_WATCHER;
4375
4390
  }
4376
4391
  let discovery = null;
4392
+ let lastRoutes = [];
4377
4393
  async function getDiscovery() {
4378
4394
  if (discovery === null) {
4379
4395
  discovery = await PersistentDiscovery.create({
@@ -4387,13 +4403,14 @@ async function watch(config, onChange) {
4387
4403
  }
4388
4404
  try {
4389
4405
  const initialRoutes = (await getDiscovery()).discover();
4406
+ lastRoutes = initialRoutes;
4390
4407
  await generate(config, initialRoutes);
4391
4408
  } catch (err) {
4392
4409
  console.warn(
4393
4410
  `[nestjs-codegen] Initial route discovery failed, falling back to pages-only: ${err instanceof Error ? err.message : String(err)}`
4394
4411
  );
4395
4412
  try {
4396
- await generate(config);
4413
+ await generate(config, lastRoutes);
4397
4414
  } catch {
4398
4415
  }
4399
4416
  }
@@ -4411,7 +4428,7 @@ async function watch(config, onChange) {
4411
4428
  pagesDebounceTimer = setTimeout(async () => {
4412
4429
  pagesDebounceTimer = void 0;
4413
4430
  try {
4414
- await generate(config);
4431
+ await generate(config, lastRoutes);
4415
4432
  } catch (err) {
4416
4433
  console.error(
4417
4434
  "[nestjs-codegen] Pages generation failed:",
@@ -4442,6 +4459,7 @@ async function watch(config, onChange) {
4442
4459
  pendingChangedPaths.clear();
4443
4460
  try {
4444
4461
  const routes = await (await getDiscovery()).rediscover(changed);
4462
+ lastRoutes = routes;
4445
4463
  await generate(config, routes);
4446
4464
  } catch (err) {
4447
4465
  console.error(
@@ -4565,7 +4583,7 @@ function createChainModuleRenderer(opts) {
4565
4583
  }
4566
4584
 
4567
4585
  // src/index.ts
4568
- var VERSION = "0.5.2";
4586
+ var VERSION = "0.6.1";
4569
4587
  // Annotate the CommonJS export names for ESM import in node:
4570
4588
  0 && (module.exports = {
4571
4589
  CodegenError,