@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/dist/index.mjs CHANGED
@@ -2030,6 +2030,7 @@ async function compileSnapshotEntry(options) {
2030
2030
  declarationMap: false,
2031
2031
  sourceMap: false,
2032
2032
  inlineSourceMap: false,
2033
+ inlineSources: false,
2033
2034
  composite: false,
2034
2035
  incremental: false,
2035
2036
  tsBuildInfoFile: void 0,
@@ -2066,72 +2067,87 @@ async function createSnapshot(repoRoot, moduleCandidates, exportName, commit, te
2066
2067
  const worktreeDir = path4.join(tempRoot, `wt-${commit.sha.slice(0, 12)}`);
2067
2068
  await runGit(repoRoot, ["worktree", "add", "--detach", worktreeDir, commit.sha]);
2068
2069
  try {
2069
- await ensureWorktreeDependencies(repoRoot, worktreeDir);
2070
- const resolvedModuleRel = await resolveModulePathForCommit(
2071
- repoRoot,
2072
- commit.sha,
2073
- moduleCandidates
2074
- );
2075
- if (!resolvedModuleRel) {
2070
+ try {
2071
+ await ensureWorktreeDependencies(repoRoot, worktreeDir);
2072
+ const resolvedModuleRel = await resolveModulePathForCommit(
2073
+ repoRoot,
2074
+ commit.sha,
2075
+ moduleCandidates
2076
+ );
2077
+ if (!resolvedModuleRel) {
2078
+ log?.(
2079
+ `[changelog] unresolved module for commit ${commit.sha.slice(0, 12)}; using empty snapshot`
2080
+ );
2081
+ return {
2082
+ commit,
2083
+ routesByKey: {},
2084
+ sourceObjectsById: {},
2085
+ unresolvedModule: true,
2086
+ fallbackReason: "module_unresolved"
2087
+ };
2088
+ }
2089
+ log?.(
2090
+ `[changelog] resolved module for commit ${commit.sha.slice(0, 12)}: ${resolvedModuleRel}`
2091
+ );
2092
+ const modulePath = path4.resolve(worktreeDir, resolvedModuleRel);
2093
+ let snapshotRuntimePath = modulePath;
2094
+ let resolvedTsconfigPath;
2095
+ if (isTypeScriptModule(modulePath)) {
2096
+ resolvedTsconfigPath = await resolveSnapshotTsconfig(
2097
+ worktreeDir,
2098
+ modulePath,
2099
+ tsconfigRel
2100
+ );
2101
+ log?.(`[changelog] using tsconfig: ${resolvedTsconfigPath}`);
2102
+ const compileCacheRoot = path4.resolve(
2103
+ exportOptions?.cacheDir ?? path4.join(os.tmpdir(), "rrroutes-export-changelog-cache")
2104
+ );
2105
+ snapshotRuntimePath = await compileSnapshotEntry({
2106
+ worktreeDir,
2107
+ moduleRel: resolvedModuleRel,
2108
+ modulePath,
2109
+ tsconfigPath: resolvedTsconfigPath,
2110
+ commitSha: commit.sha,
2111
+ cacheRoot: compileCacheRoot,
2112
+ noCache: exportOptions?.noCache,
2113
+ log
2114
+ });
2115
+ } else if (!isJavaScriptModule(modulePath)) {
2116
+ throw new Error(
2117
+ `Unsupported module extension for changelog snapshots: ${modulePath}`
2118
+ );
2119
+ }
2120
+ const input = await loadSnapshotExport({
2121
+ entryPath: snapshotRuntimePath,
2122
+ exportName
2123
+ });
2124
+ const payload = await exportFinalizedLeaves(input, {
2125
+ includeSource: true,
2126
+ sourceModulePath: modulePath,
2127
+ sourceExportName: exportName,
2128
+ tsconfigPath: resolvedTsconfigPath ?? (tsconfigRel ? path4.resolve(worktreeDir, tsconfigRel) : void 0),
2129
+ handlers: exportOptions?.handlers
2130
+ });
2131
+ const routesByKey = toRouteSnapshots(payload);
2132
+ const sourceObjectsById = toSourceObjectSnapshots(routesByKey);
2133
+ return {
2134
+ commit,
2135
+ routesByKey,
2136
+ sourceObjectsById
2137
+ };
2138
+ } catch (error) {
2139
+ const message = error instanceof Error ? error.message : String(error);
2076
2140
  log?.(
2077
- `[changelog] unresolved module for commit ${commit.sha.slice(0, 12)}; using empty snapshot`
2141
+ `[changelog] snapshot failed for ${commit.sha.slice(0, 12)}; using empty snapshot. ${message}`
2078
2142
  );
2079
2143
  return {
2080
2144
  commit,
2081
2145
  routesByKey: {},
2082
2146
  sourceObjectsById: {},
2083
- unresolvedModule: true
2147
+ fallbackReason: "snapshot_error",
2148
+ fallbackError: message
2084
2149
  };
2085
2150
  }
2086
- log?.(
2087
- `[changelog] resolved module for commit ${commit.sha.slice(0, 12)}: ${resolvedModuleRel}`
2088
- );
2089
- const modulePath = path4.resolve(worktreeDir, resolvedModuleRel);
2090
- let snapshotRuntimePath = modulePath;
2091
- let resolvedTsconfigPath;
2092
- if (isTypeScriptModule(modulePath)) {
2093
- resolvedTsconfigPath = await resolveSnapshotTsconfig(
2094
- worktreeDir,
2095
- modulePath,
2096
- tsconfigRel
2097
- );
2098
- log?.(`[changelog] using tsconfig: ${resolvedTsconfigPath}`);
2099
- const compileCacheRoot = path4.resolve(
2100
- exportOptions?.cacheDir ?? path4.join(os.tmpdir(), "rrroutes-export-changelog-cache")
2101
- );
2102
- snapshotRuntimePath = await compileSnapshotEntry({
2103
- worktreeDir,
2104
- moduleRel: resolvedModuleRel,
2105
- modulePath,
2106
- tsconfigPath: resolvedTsconfigPath,
2107
- commitSha: commit.sha,
2108
- cacheRoot: compileCacheRoot,
2109
- noCache: exportOptions?.noCache,
2110
- log
2111
- });
2112
- } else if (!isJavaScriptModule(modulePath)) {
2113
- throw new Error(
2114
- `Unsupported module extension for changelog snapshots: ${modulePath}`
2115
- );
2116
- }
2117
- const input = await loadSnapshotExport({
2118
- entryPath: snapshotRuntimePath,
2119
- exportName
2120
- });
2121
- const payload = await exportFinalizedLeaves(input, {
2122
- includeSource: true,
2123
- sourceModulePath: modulePath,
2124
- sourceExportName: exportName,
2125
- tsconfigPath: resolvedTsconfigPath ?? (tsconfigRel ? path4.resolve(worktreeDir, tsconfigRel) : void 0),
2126
- handlers: exportOptions?.handlers
2127
- });
2128
- const routesByKey = toRouteSnapshots(payload);
2129
- const sourceObjectsById = toSourceObjectSnapshots(routesByKey);
2130
- return {
2131
- commit,
2132
- routesByKey,
2133
- sourceObjectsById
2134
- };
2135
2151
  } finally {
2136
2152
  await runGit(repoRoot, ["worktree", "remove", "--force", worktreeDir]).catch(() => void 0);
2137
2153
  await fs2.rm(worktreeDir, { recursive: true, force: true }).catch(() => void 0);
@@ -2387,6 +2403,7 @@ async function exportFinalizedLeavesChangelog(options) {
2387
2403
  try {
2388
2404
  const snapshots = [];
2389
2405
  const unresolvedModuleCommits = [];
2406
+ const snapshotFallbacks = [];
2390
2407
  for (let index = 0; index < commits.length; index += 1) {
2391
2408
  const commit = commits[index];
2392
2409
  log(
@@ -2404,9 +2421,17 @@ async function exportFinalizedLeavesChangelog(options) {
2404
2421
  log
2405
2422
  )
2406
2423
  );
2407
- if (snapshots[snapshots.length - 1]?.unresolvedModule) {
2424
+ const lastSnapshot = snapshots[snapshots.length - 1];
2425
+ if (lastSnapshot?.unresolvedModule) {
2408
2426
  unresolvedModuleCommits.push(commit.sha);
2409
2427
  }
2428
+ if (lastSnapshot?.fallbackReason) {
2429
+ snapshotFallbacks.push({
2430
+ sha: commit.sha,
2431
+ reason: lastSnapshot.fallbackReason,
2432
+ error: lastSnapshot.fallbackError
2433
+ });
2434
+ }
2410
2435
  }
2411
2436
  const routeEvents = [];
2412
2437
  const sourceEvents = [];
@@ -2432,7 +2457,8 @@ async function exportFinalizedLeavesChangelog(options) {
2432
2457
  from: window.from,
2433
2458
  to: window.to,
2434
2459
  selectedCommitCount: commits.length,
2435
- unresolvedModuleCommits: unresolvedModuleCommits.length > 0 ? unresolvedModuleCommits : void 0
2460
+ unresolvedModuleCommits: unresolvedModuleCommits.length > 0 ? unresolvedModuleCommits : void 0,
2461
+ snapshotFallbacks: snapshotFallbacks.length > 0 ? snapshotFallbacks : void 0
2436
2462
  },
2437
2463
  commits,
2438
2464
  byRoute: routeRecordByKey(routeEvents),