@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/CHANGELOG.md +19 -0
- package/dist/cli/main.cjs +22 -4
- package/dist/cli/main.cjs.map +1 -1
- package/dist/cli/main.js +22 -4
- package/dist/cli/main.js.map +1 -1
- package/dist/index.cjs +22 -4
- 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 -4
- package/dist/index.js.map +1 -1
- package/dist/nest/index.cjs +21 -3
- package/dist/nest/index.cjs.map +1 -1
- package/dist/nest/index.js +21 -3
- package/dist/nest/index.js.map +1 -1
- package/package.json +1 -1
package/dist/nest/index.cjs
CHANGED
|
@@ -283,7 +283,6 @@ function resolveImportedType(name, sourceFile, project) {
|
|
|
283
283
|
if (!namedImport) continue;
|
|
284
284
|
const moduleSpecifier = importDecl.getModuleSpecifierValue();
|
|
285
285
|
const candidates = resolveModuleSpecifier(moduleSpecifier, sourceFile, project);
|
|
286
|
-
if (candidates.length === 0) continue;
|
|
287
286
|
for (const candidate of candidates) {
|
|
288
287
|
let importedFile = project.getSourceFile(candidate);
|
|
289
288
|
if (!importedFile) {
|
|
@@ -298,9 +297,25 @@ function resolveImportedType(name, sourceFile, project) {
|
|
|
298
297
|
const viaReExport = resolveReExportedType(name, importedFile, project, /* @__PURE__ */ new Set());
|
|
299
298
|
if (viaReExport) return viaReExport;
|
|
300
299
|
}
|
|
300
|
+
if (candidates.length === 0) {
|
|
301
|
+
const viaCompiler = resolveBareSpecifierType(name, importDecl, project);
|
|
302
|
+
if (viaCompiler) return viaCompiler;
|
|
303
|
+
}
|
|
301
304
|
}
|
|
302
305
|
return resolveReExportedType(name, sourceFile, project, /* @__PURE__ */ new Set());
|
|
303
306
|
}
|
|
307
|
+
function resolveBareSpecifierType(name, importDecl, project) {
|
|
308
|
+
let target;
|
|
309
|
+
try {
|
|
310
|
+
target = importDecl.getModuleSpecifierSourceFile();
|
|
311
|
+
} catch {
|
|
312
|
+
return null;
|
|
313
|
+
}
|
|
314
|
+
if (!target) return null;
|
|
315
|
+
const direct = findTypeInFile(name, target);
|
|
316
|
+
if (direct) return direct;
|
|
317
|
+
return resolveReExportedType(name, target, project, /* @__PURE__ */ new Set());
|
|
318
|
+
}
|
|
304
319
|
function resolveReExportedType(name, file, project, seen) {
|
|
305
320
|
const filePath = file.getFilePath();
|
|
306
321
|
if (seen.has(filePath)) return null;
|
|
@@ -4284,6 +4299,7 @@ async function watch(config, onChange) {
|
|
|
4284
4299
|
return NO_OP_WATCHER;
|
|
4285
4300
|
}
|
|
4286
4301
|
let discovery = null;
|
|
4302
|
+
let lastRoutes = [];
|
|
4287
4303
|
async function getDiscovery() {
|
|
4288
4304
|
if (discovery === null) {
|
|
4289
4305
|
discovery = await PersistentDiscovery.create({
|
|
@@ -4297,13 +4313,14 @@ async function watch(config, onChange) {
|
|
|
4297
4313
|
}
|
|
4298
4314
|
try {
|
|
4299
4315
|
const initialRoutes = (await getDiscovery()).discover();
|
|
4316
|
+
lastRoutes = initialRoutes;
|
|
4300
4317
|
await generate(config, initialRoutes);
|
|
4301
4318
|
} catch (err) {
|
|
4302
4319
|
console.warn(
|
|
4303
4320
|
`[nestjs-codegen] Initial route discovery failed, falling back to pages-only: ${err instanceof Error ? err.message : String(err)}`
|
|
4304
4321
|
);
|
|
4305
4322
|
try {
|
|
4306
|
-
await generate(config);
|
|
4323
|
+
await generate(config, lastRoutes);
|
|
4307
4324
|
} catch {
|
|
4308
4325
|
}
|
|
4309
4326
|
}
|
|
@@ -4321,7 +4338,7 @@ async function watch(config, onChange) {
|
|
|
4321
4338
|
pagesDebounceTimer = setTimeout(async () => {
|
|
4322
4339
|
pagesDebounceTimer = void 0;
|
|
4323
4340
|
try {
|
|
4324
|
-
await generate(config);
|
|
4341
|
+
await generate(config, lastRoutes);
|
|
4325
4342
|
} catch (err) {
|
|
4326
4343
|
console.error(
|
|
4327
4344
|
"[nestjs-codegen] Pages generation failed:",
|
|
@@ -4352,6 +4369,7 @@ async function watch(config, onChange) {
|
|
|
4352
4369
|
pendingChangedPaths.clear();
|
|
4353
4370
|
try {
|
|
4354
4371
|
const routes = await (await getDiscovery()).rediscover(changed);
|
|
4372
|
+
lastRoutes = routes;
|
|
4355
4373
|
await generate(config, routes);
|
|
4356
4374
|
} catch (err) {
|
|
4357
4375
|
console.error(
|