@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.js
CHANGED
|
@@ -257,7 +257,6 @@ function resolveImportedType(name, sourceFile, project) {
|
|
|
257
257
|
if (!namedImport) continue;
|
|
258
258
|
const moduleSpecifier = importDecl.getModuleSpecifierValue();
|
|
259
259
|
const candidates = resolveModuleSpecifier(moduleSpecifier, sourceFile, project);
|
|
260
|
-
if (candidates.length === 0) continue;
|
|
261
260
|
for (const candidate of candidates) {
|
|
262
261
|
let importedFile = project.getSourceFile(candidate);
|
|
263
262
|
if (!importedFile) {
|
|
@@ -272,9 +271,25 @@ function resolveImportedType(name, sourceFile, project) {
|
|
|
272
271
|
const viaReExport = resolveReExportedType(name, importedFile, project, /* @__PURE__ */ new Set());
|
|
273
272
|
if (viaReExport) return viaReExport;
|
|
274
273
|
}
|
|
274
|
+
if (candidates.length === 0) {
|
|
275
|
+
const viaCompiler = resolveBareSpecifierType(name, importDecl, project);
|
|
276
|
+
if (viaCompiler) return viaCompiler;
|
|
277
|
+
}
|
|
275
278
|
}
|
|
276
279
|
return resolveReExportedType(name, sourceFile, project, /* @__PURE__ */ new Set());
|
|
277
280
|
}
|
|
281
|
+
function resolveBareSpecifierType(name, importDecl, project) {
|
|
282
|
+
let target;
|
|
283
|
+
try {
|
|
284
|
+
target = importDecl.getModuleSpecifierSourceFile();
|
|
285
|
+
} catch {
|
|
286
|
+
return null;
|
|
287
|
+
}
|
|
288
|
+
if (!target) return null;
|
|
289
|
+
const direct = findTypeInFile(name, target);
|
|
290
|
+
if (direct) return direct;
|
|
291
|
+
return resolveReExportedType(name, target, project, /* @__PURE__ */ new Set());
|
|
292
|
+
}
|
|
278
293
|
function resolveReExportedType(name, file, project, seen) {
|
|
279
294
|
const filePath = file.getFilePath();
|
|
280
295
|
if (seen.has(filePath)) return null;
|
|
@@ -4263,6 +4278,7 @@ async function watch(config, onChange) {
|
|
|
4263
4278
|
return NO_OP_WATCHER;
|
|
4264
4279
|
}
|
|
4265
4280
|
let discovery = null;
|
|
4281
|
+
let lastRoutes = [];
|
|
4266
4282
|
async function getDiscovery() {
|
|
4267
4283
|
if (discovery === null) {
|
|
4268
4284
|
discovery = await PersistentDiscovery.create({
|
|
@@ -4276,13 +4292,14 @@ async function watch(config, onChange) {
|
|
|
4276
4292
|
}
|
|
4277
4293
|
try {
|
|
4278
4294
|
const initialRoutes = (await getDiscovery()).discover();
|
|
4295
|
+
lastRoutes = initialRoutes;
|
|
4279
4296
|
await generate(config, initialRoutes);
|
|
4280
4297
|
} catch (err) {
|
|
4281
4298
|
console.warn(
|
|
4282
4299
|
`[nestjs-codegen] Initial route discovery failed, falling back to pages-only: ${err instanceof Error ? err.message : String(err)}`
|
|
4283
4300
|
);
|
|
4284
4301
|
try {
|
|
4285
|
-
await generate(config);
|
|
4302
|
+
await generate(config, lastRoutes);
|
|
4286
4303
|
} catch {
|
|
4287
4304
|
}
|
|
4288
4305
|
}
|
|
@@ -4300,7 +4317,7 @@ async function watch(config, onChange) {
|
|
|
4300
4317
|
pagesDebounceTimer = setTimeout(async () => {
|
|
4301
4318
|
pagesDebounceTimer = void 0;
|
|
4302
4319
|
try {
|
|
4303
|
-
await generate(config);
|
|
4320
|
+
await generate(config, lastRoutes);
|
|
4304
4321
|
} catch (err) {
|
|
4305
4322
|
console.error(
|
|
4306
4323
|
"[nestjs-codegen] Pages generation failed:",
|
|
@@ -4331,6 +4348,7 @@ async function watch(config, onChange) {
|
|
|
4331
4348
|
pendingChangedPaths.clear();
|
|
4332
4349
|
try {
|
|
4333
4350
|
const routes = await (await getDiscovery()).rediscover(changed);
|
|
4351
|
+
lastRoutes = routes;
|
|
4334
4352
|
await generate(config, routes);
|
|
4335
4353
|
} catch (err) {
|
|
4336
4354
|
console.error(
|