@eslym/sveltekit-adapter-bun 1.0.0 → 1.0.2
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/LICENSE +7 -0
- package/README.md +9 -1
- package/dist/files/index.js +10 -1
- package/dist/index.js +20 -5
- package/package.json +13 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright 2024 0nepeop1e
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
1
|
# @eslym/sveltekit-adapter-bun
|
|
2
2
|
|
|
3
|
-
Another sveltekit adapter for bun
|
|
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
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```shell
|
|
8
|
+
bun add -d @eslym/sveltekit-adapter-bun
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
TODO: add documentation
|
package/dist/files/index.js
CHANGED
|
@@ -897,7 +897,16 @@ import {get_hooks} from "SERVER";
|
|
|
897
897
|
set_basepath(import.meta.dir);
|
|
898
898
|
var hooks = await get_hooks();
|
|
899
899
|
var cli = dist_default(CLI_NAME);
|
|
900
|
-
|
|
900
|
+
var env = Bun.env;
|
|
901
|
+
cli.command("", "Serve the app").alias("serve").option("--port, -p <port>", "Port to listen on", { default: env.HTTP_PORT || 3000 }).option("--host, -h <host>", "Host to listen on", { default: env.HTTP_HOST || "localhost" }).option("--unix-socket, -u <unix-socket>", "Serve on a unix socket instead.", {
|
|
902
|
+
default: env.HTTP_SOCKET
|
|
903
|
+
}).option("--protocol-header, -P <protocol-header>", "Protocol header to use", {
|
|
904
|
+
default: env.HTTP_PROTOCOL
|
|
905
|
+
}).option("--override-origin, -O <override-origin>", "Override the origin", {
|
|
906
|
+
default: env.HTTP_OVERRIDE_ORIGIN
|
|
907
|
+
}).option("--host-header, -H <host-header>", "Host header to use", {
|
|
908
|
+
default: env.HTTP_HOST_HEADER
|
|
909
|
+
}).option("--ip-header, -i <ip-header>", "IP header to use", { default: env.HTTP_IP_HEADER }).option("--xff-depth, -x <xff-depth>", "X-Forwarded-For depth", { default: env.HTTP_XFF_DEPTH }).action(async (options) => {
|
|
901
910
|
await hooks.beforeServe?.(options);
|
|
902
911
|
const serverOptions = options.unixSocket ? {
|
|
903
912
|
unix: options.unixSocket
|
package/dist/index.js
CHANGED
|
@@ -29,6 +29,9 @@ import {dirname, join} from "path";
|
|
|
29
29
|
import {EventEmitter} from "events";
|
|
30
30
|
import {IncomingMessage, ServerResponse} from "http";
|
|
31
31
|
async function patchSveltekit() {
|
|
32
|
+
if (!("Bun" in globalThis)) {
|
|
33
|
+
throw new Error("Please run with bun");
|
|
34
|
+
}
|
|
32
35
|
if (Bun.semver.satisfies(Bun.version, "<1.1.15")) {
|
|
33
36
|
throw new Error("bun patch requires Bun >= 1.1.15");
|
|
34
37
|
}
|
|
@@ -51,9 +54,21 @@ async function patchSveltekit() {
|
|
|
51
54
|
console.log("Patched @sveltejs/kit/node");
|
|
52
55
|
await Bun.$`${bun} patch --commit 'node_modules/@sveltejs/kit'`;
|
|
53
56
|
}
|
|
54
|
-
async function startDevServer({
|
|
57
|
+
async function startDevServer({
|
|
58
|
+
port = 5173,
|
|
59
|
+
host = "localhost",
|
|
60
|
+
config
|
|
61
|
+
} = {}) {
|
|
62
|
+
if (!("Bun" in globalThis)) {
|
|
63
|
+
throw new Error("Please run with bun");
|
|
64
|
+
}
|
|
55
65
|
if (!config) {
|
|
56
|
-
for (const cfg of [
|
|
66
|
+
for (const cfg of [
|
|
67
|
+
"vite.config.ts",
|
|
68
|
+
"vite.config.js",
|
|
69
|
+
"vite.config.cjs",
|
|
70
|
+
"vite.config.mjs"
|
|
71
|
+
]) {
|
|
57
72
|
if (Bun.file(cfg).size) {
|
|
58
73
|
config = cfg;
|
|
59
74
|
break;
|
|
@@ -203,9 +218,6 @@ var exportSetupCLI = function(out) {
|
|
|
203
218
|
writeFileSync(`${out}/index.js`, result, "utf8");
|
|
204
219
|
};
|
|
205
220
|
var files = fileURLToPath(new URL("./files", import.meta.url));
|
|
206
|
-
if (!("Bun" in globalThis)) {
|
|
207
|
-
throw new Error("Please run with bun");
|
|
208
|
-
}
|
|
209
221
|
function adapter(userOpts = {}) {
|
|
210
222
|
const opts = {
|
|
211
223
|
out: "./build",
|
|
@@ -218,6 +230,9 @@ function adapter(userOpts = {}) {
|
|
|
218
230
|
return {
|
|
219
231
|
name,
|
|
220
232
|
async adapt(builder) {
|
|
233
|
+
if (!("Bun" in globalThis)) {
|
|
234
|
+
throw new Error("Please run with bun");
|
|
235
|
+
}
|
|
221
236
|
if (Bun.semver.order(Bun.version, "1.1.8") < 0) {
|
|
222
237
|
if (opts.precompress === true) {
|
|
223
238
|
builder.log.warn(`Bun v${Bun.version} does not support brotli, please use newer version of bun or nodejs to build, otherwise brotli will be ignore.`);
|
package/package.json
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslym/sveltekit-adapter-bun",
|
|
3
|
-
"
|
|
3
|
+
"description": "Another sveltekit adapter for bun.",
|
|
4
|
+
"keywords": [
|
|
5
|
+
"sveltekit",
|
|
6
|
+
"adapter",
|
|
7
|
+
"bun"
|
|
8
|
+
],
|
|
4
9
|
"type": "module",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/eslym/sveltekit-adapter-bun.git"
|
|
13
|
+
},
|
|
5
14
|
"files": [
|
|
6
15
|
"dist/**/*"
|
|
7
16
|
],
|
|
@@ -23,5 +32,6 @@
|
|
|
23
32
|
"@rollup/plugin-json": "^6.1.0",
|
|
24
33
|
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
25
34
|
"rollup": "^4.18.0"
|
|
26
|
-
}
|
|
27
|
-
|
|
35
|
+
},
|
|
36
|
+
"version": "1.0.2"
|
|
37
|
+
}
|