Skip to content

breaking: move env-related types to @sveltejs/kit/env - #16739

Merged
Rich-Harris merged 4 commits into
version-3from
env-types
Aug 11, 2026
Merged

breaking: move env-related types to @sveltejs/kit/env#16739
Rich-Harris merged 4 commits into
version-3from
env-types

Conversation

@Rich-Harris

Copy link
Copy Markdown
Member

Another part of #16676


Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

  • Run the tests with pnpm test and lint the project with pnpm lint and pnpm check

Changesets

  • If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpm changeset and following the prompts. Changesets that add features should be minor and those that fix bugs should be patch. Please prefix changeset messages with feat:, fix:, or chore:.

Edits

  • Please ensure that 'Allow edits from maintainers' is checked. PRs without this option may be closed.

@pkg-svelte-dev

pkg-svelte-dev Bot commented Aug 11, 2026

Copy link
Copy Markdown

Install the latest version of @sveltejs/kit from 9a4ecd6:

pnpm add https://pkg.svelte.dev/@sveltejs/kit/c/9a4ecd63a6313d9e20ce120fcd12756169d64137

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

@changeset-bot

changeset-bot Bot commented Aug 11, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 9a4ecd6

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 Major

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

@Rich-Harris

Copy link
Copy Markdown
Member Author

/autofix

@vercel vercel Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Additional Suggestion:

Moving EnvVarConfig/DefinedEnvVars to src/exports/env/public.d.ts breaks internal JSDoc imports that still pull them from @sveltejs/kit, and the tsconfig paths for @sveltejs/kit/env still points at the runtime index.js (no types), so source typechecking (pnpm check) fails.

Fix on Vercel

…c.d.ts` breaks internal JSDoc imports that still pull them from `@sveltejs/kit`, and the tsconfig `paths` for `@sveltejs/kit/env` still points at the runtime `index.js` (no types), so source typechecking (`pnpm check`) fails.

This commit fixes the issue reported at packages/kit/src/exports/env/index.js:2

## Bug

This PR deleted `EnvVarConfig` and `DefinedEnvVars` from `packages/kit/src/exports/public.d.ts` and relocated them to the new `packages/kit/src/exports/env/public.d.ts`. Verified:

- `grep EnvVarConfig|DefinedEnvVars` in `src/exports/public.d.ts` → **no matches** (they were removed).
- Both types are now declared only in `src/exports/env/public.d.ts`.

However, the tsconfig `paths` map resolves the bare package specifier to the (now stripped) barrel:

```jsonc
"@sveltejs/kit": ["./src/exports/public.d.ts"],
```

and every internal file still imports the moved types from `@sveltejs/kit`:

- `src/exports/env/index.js:2`
- `src/exports/internal/env.js:2`
- `src/exports/vite/index.js:1`
- `src/core/adapt/builder.js:4`
- `src/core/adapt/index.js:13` (inline `import('@sveltejs/kit').EnvVarConfig`)
- `src/core/env.js:2`
- `src/core/sync/write_env.js:1`

During source typechecking (`pnpm check` → tsc), each of these resolves `@sveltejs/kit` to `public.d.ts`, which no longer exports `EnvVarConfig`/`DefinedEnvVars`, producing `Module '@sveltejs/kit' has no exported member 'EnvVarConfig'` (and `DefinedEnvVars`).

Additionally, the `@sveltejs/kit/env` path entry pointed to the runtime module:

```jsonc
"@sveltejs/kit/env": ["./src/exports/env/index.js"],
```

`index.js` only exports the `defineEnvVars` function — it does not declare the types (the `.d.ts` does `export * from './index.js'` and then adds the type declarations). So merely repointing the imports to `@sveltejs/kit/env` would still not resolve the types unless the tsconfig path also targeted the `.d.ts`.

This mirrors exactly what the earlier `@sveltejs/kit/params` move (same umbrella issue #16676) did correctly: `"@sveltejs/kit/params": ["./src/exports/params/public.d.ts"]` plus internal imports from `@sveltejs/kit/params`.

## Fix

1. Repointed the tsconfig path to the declaration file:
   ```jsonc
   "@sveltejs/kit/env": ["./src/exports/env/public.d.ts"],
   ```
2. Updated all internal JSDoc imports of `EnvVarConfig`/`DefinedEnvVars` to import from `@sveltejs/kit/env`. Where a file imported both a moved env type and a type that still lives in the main barrel (e.g. `KitConfig` in `vite/index.js`, `RouteDefinition` in `builder.js`), the import was split into two `@import` lines so the remaining types keep resolving via `@sveltejs/kit`.

I could not execute `tsc` here because the sandbox has no installed `node_modules`/`@typescript/native`, but the failure is structural (a resolved module missing an exported member) and the fix restores the exact pattern already proven for the `params` migration.

Co-authored-by: Vercel <vercel[bot]@users.noreply.github.com>
Co-authored-by: Rich-Harris <hello@rich-harris.dev>
@svelte-docs-bot

Copy link
Copy Markdown

@Rich-Harris
Rich-Harris merged commit 81d6319 into version-3 Aug 11, 2026
26 of 27 checks passed
@Rich-Harris
Rich-Harris deleted the env-types branch August 11, 2026 17:19
Rich-Harris pushed a commit that referenced this pull request Aug 11, 2026
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to version-3, this PR
will be updated.

⚠️⚠️⚠️⚠️⚠️⚠️

`version-3` is currently in **pre mode** so this branch has prereleases
rather than normal releases. If you want to exit prereleases, run
`changeset pre exit` on `version-3`.

⚠️⚠️⚠️⚠️⚠️⚠️

# Releases
## @sveltejs/kit@3.0.0-next.20

### Major Changes

- breaking: move remote function types to `$app/server`
([#16740](#16740))

- breaking: remove `#lib` definition from `paths`; requires explicit
module extensions as a result
([#16736](#16736))

- breaking: move hooks-related types to `@sveltejs/kit/hooks`
([#16737](#16737))

- breaking: move env-related types to `@sveltejs/kit/env`
([#16739](#16739))

### Minor Changes

- feat: better response logging
([#16744](#16744))

### Patch Changes

- chore: bump `mrmime` to 2.0.1
([#16745](#16745))

- chore: bump `@sveltejs/acorn-typescript` to 1.0.12
([#16745](#16745))

- chore: bump `magic-string` to 1.1.0
([#16745](#16745))

- chore: bump `devalue` to 5.9.0
([#16745](#16745))

- chore: bump `cookie` to 2.0.1
([#16745](#16745))

- chore: bump `acorn` to 8.18.0
([#16745](#16745))

- fix: avoid infinite loop when building with `--watch` flag
([#16632](#16632))
## @sveltejs/adapter-cloudflare@8.0.0-next.6

### Patch Changes

- chore: bump `@cloudflare/worker-types` to 5.20260809.1
([#16745](#16745))
- Updated dependencies
[[`1742811`](1742811),
[`1611c61`](1611c61),
[`b361b81`](b361b81),
[`b361b81`](b361b81),
[`b361b81`](b361b81),
[`b361b81`](b361b81),
[`13e7b18`](13e7b18),
[`529346d`](529346d),
[`b361b81`](b361b81),
[`81d6319`](81d6319),
[`b361b81`](b361b81),
[`69a5bdf`](69a5bdf)]:
  - @sveltejs/kit@3.0.0-next.20
## @sveltejs/adapter-netlify@7.0.0-next.8

### Patch Changes

- chore: bump `rolldown` to 1.2.3
([#16745](#16745))
- Updated dependencies
[[`1742811`](1742811),
[`1611c61`](1611c61),
[`b361b81`](b361b81),
[`b361b81`](b361b81),
[`b361b81`](b361b81),
[`b361b81`](b361b81),
[`13e7b18`](13e7b18),
[`529346d`](529346d),
[`b361b81`](b361b81),
[`81d6319`](81d6319),
[`b361b81`](b361b81),
[`69a5bdf`](69a5bdf)]:
  - @sveltejs/kit@3.0.0-next.20
## @sveltejs/adapter-node@6.0.0-next.10

### Patch Changes

- chore: bump `rolldown` to 1.2.3
([#16745](#16745))
- Updated dependencies
[[`1742811`](1742811),
[`1611c61`](1611c61),
[`b361b81`](b361b81),
[`b361b81`](b361b81),
[`b361b81`](b361b81),
[`b361b81`](b361b81),
[`13e7b18`](13e7b18),
[`529346d`](529346d),
[`b361b81`](b361b81),
[`81d6319`](81d6319),
[`b361b81`](b361b81),
[`69a5bdf`](69a5bdf)]:
  - @sveltejs/kit@3.0.0-next.20
## @sveltejs/enhanced-img@1.0.0-next.5

### Patch Changes

- chore: bump `magic-string` to 1.1.0
([#16745](#16745))

- chore: bump `zimmerframe` to 1.1.4
([#16745](#16745))
## @sveltejs/package@3.0.0-next.6

### Patch Changes

- chore: bump `svelte2tsx` to 0.7.59
([#16745](#16745))

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

2 participants