AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

Fix Edge Function Import Resolution For GitHub Branch Deployments

Supabase GitHub branch integration deploys fail at bundling when edge functions use relative or @ alias imports because the CLI bundler resolves paths from the repository root instead of the function directory.

highConfidence 72%Supabase-Cli

Origin Analysis

The Supabase CLI Edge Function bundler uses process working directory (cwd) as the base for import resolution. When deploying from a persistent branch via GitHub integration, the cwd is the repository root or a temporary checkout, not the functions directory. This causes relative imports like './helper' and path aliases like '@/' to fail with 'Could not resolve' errors.
1. Create a Supabase project with GitHub integration and a persistent branch. 2. Add an edge function that imports a local module using a relative path or '@' alias. 3. Deploy the function from the GitHub branch using the integration. 4. Observe bundling fails with path resolution error; deploying locally with 'supabase functions deploy' succeeds.

Fixing Code Block

Edge Case Audit

Changing AbsWorkingDir may affect existing functions that intentionally imported using paths relative to the repository root; test all functions before rolling out. The alias plugin only handles single-level '@/' prefixes and may not fully support complex tsconfig path mappings; consider using a dedicated tsconfig-paths plugin for production. Ensure Windows path separators are normalized (use filepath.ToSlash) to avoid esbuild failures. Because this modifies shared bundling logic, concurrent deployments of different functions must not share mutable plugin state. Rollback by reverting to the previous bundler configuration if unexpected import errors appear.

Ecosystem Topology