@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/cli/main.js
CHANGED
|
@@ -2246,7 +2246,6 @@ function resolveImportedType(name, sourceFile, project) {
|
|
|
2246
2246
|
if (!namedImport) continue;
|
|
2247
2247
|
const moduleSpecifier = importDecl.getModuleSpecifierValue();
|
|
2248
2248
|
const candidates = resolveModuleSpecifier(moduleSpecifier, sourceFile, project);
|
|
2249
|
-
if (candidates.length === 0) continue;
|
|
2250
2249
|
for (const candidate of candidates) {
|
|
2251
2250
|
let importedFile = project.getSourceFile(candidate);
|
|
2252
2251
|
if (!importedFile) {
|
|
@@ -2261,9 +2260,25 @@ function resolveImportedType(name, sourceFile, project) {
|
|
|
2261
2260
|
const viaReExport = resolveReExportedType(name, importedFile, project, /* @__PURE__ */ new Set());
|
|
2262
2261
|
if (viaReExport) return viaReExport;
|
|
2263
2262
|
}
|
|
2263
|
+
if (candidates.length === 0) {
|
|
2264
|
+
const viaCompiler = resolveBareSpecifierType(name, importDecl, project);
|
|
2265
|
+
if (viaCompiler) return viaCompiler;
|
|
2266
|
+
}
|
|
2264
2267
|
}
|
|
2265
2268
|
return resolveReExportedType(name, sourceFile, project, /* @__PURE__ */ new Set());
|
|
2266
2269
|
}
|
|
2270
|
+
function resolveBareSpecifierType(name, importDecl, project) {
|
|
2271
|
+
let target;
|
|
2272
|
+
try {
|
|
2273
|
+
target = importDecl.getModuleSpecifierSourceFile();
|
|
2274
|
+
} catch {
|
|
2275
|
+
return null;
|
|
2276
|
+
}
|
|
2277
|
+
if (!target) return null;
|
|
2278
|
+
const direct = findTypeInFile(name, target);
|
|
2279
|
+
if (direct) return direct;
|
|
2280
|
+
return resolveReExportedType(name, target, project, /* @__PURE__ */ new Set());
|
|
2281
|
+
}
|
|
2267
2282
|
function resolveReExportedType(name, file, project, seen) {
|
|
2268
2283
|
const filePath = file.getFilePath();
|
|
2269
2284
|
if (seen.has(filePath)) return null;
|
|
@@ -4321,6 +4336,7 @@ async function watch(config, onChange) {
|
|
|
4321
4336
|
return NO_OP_WATCHER;
|
|
4322
4337
|
}
|
|
4323
4338
|
let discovery = null;
|
|
4339
|
+
let lastRoutes = [];
|
|
4324
4340
|
async function getDiscovery() {
|
|
4325
4341
|
if (discovery === null) {
|
|
4326
4342
|
discovery = await PersistentDiscovery.create({
|
|
@@ -4334,13 +4350,14 @@ async function watch(config, onChange) {
|
|
|
4334
4350
|
}
|
|
4335
4351
|
try {
|
|
4336
4352
|
const initialRoutes = (await getDiscovery()).discover();
|
|
4353
|
+
lastRoutes = initialRoutes;
|
|
4337
4354
|
await generate(config, initialRoutes);
|
|
4338
4355
|
} catch (err) {
|
|
4339
4356
|
console.warn(
|
|
4340
4357
|
`[nestjs-codegen] Initial route discovery failed, falling back to pages-only: ${err instanceof Error ? err.message : String(err)}`
|
|
4341
4358
|
);
|
|
4342
4359
|
try {
|
|
4343
|
-
await generate(config);
|
|
4360
|
+
await generate(config, lastRoutes);
|
|
4344
4361
|
} catch {
|
|
4345
4362
|
}
|
|
4346
4363
|
}
|
|
@@ -4358,7 +4375,7 @@ async function watch(config, onChange) {
|
|
|
4358
4375
|
pagesDebounceTimer = setTimeout(async () => {
|
|
4359
4376
|
pagesDebounceTimer = void 0;
|
|
4360
4377
|
try {
|
|
4361
|
-
await generate(config);
|
|
4378
|
+
await generate(config, lastRoutes);
|
|
4362
4379
|
} catch (err) {
|
|
4363
4380
|
console.error(
|
|
4364
4381
|
"[nestjs-codegen] Pages generation failed:",
|
|
@@ -4389,6 +4406,7 @@ async function watch(config, onChange) {
|
|
|
4389
4406
|
pendingChangedPaths.clear();
|
|
4390
4407
|
try {
|
|
4391
4408
|
const routes = await (await getDiscovery()).rediscover(changed);
|
|
4409
|
+
lastRoutes = routes;
|
|
4392
4410
|
await generate(config, routes);
|
|
4393
4411
|
} catch (err) {
|
|
4394
4412
|
console.error(
|
|
@@ -4429,7 +4447,7 @@ async function watch(config, onChange) {
|
|
|
4429
4447
|
}
|
|
4430
4448
|
|
|
4431
4449
|
// src/index.ts
|
|
4432
|
-
var VERSION = "0.
|
|
4450
|
+
var VERSION = "0.6.1";
|
|
4433
4451
|
|
|
4434
4452
|
// src/cli/codegen.ts
|
|
4435
4453
|
async function runCodegen(opts = {}) {
|