Skip to content

fix: identify circular imports from src/env - #17014

Merged
elliott-with-the-longest-name-on-github merged 3 commits into
version-3from
triage/kit-17013-env-circular-import
Sep 4, 2026
Merged

fix: identify circular imports from src/env#17014
elliott-with-the-longest-name-on-github merged 3 commits into
version-3from
triage/kit-17013-env-circular-import

Conversation

@svelte-triage-bot

@svelte-triage-bot svelte-triage-bot Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Fixes #17013.

When src/env imports a dependency that imports $app/env/private or $app/env/public, loading the environment configuration depends on modules that have not yet been generated.

Recognize this resolution failure and report the circular dependency directly instead of exposing the internal generated-module path. When available, the diagnostic now identifies the project-relative module that imported $app/env/private or $app/env/public.

A regression test covers the transitive helper-import pattern and verifies that the responsible helper module is reported.

Testing

  • pnpm vitest run -c vitest.kit.config.js src/core/sync/sync.spec.js --reporter=verbose
  • pnpm -F @sveltejs/kit test:unit
  • pnpm format
  • pnpm -F @sveltejs/kit lint
  • pnpm -F @sveltejs/kit prepublishOnly

@pkg-svelte-dev

pkg-svelte-dev Bot commented Sep 2, 2026

Copy link
Copy Markdown

Install the latest version of @sveltejs/kit from 2c90fd5:

pnpm add https://pkg.svelte.dev/@sveltejs/kit/c/2c90fd575e104fd3c4be91756495774e8585d906

Open in pkg.svelte.dev: https://pkg.svelte.dev/repos/kit/pr/17014

Note

This PR is from a fork. A maintainer must approve approve each commit before it can be built and installed.

@changeset-bot

changeset-bot Bot commented Sep 2, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 2c90fd5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@sveltejs/kit Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@dummdidumm
dummdidumm marked this pull request as ready for review September 3, 2026 13:12
Comment thread packages/kit/src/core/env.js Outdated
@svelte-triage-bot svelte-triage-bot Bot changed the title fix: clarify circular imports from src/env fix: identify circular imports from src/env Sep 3, 2026
@ottomated

Copy link
Copy Markdown
Contributor

@svelte-triage-bot Throw the error using stackless so it doesn't take up so much space in the terminal

@svelte-triage-bot

Copy link
Copy Markdown
Contributor Author

Implemented and pushed the stackless change to the existing PR branch.

  • Commit: 2c90fd575e104fd3c4be91756495774e8585d906
  • Updated regression test verifies the diagnostic has no stack.
  • Focused tests, unit tests, formatting, lint, and prepublish checks pass.

I also recorded this feedback in svelte-agent#5.

@elliott-with-the-longest-name-on-github
elliott-with-the-longest-name-on-github merged commit ee2f55b into sveltejs:version-3 Sep 4, 2026
36 of 37 checks passed
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.

Circular imports in env.ts are confusing

3 participants