@emeryld/rrroutes-export 1.0.10 → 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
@@ -2084,6 +2084,7 @@ async function compileSnapshotEntry(options) {
2084
2084
  declarationMap: false,
2085
2085
  sourceMap: false,
2086
2086
  inlineSourceMap: false,
2087
+ inlineSources: false,
2087
2088
  composite: false,
2088
2089
  incremental: false,
2089
2090
  tsBuildInfoFile: void 0,
@@ -2120,72 +2121,87 @@ async function createSnapshot(repoRoot, moduleCandidates, exportName, commit, te
2120
2121
  const worktreeDir = import_node_path4.default.join(tempRoot, `wt-${commit.sha.slice(0, 12)}`);
2121
2122
  await runGit(repoRoot, ["worktree", "add", "--detach", worktreeDir, commit.sha]);
2122
2123
  try {
2123
- await ensureWorktreeDependencies(repoRoot, worktreeDir);
2124
- const resolvedModuleRel = await resolveModulePathForCommit(
2125
- repoRoot,
2126
- commit.sha,
2127
- moduleCandidates
2128
- );
2129
- 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);
2130
2194
  log?.(
2131
- `[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}`
2132
2196
  );
2133
2197
  return {
2134
2198
  commit,
2135
2199
  routesByKey: {},
2136
2200
  sourceObjectsById: {},
2137
- unresolvedModule: true
2201
+ fallbackReason: "snapshot_error",
2202
+ fallbackError: message
2138
2203
  };
2139
2204
  }
2140
- log?.(
2141
- `[changelog] resolved module for commit ${commit.sha.slice(0, 12)}: ${resolvedModuleRel}`
2142
- );
2143
- const modulePath = import_node_path4.default.resolve(worktreeDir, resolvedModuleRel);
2144
- let snapshotRuntimePath = modulePath;
2145
- let resolvedTsconfigPath;
2146
- if (isTypeScriptModule(modulePath)) {
2147
- resolvedTsconfigPath = await resolveSnapshotTsconfig(
2148
- worktreeDir,
2149
- modulePath,
2150
- tsconfigRel
2151
- );
2152
- log?.(`[changelog] using tsconfig: ${resolvedTsconfigPath}`);
2153
- const compileCacheRoot = import_node_path4.default.resolve(
2154
- exportOptions?.cacheDir ?? import_node_path4.default.join(import_node_os.default.tmpdir(), "rrroutes-export-changelog-cache")
2155
- );
2156
- snapshotRuntimePath = await compileSnapshotEntry({
2157
- worktreeDir,
2158
- moduleRel: resolvedModuleRel,
2159
- modulePath,
2160
- tsconfigPath: resolvedTsconfigPath,
2161
- commitSha: commit.sha,
2162
- cacheRoot: compileCacheRoot,
2163
- noCache: exportOptions?.noCache,
2164
- log
2165
- });
2166
- } else if (!isJavaScriptModule(modulePath)) {
2167
- throw new Error(
2168
- `Unsupported module extension for changelog snapshots: ${modulePath}`
2169
- );
2170
- }
2171
- const input = await loadSnapshotExport({
2172
- entryPath: snapshotRuntimePath,
2173
- exportName
2174
- });
2175
- const payload = await exportFinalizedLeaves(input, {
2176
- includeSource: true,
2177
- sourceModulePath: modulePath,
2178
- sourceExportName: exportName,
2179
- tsconfigPath: resolvedTsconfigPath ?? (tsconfigRel ? import_node_path4.default.resolve(worktreeDir, tsconfigRel) : void 0),
2180
- handlers: exportOptions?.handlers
2181
- });
2182
- const routesByKey = toRouteSnapshots(payload);
2183
- const sourceObjectsById = toSourceObjectSnapshots(routesByKey);
2184
- return {
2185
- commit,
2186
- routesByKey,
2187
- sourceObjectsById
2188
- };
2189
2205
  } finally {
2190
2206
  await runGit(repoRoot, ["worktree", "remove", "--force", worktreeDir]).catch(() => void 0);
2191
2207
  await import_promises2.default.rm(worktreeDir, { recursive: true, force: true }).catch(() => void 0);
@@ -2441,6 +2457,7 @@ async function exportFinalizedLeavesChangelog(options) {
2441
2457
  try {
2442
2458
  const snapshots = [];
2443
2459
  const unresolvedModuleCommits = [];
2460
+ const snapshotFallbacks = [];
2444
2461
  for (let index = 0; index < commits.length; index += 1) {
2445
2462
  const commit = commits[index];
2446
2463
  log(
@@ -2458,9 +2475,17 @@ async function exportFinalizedLeavesChangelog(options) {
2458
2475
  log
2459
2476
  )
2460
2477
  );
2461
- if (snapshots[snapshots.length - 1]?.unresolvedModule) {
2478
+ const lastSnapshot = snapshots[snapshots.length - 1];
2479
+ if (lastSnapshot?.unresolvedModule) {
2462
2480
  unresolvedModuleCommits.push(commit.sha);
2463
2481
  }
2482
+ if (lastSnapshot?.fallbackReason) {
2483
+ snapshotFallbacks.push({
2484
+ sha: commit.sha,
2485
+ reason: lastSnapshot.fallbackReason,
2486
+ error: lastSnapshot.fallbackError
2487
+ });
2488
+ }
2464
2489
  }
2465
2490
  const routeEvents = [];
2466
2491
  const sourceEvents = [];
@@ -2486,7 +2511,8 @@ async function exportFinalizedLeavesChangelog(options) {
2486
2511
  from: window.from,
2487
2512
  to: window.to,
2488
2513
  selectedCommitCount: commits.length,
2489
- unresolvedModuleCommits: unresolvedModuleCommits.length > 0 ? unresolvedModuleCommits : void 0
2514
+ unresolvedModuleCommits: unresolvedModuleCommits.length > 0 ? unresolvedModuleCommits : void 0,
2515
+ snapshotFallbacks: snapshotFallbacks.length > 0 ? snapshotFallbacks : void 0
2490
2516
  },
2491
2517
  commits,
2492
2518
  byRoute: routeRecordByKey(routeEvents),