feat: add Bun adapter - #16695
Open
Black-Hack wants to merge 96 commits into
Open
Conversation
… configuration - Add env.js for managing environment variables with validation and fallback options. - Introduce handler.js to manage the Bun-native SvelteKit request handling. - Create index.js to configure server options based on environment variables. - Implement static.js for serving static files and handling prerendered paths. - Add utils.js for utility functions related to byte parsing and header management. - Create tests for environment variable functions and utility functions. - Set up a basic SvelteKit application with routes, static files, and event streams. - Configure Playwright for end-to-end testing of the application.
…nd enhance type definitions
…ndling in Bun build process
…or executable generation
…serving with URL encoding support
…improved performance
…asset handling - Added TLS configuration options in serverOptions, allowing for certificate and key specification. - Introduced embedded asset handling for serving static files with metadata (size, type, lastModified, etag). - Updated file_route to support embedded assets and conditional requests. - Enhanced compile options to reserve runtime target and module format, ensuring user configurations are safely composed. - Added tests for TLS options and embedded asset functionality to ensure robustness. - Improved documentation to clarify usage of new features and options.
…ed shutdown logic
…ironment variables
…ation and updating related tests
…s module and removing unused assets
…necessary declarations
…lization and improve type definitions
…s for Bun integration
… usage in configuration
… type definitions
…or entrypoint logic
…trumentation logic
Rich-Harris
reviewed
Aug 11, 2026
Rich-Harris
reviewed
Aug 11, 2026
Rich-Harris
reviewed
Aug 11, 2026
Rich-Harris
reviewed
Aug 11, 2026
Rich-Harris
reviewed
Aug 11, 2026
Rich-Harris
reviewed
Aug 11, 2026
Rich-Harris
reviewed
Aug 11, 2026
Rich-Harris
left a comment
Member
There was a problem hiding this comment.
a few small nits but this is a great addition! thank you
Namespace imports for node:path and node:fs, sync fs calls in the build-time code with an existsSync early return instead of catching ENOENT, fs.rmSync in place of the deprecated builder.rimraf, and snake_case with url/filename naming for internal variables.
Matches kit's convention of one @import comment per module instead of inline import() types at every use site.
Contributor
|
@Black-Hack apologies for pushing straight to your branch, it felt like the fastest way to spare us weeks of back and forth. Please go through the commits when you get a chance. If anything I changed doesn't sit right, do not hesitate to communicate them in this thread. |
Control characters are deliberately part of the URL Standard's path percent-encode set.
This comment was marked as resolved.
This comment was marked as resolved.
Nic-Polumeyv
marked this pull request as draft
August 11, 2026 17:57
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.
closes #16070
Summary
This PR adds an official
@sveltejs/adapter-bunpackage that builds SvelteKit applications into standalone Bun-native servers usingBun.serve, Web API requests/responses, native routes, andBun.file.What changed
$app/serverreads,instrumentation.server.js, server-sent events, graceful shutdown, request-origin normalization, and trusted proxy headers.Requestand BunServerthroughevent.platform, including Bun metrics andrequestIP.Key differences from
adapter-nodeadapter-bunadapter-nodeBun.serveand Web APIssirvwith Brotli/gzip precompressionevent.platformhandler.jsand Node request contextApplication imports follow Bun's bundler behavior rather than
adapter-node'sdependencies/devDependenciesexternalization policy.Decisions and tradeoffs
HEADbehavior.fetchandroutesto preserve SvelteKit behavior.event.platform.requestretains the original Bun request required by native APIs.Known limitations and future work
*as a route wildcard, so filenames containing a literal*are currently rejected at build time.buildOptions, dependency externalization controls, MIME handling, and literal-wildcard support.Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm testand lint the project withpnpm lintandpnpm checkChangesets
pnpm changesetand following the prompts. Changesets that add features should beminorand those that fix bugs should bepatch. Please prefix changeset messages withfeat:,fix:, orchore:.Edits