bun-dev-server 0.0.1 → 0.0.3
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/@types/windowExtensions.ts +6 -0
- package/bunClientHmr.ts +4 -0
- package/bunHmrPlugin.ts +4 -0
- package/index.ts +6 -4
- package/package.json +4 -3
- package/test/bun.lockb +0 -0
- package/test/bunrun.ts +4 -2
- package/test/package.json +6 -5
- package/test/src/@types/filetypes.d.ts +1 -1
- package/test/tsconfig.json +2 -1
- package/tsconfig.json +2 -1
- package/bun.lockb +0 -0
package/bunClientHmr.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { type BunDevServerSocketConfig } from "./bunServeConfig";
|
|
2
2
|
|
|
3
3
|
function hotReload() {
|
|
4
|
+
if (window.BUN_HMR_INITED) {
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
7
|
+
window.BUN_HMR_INITED = true;
|
|
4
8
|
const hmrSock = new WebSocket("[REPLACE_ENDPOINT]");
|
|
5
9
|
hmrSock.addEventListener("error", (err) => {
|
|
6
10
|
console.error("HMR ERROR", err);
|
package/bunHmrPlugin.ts
CHANGED
package/index.ts
CHANGED
|
@@ -6,7 +6,7 @@ import indexTemplate from "./indexHTMLTemplate.ejs" with { type: "text" };
|
|
|
6
6
|
import { watch, readdir, exists, readFile } from "fs/promises";
|
|
7
7
|
import { type FileChangeInfo } from "fs/promises";
|
|
8
8
|
import { startTSWatcher } from "./bunTSWatcher";
|
|
9
|
-
import {
|
|
9
|
+
import { getBunHMRFooter } from "./bunHmrPlugin";
|
|
10
10
|
import { type BunDevServerConfig } from "./bunServeConfig";
|
|
11
11
|
|
|
12
12
|
|
|
@@ -32,16 +32,18 @@ export async function startBunDevServer(serverConfig: BunDevServerConfig) {
|
|
|
32
32
|
throw e;
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
|
+
const buncfg = { port: finalConfig.port, tls: finalConfig.tls, websocketPath: finalConfig.websocketPath };
|
|
35
36
|
const buildCfg: Bun.BuildConfig = {
|
|
36
37
|
...serverConfig.buildConfig,
|
|
37
38
|
outdir: dst,
|
|
38
|
-
plugins: [...serverConfig.buildConfig.plugins ?? []
|
|
39
|
+
plugins: [...(serverConfig.buildConfig.plugins ?? [])],
|
|
40
|
+
footer: getBunHMRFooter(buncfg),
|
|
39
41
|
}
|
|
40
42
|
|
|
41
43
|
if (serverConfig.cleanServePath) {
|
|
42
44
|
await cleanDirectory(dst);
|
|
43
45
|
}
|
|
44
|
-
|
|
46
|
+
console.log("Starting Bun Dev Server on port", finalConfig.port);
|
|
45
47
|
const bunServer = Bun.serve({
|
|
46
48
|
port: finalConfig.port,
|
|
47
49
|
development: true,
|
|
@@ -122,7 +124,7 @@ export async function startBunDevServer(serverConfig: BunDevServerConfig) {
|
|
|
122
124
|
// });
|
|
123
125
|
|
|
124
126
|
if (finalConfig.enableTypeScriptWatch) {
|
|
125
|
-
if(!finalConfig.watchDir) {
|
|
127
|
+
if (!finalConfig.watchDir) {
|
|
126
128
|
throw new Error("watchDir must be set to enable TypeScript watch");
|
|
127
129
|
}
|
|
128
130
|
const watchDir = Bun.pathToFileURL(finalConfig.watchDir);
|
package/package.json
CHANGED
|
@@ -6,18 +6,19 @@
|
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/SPWizard01/bun-dev-server"
|
|
8
8
|
},
|
|
9
|
-
"version": "0.0.
|
|
9
|
+
"version": "0.0.3",
|
|
10
10
|
"module": "index.ts",
|
|
11
11
|
"type": "module",
|
|
12
|
+
"license": "MIT",
|
|
12
13
|
"scripts": {
|
|
13
14
|
"serve": "bun --hot ./serve.ts"
|
|
14
15
|
},
|
|
15
16
|
"devDependencies": {
|
|
16
|
-
"@types/bun": "
|
|
17
|
+
"@types/bun": "^1.1.11",
|
|
17
18
|
"@types/ejs": "^3.1.5"
|
|
18
19
|
},
|
|
19
20
|
"peerDependencies": {
|
|
20
|
-
"typescript": "^5.
|
|
21
|
+
"typescript": "^5.6.3"
|
|
21
22
|
},
|
|
22
23
|
"dependencies": {
|
|
23
24
|
"ejs": "^3.1.10"
|
package/test/bun.lockb
CHANGED
|
Binary file
|
package/test/bunrun.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { startBunDevServer } from "
|
|
1
|
+
// import { startBunDevServer } from "bun-dev-server";
|
|
2
|
+
import { startBunDevServer } from "../index";
|
|
2
3
|
|
|
3
4
|
startBunDevServer({
|
|
4
5
|
buildConfig: {
|
|
@@ -8,7 +9,8 @@ startBunDevServer({
|
|
|
8
9
|
naming: {
|
|
9
10
|
asset: "assets/[name]-[hash].[ext]",
|
|
10
11
|
chunk: "chunks/[name]-[hash].[ext]",
|
|
11
|
-
}
|
|
12
|
+
},
|
|
13
|
+
sourcemap: "linked"
|
|
12
14
|
},
|
|
13
15
|
cleanServePath: true,
|
|
14
16
|
port: 4567,
|
package/test/package.json
CHANGED
|
@@ -3,14 +3,15 @@
|
|
|
3
3
|
"module": "app.ts",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"devDependencies": {
|
|
6
|
-
"@types/bun": "^1.1.
|
|
6
|
+
"@types/bun": "^1.1.11",
|
|
7
|
+
"bun-dev-server": "^0.0.2"
|
|
7
8
|
},
|
|
8
9
|
"peerDependencies": {
|
|
9
|
-
"typescript": "^5.
|
|
10
|
+
"typescript": "^5.6.3"
|
|
10
11
|
},
|
|
11
12
|
"dependencies": {
|
|
12
|
-
"@pnp/queryable": "^4.
|
|
13
|
-
"@pnp/sp": "^4.
|
|
14
|
-
"bun": "^1.1.
|
|
13
|
+
"@pnp/queryable": "^4.6.0",
|
|
14
|
+
"@pnp/sp": "^4.6.0",
|
|
15
|
+
"bun": "^1.1.31"
|
|
15
16
|
}
|
|
16
17
|
}
|
package/test/tsconfig.json
CHANGED
package/tsconfig.json
CHANGED
package/bun.lockb
DELETED
|
Binary file
|