Skip to content

feat(drizzle): fix file tag path resolution in deployed environments#9

Merged
veksen merged 4 commits intomasterfrom
veksen/drizzle-review
Feb 26, 2026
Merged

feat(drizzle): fix file tag path resolution in deployed environments#9
veksen merged 4 commits intomasterfrom
veksen/drizzle-review

Conversation

@veksen
Copy link
Member

@veksen veksen commented Feb 26, 2026

Summary

Implements fixes for 3 issues with the Drizzle sqlcommenter file tag producing incorrect/unusable paths in production:

  • Issue 5: When compiled JS is relocated, source map paths resolve to wrong absolute paths. Now extracts src/-relative portion and reconstructs from the true project root.
  • Issue 6: process.cwd() may not be the project root in deployments. Now walks up from cwd looking for tsconfig.json to find the real project root.
  • Issue 7: WSL absolute paths aren't resolvable from Windows tooling. Now detects WSL_DISTRO_NAME and prefixes paths with //wsl.localhost/<distro>.

All path resolution happens in a new src/path.ts utility module with three functions: findProjectRoot(), resolveFilePath(), and applyWslPrefix(). Integrated into the traceCaller() function.

Version bumped to 0.2.0.

Test plan

  • ✔ All 15 tests passing on Node 20 and Node 24
  • ✔ 13 new unit tests covering all path resolution functions
  • ✔ Existing integration test still passing

🤖 Generated with Claude Code

veksen and others added 4 commits February 26, 2026 19:18
In deployed environments, process.cwd() may not be the project root
(e.g., when the start script does `cd .amplify-hosting/compute/default/
&& node app.js`). This adds findProjectRoot() which walks up from cwd
looking for tsconfig.json to find the real project root.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When compiled JS is relocated (e.g., postbuild copies dist/ to a
deployment directory), source map relative paths resolve to wrong
absolute paths. The file tag would contain bogus paths like
/.amplify-hosting/compute/src/routes/admin.ts instead of the real
project path.

This extracts the src/-relative portion from the stack trace path
and reconstructs it using the real project root found via tsconfig.json.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Inside WSL, absolute paths like /home/user/project/... can't be
resolved from Windows-side tooling (dashboards, VS Code terminal).
This detects the WSL_DISTRO_NAME env var and prefixes resolved paths
with //wsl.localhost/<distro> to make them accessible from Windows.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@veksen veksen merged commit 274a1a7 into master Feb 26, 2026
2 checks passed
@veksen veksen deleted the veksen/drizzle-review branch February 26, 2026 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant