@eslym/sveltekit-adapter-bun 1.0.15 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,12 +2,18 @@
2
2
 
3
3
  Another sveltekit adapter for bun, an alternative to [svelte-adapter-bun](https://github.com/gornostay25/svelte-adapter-bun). This package support websocket in dev mode with few steps of setup.
4
4
 
5
+ The built bundle with version `2.0.0` will be ready to compile into single executable with bun.
6
+
5
7
  ## Installation
6
8
 
7
9
  ```shell
8
10
  bun add -d @eslym/sveltekit-adapter-bun
9
11
  ```
10
12
 
13
+ > [!IMPORTANT] > **Breaking Changes**
14
+ >
15
+ > Since version `2.0.0`, the custom hooks (`beforeServe`, `afterServe` and `setupCLI`) and CLI functionality is complemetely removed.
16
+
11
17
  ## Setup dev server
12
18
 
13
19
  > [!NOTE]
@@ -15,6 +21,7 @@ bun add -d @eslym/sveltekit-adapter-bun
15
21
 
16
22
  1. Create an entrypoint file for dev server, e.g. `./dev.ts`
17
23
  2. Add the following code to the entrypoint file
24
+
18
25
  ```typescript
19
26
  import { patchSvelteKit, startDevServer } from '@eslym/sveltekit-adapter-bun';
20
27
 
@@ -70,3 +77,87 @@ export async function GET({ platform }) {
70
77
  );
71
78
  }
72
79
  ```
80
+
81
+ ## Adapter Options
82
+
83
+ ```typescript
84
+ export type AdapterOptions = {
85
+ /**
86
+ * Output path
87
+ * @default './build'
88
+ */
89
+ out?: string;
90
+
91
+ /**
92
+ * The bundler for the final step build.
93
+ * @default 'rollup'
94
+ */
95
+ bundler?: 'rollup' | 'bun';
96
+
97
+ /**
98
+ * Enable pre-compress
99
+ * @default false
100
+ */
101
+ precompress?: boolean | PreCompressOptions;
102
+
103
+ /**
104
+ * Serve static assets, set if to false if you want to handle static assets yourself
105
+ * like using nginx or caddy. When it is true, an index of assets will build with
106
+ * bun's `import with { type: 'file' }` syntax, which make it ready to bundle into
107
+ * single executable file.
108
+ *
109
+ * @default true
110
+ */
111
+ serveStatic?: boolean;
112
+
113
+ /**
114
+ * File patterns to be ignored in the static assets, ex: `*.{br,gz}`
115
+ * @default ["**​/.*"]
116
+ */
117
+ staticIgnores?: string[];
118
+
119
+ /**
120
+ * Export prerendered entries as json
121
+ * @default false
122
+ */
123
+ exportPrerender?: boolean;
124
+
125
+ /**
126
+ * Include source maps
127
+ *
128
+ * @default true
129
+ */
130
+ sourceMap?: boolean | 'inline';
131
+
132
+ /**
133
+ * Minify the output when using bun build
134
+ *
135
+ * @default false
136
+ */
137
+ bunBuildMinify?:
138
+ | boolean
139
+ | {
140
+ whitespace?: boolean;
141
+ syntax?: boolean;
142
+ identifiers?: boolean;
143
+ };
144
+ };
145
+ ```
146
+
147
+ ## Runtime Environments
148
+
149
+ | Name | Description | Default |
150
+ | ---------------------- | ------------------------------------------------------------------------------------ | --------- |
151
+ | `HTTP_HOST` | The host for the server | `0.0.0.0` |
152
+ | `HTTP_PORT` | The port for the server | `3000` |
153
+ | `HTTP_SOCKET` | The path of the unix socket which the server will listen to (this will disable http) | - |
154
+ | `HTTP_PROTOCOL_HEADER` | The header name to get the protocol from the request | - |
155
+ | `HTTP_HOST_HEADER` | The header name to get the host from the request | - |
156
+ | `HTTP_IP_HEADER` | The header name to get the client ip from the request (usually `X-Forwarded-For`) | - |
157
+ | `HTTP_XFF_DEPTH` | The depth of the `X-Forwarded-For` header to get the client ip | `1` |
158
+ | `HTTP_OVERRIDE_ORIGIN` | Force the request origin when it is unable to retrieve from the request | - |
159
+ | `HTTP_IDLE_TIMEOUT` | The request timeout for the server(in seconds) | `30` |
160
+ | `HTTP_MAX_BODY` | The maximum body size for the request | `128mib` |
161
+ | `WS_IDLE_TIMEOUT` | The websocket idle timeout (in seconds) | `120` |
162
+ | `WS_MAX_PAYLOAD` | The maximum payload size for the websocket | `16mib` |
163
+ | `WS_NO_PING` | Disable automatic ping response | `false` |
@@ -0,0 +1,4 @@
1
+ import type { Glob } from 'bun';
2
+ export declare function build_assets_js(base_path: string, client_files: AsyncIterableIterator<string>, prerendered_pages: Map<string, {
3
+ file: string;
4
+ }>, immutable_prefix: string, ignores: Glob[]): Promise<string>;
package/dist/dev.d.ts CHANGED
@@ -1,5 +1,6 @@
1
+ import type { DevServeOptions } from './types';
1
2
  export declare function patchSveltekit(): Promise<void>;
2
- export declare function startDevServer({ port, host, config }?: {
3
+ export declare function startDevServer({ port, host, idleTimeout, config, websocket, ...serveOptions }?: DevServeOptions & {
3
4
  port?: number;
4
5
  host?: string;
5
6
  config?: string;