bun-dev-server 0.2.0 → 0.3.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 +23 -22
- package/bunHmrPlugin.ts +8 -3
- package/package.json +9 -2
package/README.md
CHANGED
|
@@ -1,32 +1,33 @@
|
|
|
1
1
|
# Bun Dev Server
|
|
2
2
|
|
|
3
|
-
```
|
|
3
|
+
```ts
|
|
4
4
|
//devserver.ts
|
|
5
|
-
import {startBunDevServer} from "bun-dev-server"
|
|
6
|
-
import { file } from "bun"
|
|
5
|
+
import { startBunDevServer } from "bun-dev-server";
|
|
6
|
+
import { file } from "bun";
|
|
7
7
|
|
|
8
8
|
startBunDevServer({
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
},
|
|
18
|
-
tls: {
|
|
19
|
-
cert: file("./serve_cert.pem"),
|
|
20
|
-
key: file("./serve_key.pem"),
|
|
9
|
+
buildConfig: {
|
|
10
|
+
entrypoints: ["./src/app.ts"],
|
|
11
|
+
//...
|
|
12
|
+
outdir: "dist",
|
|
13
|
+
splitting: true,
|
|
14
|
+
naming: {
|
|
15
|
+
asset: "assets/[name]-[hash].[ext]",
|
|
16
|
+
chunk: "chunks/[name]-[hash].[ext]",
|
|
21
17
|
},
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
18
|
+
},
|
|
19
|
+
tls: {
|
|
20
|
+
cert: file("./serve_cert.pem"),
|
|
21
|
+
key: file("./serve_key.pem"),
|
|
22
|
+
},
|
|
23
|
+
writeManifest: true,
|
|
24
|
+
cleanServePath: true,
|
|
25
|
+
port: 4567,
|
|
26
|
+
enableTypeScriptWatch: true,
|
|
27
|
+
watchDir: "./src",
|
|
28
|
+
});
|
|
28
29
|
```
|
|
29
30
|
|
|
30
31
|
```
|
|
31
32
|
bun run devserver.ts
|
|
32
|
-
```
|
|
33
|
+
```
|
package/bunHmrPlugin.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { BunPlugin, Loader } from "bun";
|
|
2
2
|
import { bunHotReload } from "./bunClientHmr";
|
|
3
3
|
import { readFile } from "fs/promises";
|
|
4
4
|
import { type BunDevServerSocketConfig } from "./bunServeConfig";
|
|
@@ -10,11 +10,16 @@ export function getBunHMRPlugin(config: BunDevServerSocketConfig) {
|
|
|
10
10
|
let hmrAdded = false;
|
|
11
11
|
build.onLoad({ filter: /\.m?tsx?/ }, async (args) => {
|
|
12
12
|
const contents = await readFile(args.path, { encoding: "utf-8" });
|
|
13
|
+
const isTSx = /\.m?tsx$/.test(args.path);
|
|
14
|
+
const isJSx = /\.m?jsx$/.test(args.path);
|
|
15
|
+
const isJS = /\.m?js$/.test(args.path);
|
|
16
|
+
const isTS = /\.m?ts$/.test(args.path);
|
|
17
|
+
const loader: Loader = isTSx ? "tsx" : isJSx ? "jsx" : isTS ? "ts" : isJS ? "js" : "text";
|
|
13
18
|
if (!hmrAdded) {
|
|
14
19
|
hmrAdded = true;
|
|
15
|
-
return { contents: `import "bun-hot-reload"\n` + contents, loader
|
|
20
|
+
return { contents: `import "bun-hot-reload"\n` + contents, loader };
|
|
16
21
|
}
|
|
17
|
-
return { contents, loader
|
|
22
|
+
return { contents, loader };
|
|
18
23
|
});
|
|
19
24
|
build.onLoad({ filter: /./, namespace: "bun-hot-reload" }, async (args) => {
|
|
20
25
|
|
package/package.json
CHANGED
|
@@ -6,7 +6,14 @@
|
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/SPWizard01/bun-dev-server"
|
|
8
8
|
},
|
|
9
|
-
"
|
|
9
|
+
"keywords": [
|
|
10
|
+
"bun",
|
|
11
|
+
"devserver",
|
|
12
|
+
"hmr",
|
|
13
|
+
"reload",
|
|
14
|
+
"hot"
|
|
15
|
+
],
|
|
16
|
+
"version": "0.3.0",
|
|
10
17
|
"module": "index.ts",
|
|
11
18
|
"type": "module",
|
|
12
19
|
"license": "MIT",
|
|
@@ -17,7 +24,7 @@
|
|
|
17
24
|
"@types/bun": "latest"
|
|
18
25
|
},
|
|
19
26
|
"peerDependencies": {
|
|
20
|
-
"typescript": "^5.
|
|
27
|
+
"typescript": "^5.7.2"
|
|
21
28
|
},
|
|
22
29
|
"dependencies": {
|
|
23
30
|
"ejs": "^3.1.10",
|