svelte-kit-sst incompatible with SvelteKit 3 — Lambda handler imports removed @sveltejs/kit/node/polyfills export
Description
Deploying a SvelteKit app with sst.aws.SvelteKit fails during the Lambda function bundling step. The svelte-kit-sst adapter's generated Lambda handler imports @sveltejs/kit/node/polyfills, but that subpath export was removed in SvelteKit 3, so the bundler cannot resolve it.
The two core issues:
The adapter declares
@sveltejs/kit^1.5.0([email protected]), and its shipped handler (dist/handler/index.js, copied to.svelte-kit/svelte-kit-sst/server/lambda-handler/index.js) does:import { installPolyfills } from "@sveltejs/kit/node/polyfills"; // ... installPolyfills();SvelteKit 3 removed
./node/polyfillsfrom its export map. Installed@sveltejs/[email protected]exposes:".", "./internal", "./internal/env", "./internal/types", "./internal/server", "./adapter", "./node", "./hooks", "./env", "./params", "./vite"./nodeexists, but./node/polyfillsdoes not.
Error
Error: Could not resolve "@sveltejs/kit/node/polyfills" .svelte-kit/svelte-kit-sst/server/lambda-handler/index.js:3:33
at .../.sst/platform/src/components/aws/function.ts:2105:21References
- SvelteKit 3 migration guide —
@sveltejs/kit/node/polyfills(removed): https://next.svelte.dev/docs/kit/migrating-to-sveltekit-3The
@sveltejs/kit/node/polyfillsmodule (and the Node global shims inadapter-nodeandadapter-netlify) applied to Node versions that are no longer supported. Remove anyimport '@sveltejs/kit/node/polyfills'statements from your custom server code. - Same guide states "All first-party adapters now require SvelteKit 3", with per-adapter migration steps — a third-party adapter like
svelte-kit-sstneeds equivalent updates. - Historical origin of the module: sveltejs/kit PR #4934 "Node polyfills" ("replace
@sveltejs/kit/install-fetchwith@sveltejs/kit/node/polyfills").
Additional adapter-API breakage against Kit 3
Beyond the fatal import, the adapter's adapt() (dist/index.js) uses builder methods that the migration guide lists as deprecated in Kit 3 in favour of node:fs:
builder.rimraf(out);
builder.mkdirp(clientDir);
builder.mkdirpandbuilder.rimrafare deprecated in favour ofnode:fsmethods.
(These are only deprecations today, but signal the adapter predates the Kit 3 adapter API.)
Notes
vite build/ the adapter'sadapt()step succeeds because it only copies the prewritten handler files — it does not bundle them. Resolution fails later, when SST bundles the Lambda function, which is where the deploy aborts.- The deploy is left partially applied — asset files, CloudWatch log group, server IAM role, and the API gateway are created before the error.
Environment
| Package | Version |
|---|---|
| sst | 4.17.1 |
| svelte-kit-sst | 2.43.5 |
| @sveltejs/kit | 3.0.0-next.25 |
| @sveltejs/vite-plugin-svelte | 7.3.0 |
| svelte | 5.57.0 |
| vite | 8.2.2 |
| Node | 22.14.0 |
| OS | Linux |
Expected
Either svelte-kit-sst is updated for SvelteKit 3 (drop the installPolyfills import; adopt the current adapter API), or the docs/adapter declare a supported SvelteKit version range so sst.aws.SvelteKit builds don't fail at deploy time.
Source: anomalyco/sst