Skip to content

fix(compile): detect svelte-adapter-deno build output#34535

Merged
bartlomieju merged 3 commits into
mainfrom
fix/compile-sveltekit-adapter-deno
May 30, 2026
Merged

fix(compile): detect svelte-adapter-deno build output#34535
bartlomieju merged 3 commits into
mainfrom
fix/compile-sveltekit-adapter-deno

Conversation

@bartlomieju

@bartlomieju bartlomieju commented May 29, 2026

Copy link
Copy Markdown
Member

Framework detection for compiling a directory mapped any SvelteKit project
whose svelte.config referenced svelte-adapter-deno to a Nitro-style
.output/server/index.mjs entrypoint. That adapter does not use Nitro; it emits
a build/ directory where build/index.js boots the server and build/handler.js
serves static assets from sibling client, static and prerendered directories.
As a result deno compile on such a project failed with a missing .output
module, and the older workaround of compiling build/index.js directly produced
a server that returned 404 for every asset because the static directories were
never embedded in the binary.

This detects the build/index.js plus build/handler.js output shape (and the
svelte-adapter-deno config when there is no build yet) and generates a
./build/index.js entrypoint, including the build/client, build/static and
build/prerendered directories that exist so the compiled binary can serve
them.

It also disables Deno type checking for SvelteKit, the same way it is already
done for Next.js, because the adapter's bundled output references Node types
that aren't resolvable from the build and would otherwise fail type checking.
With both changes, deno compile ./my-app just works with no extra flags.
Verified end to end against a scaffolded SvelteKit app: the resulting binary
serves the page, static files and the immutable client assets.

Fixes #26155

Framework detection for `deno compile <dir>` mapped any svelte.config that
referenced `svelte-adapter-deno` to a Nitro-style `.output/server/index.mjs`
entrypoint. That adapter actually emits a `build/` directory (`build/index.js`
boots the server, `build/handler.js` serves static assets from sibling
`client`/`static`/`prerendered` dirs), so compilation failed with a missing
`.output` module, and even when worked around the static assets 404'd at
runtime because they were never embedded.

Detect the `build/index.js` + `build/handler.js` output shape (and the
`svelte-adapter-deno` config) and generate a `./build/index.js` entrypoint,
including the existing `build/client`, `build/static` and `build/prerendered`
asset directories so the compiled binary serves them.

Fixes #26155
The svelte-adapter-deno build output references Node types that aren't
resolvable from the bundle, so type checking the generated entrypoint fails
with a '@types/node' resolution error. Disable type checking for SvelteKit the
same way it is already done for Next.js, so `deno compile <dir>` works without
requiring `--no-check`.
@bartlomieju
bartlomieju enabled auto-merge (squash) May 30, 2026 06:41
@bartlomieju
bartlomieju merged commit 862d283 into main May 30, 2026
268 of 270 checks passed
@bartlomieju
bartlomieju deleted the fix/compile-sveltekit-adapter-deno branch May 30, 2026 06:42
littledivy pushed a commit to crowlKats/deno that referenced this pull request Jun 10, 2026
Framework detection for compiling a directory mapped any SvelteKit
project whose svelte.config referenced svelte-adapter-deno to a Nitro-style
.output/server/index.mjs entrypoint. That adapter does not use Nitro; it
emits a build/ directory where build/index.js boots the server and
build/handler.js serves static assets from sibling client, static and prerendered
directories.
As a result deno compile on such a project failed with a missing .output
module, and the older workaround of compiling build/index.js directly
produced a server that returned 404 for every asset because the static
directories were never embedded in the binary.

This detects the build/index.js plus build/handler.js output shape (and
the svelte-adapter-deno config when there is no build yet) and generates a
./build/index.js entrypoint, including the build/client, build/static
and build/prerendered directories that exist so the compiled binary can
serve them.

It also disables Deno type checking for SvelteKit, the same way it is
already done for Next.js, because the adapter's bundled output references Node
types that aren't resolvable from the build and would otherwise fail type
checking.
With both changes, deno compile ./my-app just works with no extra flags.
Verified end to end against a scaffolded SvelteKit app: the resulting
binary serves the page, static files and the immutable client assets.

Fixes denoland#26155
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.

Deno 2 compile doesn't work on sveltekit (error: Module not found runtime/control.js)

1 participant