Skip to content

Conversation

@jakebailey
Copy link
Member

  • Make the funcs lazy, so that including them but not calling them won't cause a problem
  • Fix the upward go.mod look; I misunderstood what VolumePath did.
  • Panic early if the source path embedded in the binary looks wrong

Copilot AI review requested due to automatic review settings December 18, 2025 19:12
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the internal/repo package to make repository path functions lazy, preventing initialization issues when the code is included but not called. The changes fix the upward go.mod search logic and add early validation checks for invalid source paths.

Key Changes:

  • Converted package-level variables (RootPath, TypeScriptSubmodulePath, TestDataPath) to lazy-initialized functions using sync.OnceValue
  • Fixed the go.mod upward search by correctly computing the filesystem root with filepath.VolumeName(filename) + string(filepath.Separator)
  • Added panic checks to detect when the binary is built with -trimpath or when paths are not absolute

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
internal/repo/paths.go Core refactoring: converted variables to functions with lazy initialization; fixed root path calculation; added early validation panics
internal/vfs/vfs_test.go Updated repo.TypeScriptSubmodulePath to function call repo.TypeScriptSubmodulePath()
internal/vfs/osvfs/os_test.go Updated repo.RootPath to function call repo.RootPath()
internal/tsoptions/tsconfigparsing_test.go Updated multiple references to repo.TypeScriptSubmodulePath to function calls
internal/tsoptions/commandlineparser_test.go Updated repo.TypeScriptSubmodulePath references to function calls
internal/testutil/jstest/node.go Updated repo.RootPath to function call repo.RootPath()
internal/testutil/harnessutil/harnessutil.go Updated repo.TypeScriptSubmodulePath and repo.TestDataPath to function calls
internal/testutil/fixtures/benchfixtures.go Updated all repo.TypeScriptSubmodulePath references to function calls
internal/testutil/baseline/baseline.go Updated repo.TestDataPath and repo.TypeScriptSubmodulePath to function calls
internal/testrunner/compiler_runner.go Updated multiple repo.TestDataPath references to function calls
internal/parser/parser_test.go Updated repo.TypeScriptSubmodulePath and repo.TestDataPath to function calls
internal/packagejson/packagejson_test.go Updated repo.RootPath and repo.TestDataPath to function calls
internal/format/api_test.go Updated repo.TypeScriptSubmodulePath references to function calls
internal/diagnostics/generate.go Updated multiple repo.TypeScriptSubmodulePath references to function calls
internal/compiler/program_test.go Updated repo.TypeScriptSubmodulePath to function call repo.TypeScriptSubmodulePath()
internal/checker/checker_test.go Updated repo.TypeScriptSubmodulePath to function call repo.TypeScriptSubmodulePath()
internal/bundled/generate.go Updated repo.TypeScriptSubmodulePath references to function calls
internal/astnav/tokens_test.go Updated repo.TypeScriptSubmodulePath to function call repo.TypeScriptSubmodulePath()
internal/api/encoder/encoder_test.go Updated repo.TypeScriptSubmodulePath to function call repo.TypeScriptSubmodulePath()

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.

3 participants