[PR #8148] fix: Add test to avoid throwing errors during SvelteKit build process #7780

Open
opened 2026-03-13 13:48:56 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/8148
Author: @simonfelding
Created: 2/25/2026
Status: 🔄 Open

Base: canaryHead: fix-sveltekit-errors-during-build


📝 Commits (4)

  • 90d0241 this should work
  • a774c1b make format & lint happy
  • 39b3071 try to ignore the linter like this
  • 436585c maybe this will skip the linter

📊 Changes

3 files changed (+21 additions, -1 deletions)

View changed files

📝 knip.jsonc (+4 -0)
📝 packages/core/src/env/env-impl.ts (+16 -1)
📝 packages/core/src/env/index.ts (+1 -0)

📄 Description

Not very pretty, but it should work. There is no other way to do this.

Also exports a new function to check if we are in a sveltekit build process - may come in handy later.

Solves #8125 #8061 #288 once and for all :)

NOTE: I haven't tested this yet. I don't really see how I can build a good test for this. Open to feedback.


Summary by cubic

Detect SvelteKit builds and treat them as test mode to prevent env errors during build. Exposes a helper to detect SvelteKit build state.

  • Bug Fixes

    • Detect build via $app/environment.building, make isTest return true during build, and add knip ignoreUnresolved for $app/environment to silence unresolved import warnings.
  • New Features

    • Export isSvelteKitBuilding for future checks.

Written for commit 436585c9cc. Summary will update on new commits.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/8148 **Author:** [@simonfelding](https://github.com/simonfelding) **Created:** 2/25/2026 **Status:** 🔄 Open **Base:** `canary` ← **Head:** `fix-sveltekit-errors-during-build` --- ### 📝 Commits (4) - [`90d0241`](https://github.com/better-auth/better-auth/commit/90d02415f194abcde50a380f905c69423d9c8a70) this should work - [`a774c1b`](https://github.com/better-auth/better-auth/commit/a774c1b319390e2929125bbbb7bc50e93742696e) make format & lint happy - [`39b3071`](https://github.com/better-auth/better-auth/commit/39b30711a07055575152c03e60627626ee888c00) try to ignore the linter like this - [`436585c`](https://github.com/better-auth/better-auth/commit/436585c9cc03258ef1530ae08c26a96facdc49ea) maybe this will skip the linter ### 📊 Changes **3 files changed** (+21 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `knip.jsonc` (+4 -0) 📝 `packages/core/src/env/env-impl.ts` (+16 -1) 📝 `packages/core/src/env/index.ts` (+1 -0) </details> ### 📄 Description Not very pretty, but it should work. There is no other way to do this. Also exports a new function to check if we are in a sveltekit build process - may come in handy later. Solves #8125 #8061 #288 once and for all :) NOTE: I haven't tested this yet. I don't really see how I can build a good test for this. Open to feedback. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Detect SvelteKit builds and treat them as test mode to prevent env errors during build. Exposes a helper to detect SvelteKit build state. - **Bug Fixes** - Detect build via $app/environment.building, make isTest return true during build, and add knip ignoreUnresolved for $app/environment to silence unresolved import warnings. - **New Features** - Export isSvelteKitBuilding for future checks. <sup>Written for commit 436585c9cc03258ef1530ae08c26a96facdc49ea. Summary will update on new commits.</sup> <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-03-13 13:48:56 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#7780