chore: make set_env synchronous#16060
Merged
Merged
Conversation
|
6 tasks
…in analyse.js references `set_env`, which was removed from the `ServerInternalModule` interface, causing a TS2339 type-check error. This commit fixes the issue reported at packages/kit/src/core/postbuild/analyse.js:64 ## Bug In this PR, `set_env` was removed from the `ServerInternalModule` interface in `internal.d.ts` (no `set_env` matches found there) and is now declared only on the `__sveltekit/env` ambient module: ```ts // ambient-private.d.ts export function set_env(environment: Record<string, string>): void; ``` However, `packages/kit/src/core/postbuild/analyse.js` still annotates the dynamic `env.js` import with the old type: ```js /** @type {import('types').ServerInternalModule} */ const { set_env } = await import(pathToFileURL(`${server_root}/server/env.js`).href); set_env(env); ``` Destructuring `set_env` from a value typed as `ServerInternalModule` — which no longer has that member — triggers **TS2339: Property 'set_env' does not exist on type 'ServerInternalModule'** under `pnpm check` (tsc with `checkJs`). The analogous code in `prerender.js` was correctly updated to use `@type {import('__sveltekit/env')}`. ## Trigger Running `pnpm check` will fail on `analyse.js` line 64-65 because `set_env` is no longer a member of `ServerInternalModule`. ## Fix Changed the annotation in `analyse.js` to `@type {import('__sveltekit/env')}`, matching the corrected code in `prerender.js`. Co-authored-by: Vercel <vercel[bot]@users.noreply.github.com> Co-authored-by: Rich-Harris <hello@rich-harris.dev>
teemingc
approved these changes
Jun 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Didn't get a chance to review #16058, but I think we should extract the env stuff out into a separate module, so that we don't need the dynamic import in
set_env— not really an issue during build, but adds unnecessary microtasks on everyserver.init(...)at runtime