@emeryld/rrroutes-export 1.0.11 → 1.0.12

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/README.md CHANGED
@@ -79,15 +79,18 @@ Behavior summary:
79
79
  - For TypeScript module entries, compiles the commit snapshot to JS and imports emitted output.
80
80
  - For JavaScript module entries, imports directly from worktree.
81
81
  - If module entrypoint cannot be resolved for a commit, changelog uses an empty snapshot for that commit (timeline continuity).
82
+ - If a commit snapshot fails to compile/load, changelog also uses an empty snapshot for that commit and continues.
82
83
  - Exports snapshots, then computes adjacent diffs:
83
84
  - route events (`route_added`, `route_removed`, `schema_changed`, `cfg_changed`)
84
85
  - source-object events (`source_object_added`, `source_object_removed`, `source_schema_changed`)
86
+ - metadata includes fallback details in `_meta.unresolvedModuleCommits` and `_meta.snapshotFallbacks`
85
87
 
86
88
  Runtime progress logs:
87
89
 
88
90
  - `rrroutes-export-changelog` now prints step-by-step progress (window resolution, commit filtering, per-commit snapshot progress, diff totals, output writing, cleanup).
89
91
  - Changelog logs include compile lifecycle details: selected tsconfig, cache hit/miss, emitted entry path.
90
92
  - Changelog logs include per-commit module resolution and unresolved-entry fallback messages.
93
+ - Changelog logs include snapshot compile/load fallback messages when a commit cannot be materialized.
91
94
  - Bundle script prints stage logs for snapshot export + changelog export.
92
95
 
93
96
  Troubleshooting historical TS imports:
@@ -33,6 +33,8 @@ type CommitSnapshot = {
33
33
  routesByKey: Record<string, RouteSnapshot>;
34
34
  sourceObjectsById: Record<string, SourceObjectSnapshot>;
35
35
  unresolvedModule?: boolean;
36
+ fallbackReason?: 'module_unresolved' | 'snapshot_error';
37
+ fallbackError?: string;
36
38
  };
37
39
  type DiffOp = 'added' | 'removed' | 'changed';
38
40
  export type SchemaPathDelta = {
@@ -98,6 +100,11 @@ export type FinalizedLeavesChangelogExport = {
98
100
  to: string;
99
101
  selectedCommitCount: number;
100
102
  unresolvedModuleCommits?: string[];
103
+ snapshotFallbacks?: Array<{
104
+ sha: string;
105
+ reason: 'module_unresolved' | 'snapshot_error';
106
+ error?: string;
107
+ }>;
101
108
  };
102
109
  commits: ChangelogCommit[];
103
110
  byRoute: Record<string, RouteChangeEvent[]>;
package/dist/index.cjs CHANGED
@@ -2121,72 +2121,87 @@ async function createSnapshot(repoRoot, moduleCandidates, exportName, commit, te
2121
2121
  const worktreeDir = import_node_path4.default.join(tempRoot, `wt-${commit.sha.slice(0, 12)}`);
2122
2122
  await runGit(repoRoot, ["worktree", "add", "--detach", worktreeDir, commit.sha]);
2123
2123
  try {
2124
- await ensureWorktreeDependencies(repoRoot, worktreeDir);
2125
- const resolvedModuleRel = await resolveModulePathForCommit(
2126
- repoRoot,
2127
- commit.sha,
2128
- moduleCandidates
2129
- );
2130
- if (!resolvedModuleRel) {
2124
+ try {
2125
+ await ensureWorktreeDependencies(repoRoot, worktreeDir);
2126
+ const resolvedModuleRel = await resolveModulePathForCommit(
2127
+ repoRoot,
2128
+ commit.sha,
2129
+ moduleCandidates
2130
+ );
2131
+ if (!resolvedModuleRel) {
2132
+ log?.(
2133
+ `[changelog] unresolved module for commit ${commit.sha.slice(0, 12)}; using empty snapshot`
2134
+ );
2135
+ return {
2136
+ commit,
2137
+ routesByKey: {},
2138
+ sourceObjectsById: {},
2139
+ unresolvedModule: true,
2140
+ fallbackReason: "module_unresolved"
2141
+ };
2142
+ }
2143
+ log?.(
2144
+ `[changelog] resolved module for commit ${commit.sha.slice(0, 12)}: ${resolvedModuleRel}`
2145
+ );
2146
+ const modulePath = import_node_path4.default.resolve(worktreeDir, resolvedModuleRel);
2147
+ let snapshotRuntimePath = modulePath;
2148
+ let resolvedTsconfigPath;
2149
+ if (isTypeScriptModule(modulePath)) {
2150
+ resolvedTsconfigPath = await resolveSnapshotTsconfig(
2151
+ worktreeDir,
2152
+ modulePath,
2153
+ tsconfigRel
2154
+ );
2155
+ log?.(`[changelog] using tsconfig: ${resolvedTsconfigPath}`);
2156
+ const compileCacheRoot = import_node_path4.default.resolve(
2157
+ exportOptions?.cacheDir ?? import_node_path4.default.join(import_node_os.default.tmpdir(), "rrroutes-export-changelog-cache")
2158
+ );
2159
+ snapshotRuntimePath = await compileSnapshotEntry({
2160
+ worktreeDir,
2161
+ moduleRel: resolvedModuleRel,
2162
+ modulePath,
2163
+ tsconfigPath: resolvedTsconfigPath,
2164
+ commitSha: commit.sha,
2165
+ cacheRoot: compileCacheRoot,
2166
+ noCache: exportOptions?.noCache,
2167
+ log
2168
+ });
2169
+ } else if (!isJavaScriptModule(modulePath)) {
2170
+ throw new Error(
2171
+ `Unsupported module extension for changelog snapshots: ${modulePath}`
2172
+ );
2173
+ }
2174
+ const input = await loadSnapshotExport({
2175
+ entryPath: snapshotRuntimePath,
2176
+ exportName
2177
+ });
2178
+ const payload = await exportFinalizedLeaves(input, {
2179
+ includeSource: true,
2180
+ sourceModulePath: modulePath,
2181
+ sourceExportName: exportName,
2182
+ tsconfigPath: resolvedTsconfigPath ?? (tsconfigRel ? import_node_path4.default.resolve(worktreeDir, tsconfigRel) : void 0),
2183
+ handlers: exportOptions?.handlers
2184
+ });
2185
+ const routesByKey = toRouteSnapshots(payload);
2186
+ const sourceObjectsById = toSourceObjectSnapshots(routesByKey);
2187
+ return {
2188
+ commit,
2189
+ routesByKey,
2190
+ sourceObjectsById
2191
+ };
2192
+ } catch (error) {
2193
+ const message = error instanceof Error ? error.message : String(error);
2131
2194
  log?.(
2132
- `[changelog] unresolved module for commit ${commit.sha.slice(0, 12)}; using empty snapshot`
2195
+ `[changelog] snapshot failed for ${commit.sha.slice(0, 12)}; using empty snapshot. ${message}`
2133
2196
  );
2134
2197
  return {
2135
2198
  commit,
2136
2199
  routesByKey: {},
2137
2200
  sourceObjectsById: {},
2138
- unresolvedModule: true
2201
+ fallbackReason: "snapshot_error",
2202
+ fallbackError: message
2139
2203
  };
2140
2204
  }
2141
- log?.(
2142
- `[changelog] resolved module for commit ${commit.sha.slice(0, 12)}: ${resolvedModuleRel}`
2143
- );
2144
- const modulePath = import_node_path4.default.resolve(worktreeDir, resolvedModuleRel);
2145
- let snapshotRuntimePath = modulePath;
2146
- let resolvedTsconfigPath;
2147
- if (isTypeScriptModule(modulePath)) {
2148
- resolvedTsconfigPath = await resolveSnapshotTsconfig(
2149
- worktreeDir,
2150
- modulePath,
2151
- tsconfigRel
2152
- );
2153
- log?.(`[changelog] using tsconfig: ${resolvedTsconfigPath}`);
2154
- const compileCacheRoot = import_node_path4.default.resolve(
2155
- exportOptions?.cacheDir ?? import_node_path4.default.join(import_node_os.default.tmpdir(), "rrroutes-export-changelog-cache")
2156
- );
2157
- snapshotRuntimePath = await compileSnapshotEntry({
2158
- worktreeDir,
2159
- moduleRel: resolvedModuleRel,
2160
- modulePath,
2161
- tsconfigPath: resolvedTsconfigPath,
2162
- commitSha: commit.sha,
2163
- cacheRoot: compileCacheRoot,
2164
- noCache: exportOptions?.noCache,
2165
- log
2166
- });
2167
- } else if (!isJavaScriptModule(modulePath)) {
2168
- throw new Error(
2169
- `Unsupported module extension for changelog snapshots: ${modulePath}`
2170
- );
2171
- }
2172
- const input = await loadSnapshotExport({
2173
- entryPath: snapshotRuntimePath,
2174
- exportName
2175
- });
2176
- const payload = await exportFinalizedLeaves(input, {
2177
- includeSource: true,
2178
- sourceModulePath: modulePath,
2179
- sourceExportName: exportName,
2180
- tsconfigPath: resolvedTsconfigPath ?? (tsconfigRel ? import_node_path4.default.resolve(worktreeDir, tsconfigRel) : void 0),
2181
- handlers: exportOptions?.handlers
2182
- });
2183
- const routesByKey = toRouteSnapshots(payload);
2184
- const sourceObjectsById = toSourceObjectSnapshots(routesByKey);
2185
- return {
2186
- commit,
2187
- routesByKey,
2188
- sourceObjectsById
2189
- };
2190
2205
  } finally {
2191
2206
  await runGit(repoRoot, ["worktree", "remove", "--force", worktreeDir]).catch(() => void 0);
2192
2207
  await import_promises2.default.rm(worktreeDir, { recursive: true, force: true }).catch(() => void 0);
@@ -2442,6 +2457,7 @@ async function exportFinalizedLeavesChangelog(options) {
2442
2457
  try {
2443
2458
  const snapshots = [];
2444
2459
  const unresolvedModuleCommits = [];
2460
+ const snapshotFallbacks = [];
2445
2461
  for (let index = 0; index < commits.length; index += 1) {
2446
2462
  const commit = commits[index];
2447
2463
  log(
@@ -2459,9 +2475,17 @@ async function exportFinalizedLeavesChangelog(options) {
2459
2475
  log
2460
2476
  )
2461
2477
  );
2462
- if (snapshots[snapshots.length - 1]?.unresolvedModule) {
2478
+ const lastSnapshot = snapshots[snapshots.length - 1];
2479
+ if (lastSnapshot?.unresolvedModule) {
2463
2480
  unresolvedModuleCommits.push(commit.sha);
2464
2481
  }
2482
+ if (lastSnapshot?.fallbackReason) {
2483
+ snapshotFallbacks.push({
2484
+ sha: commit.sha,
2485
+ reason: lastSnapshot.fallbackReason,
2486
+ error: lastSnapshot.fallbackError
2487
+ });
2488
+ }
2465
2489
  }
2466
2490
  const routeEvents = [];
2467
2491
  const sourceEvents = [];
@@ -2487,7 +2511,8 @@ async function exportFinalizedLeavesChangelog(options) {
2487
2511
  from: window.from,
2488
2512
  to: window.to,
2489
2513
  selectedCommitCount: commits.length,
2490
- unresolvedModuleCommits: unresolvedModuleCommits.length > 0 ? unresolvedModuleCommits : void 0
2514
+ unresolvedModuleCommits: unresolvedModuleCommits.length > 0 ? unresolvedModuleCommits : void 0,
2515
+ snapshotFallbacks: snapshotFallbacks.length > 0 ? snapshotFallbacks : void 0
2491
2516
  },
2492
2517
  commits,
2493
2518
  byRoute: routeRecordByKey(routeEvents),