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.
@@ -0,0 +1,6 @@
1
+ declare global {
2
+ interface Window {
3
+ BUN_HMR_INITED: boolean;
4
+ }
5
+ }
6
+ export {};
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
@@ -26,4 +26,8 @@ export function getBunHMRPlugin(config: BunDevServerSocketConfig) {
26
26
  },
27
27
  }
28
28
  return bunHMRPlugin;
29
+ }
30
+
31
+ export function getBunHMRFooter(config: BunDevServerSocketConfig) {
32
+ return `(${bunHotReload(config)})()`;
29
33
  }
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 { getBunHMRPlugin } from "./bunHmrPlugin";
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 ?? [], getBunHMRPlugin({ port: finalConfig.port, tls: finalConfig.tls, websocketPath: finalConfig.websocketPath })]
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.1",
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": "latest",
17
+ "@types/bun": "^1.1.11",
17
18
  "@types/ejs": "^3.1.5"
18
19
  },
19
20
  "peerDependencies": {
20
- "typescript": "^5.5.4"
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 "../index"
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.8"
6
+ "@types/bun": "^1.1.11",
7
+ "bun-dev-server": "^0.0.2"
7
8
  },
8
9
  "peerDependencies": {
9
- "typescript": "^5.0.0"
10
+ "typescript": "^5.6.3"
10
11
  },
11
12
  "dependencies": {
12
- "@pnp/queryable": "^4.4.0",
13
- "@pnp/sp": "^4.4.0",
14
- "bun": "^1.1.27"
13
+ "@pnp/queryable": "^4.6.0",
14
+ "@pnp/sp": "^4.6.0",
15
+ "bun": "^1.1.31"
15
16
  }
16
17
  }
@@ -1,4 +1,4 @@
1
1
  declare module "*.svg" {
2
2
  const template: string;
3
3
  export default template;
4
- }
4
+ }
@@ -22,6 +22,7 @@
22
22
  // Some stricter flags (disabled by default)
23
23
  "noUnusedLocals": false,
24
24
  "noUnusedParameters": false,
25
- "noPropertyAccessFromIndexSignature": false
25
+ "noPropertyAccessFromIndexSignature": false,
26
+ "sourceMap": true
26
27
  }
27
28
  }
package/tsconfig.json CHANGED
@@ -23,5 +23,6 @@
23
23
  "noUnusedLocals": false,
24
24
  "noUnusedParameters": false,
25
25
  "noPropertyAccessFromIndexSignature": false
26
- }
26
+ },
27
+ "exclude": ["node_modules"]
27
28
  }
package/bun.lockb DELETED
Binary file